Disable WordPress Jetpack Stats when someone saves your webpage

I recently ran into a small problem when someone appeared to have saved a page on my site and seemed to be testing it locally on their machine (based on the analytics). I contacted the (awesome) guys at Automattic about the issue, they referred it up the chain but ultimately were not able to resolve it:

Dom,

I just received a reply from one of our developers, and I’m afraid we won’t be able to help; If someone saved a copy of your page on their machine in India, we do not have a way to exclude their hits since no referrer information gets sent from pages with file:// protocol. We also cannot clean stats for a specific post at the moment, unfortunately.

Sorry not to be able to help you more.

*Team Member*
Happiness Engineer | WordPress.com | Automattic

The following method will work for pages that are saved after this code has been added. Pages that have already been saved and are sending page views will still continue sending page views as there currently doesn’t appear to be a way to disable them*.

I ended up writing a very quick solution to the problem by simply checking the document.location.hostname to see if it matches my domain, and if not, then remove the WordPress JetPack stats script.