Created
December 29, 2016 15:37
-
-
Save mhingston/4164873ea2a1d32525034385686f1b04 to your computer and use it in GitHub Desktop.
A few privacy enhancements for browsers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Privacy Guard | |
| // @namespace https://jumpkick.io/ | |
| // @version 1.0.0 | |
| // @author Miles Hingston | |
| // @include * | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const allow = {}; | |
| // Remove Referrer | |
| let referrer = document.querySelector('meta[name="referrer"]'); | |
| while(referrer) | |
| { | |
| referrer.parentElement.removeChild(referrer); | |
| referrer = document.querySelector('meta[name="referrer"]'); | |
| } | |
| const meta = document.createElement('meta'); | |
| meta.name = 'referrer'; | |
| meta.content = 'no-referrer'; | |
| document.querySelector('head').appendChild(meta); | |
| // Confirm reads from HTML Canvas | |
| const toDataURL = HTMLCanvasElement.prototype.toDataURL; | |
| HTMLCanvasElement.prototype.toDataURL = function() | |
| { | |
| allow.toDataURL = allow.toDataURL === undefined ? confirm(`Do you want to allow the domain '${document.domain}' to read from HTML Canvas?`) : allow.toDataURL; | |
| if(allow.toDataURL) | |
| { | |
| return toDataURL.call(this); | |
| } | |
| }; | |
| // Mock window.navigator object | |
| Object.defineProperty(window, 'navigator', | |
| { | |
| __proto__: null, | |
| value: | |
| { | |
| doNotTrack: '1', | |
| language: 'en', | |
| userAgent: 'Mozilla/5.0' | |
| }, | |
| writable: false, | |
| enumerable: false, | |
| configurable: false | |
| }); | |
| Object.freeze(window.navigator); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment