Skip to content

Instantly share code, notes, and snippets.

@mhingston
Created December 29, 2016 15:37
Show Gist options
  • Select an option

  • Save mhingston/4164873ea2a1d32525034385686f1b04 to your computer and use it in GitHub Desktop.

Select an option

Save mhingston/4164873ea2a1d32525034385686f1b04 to your computer and use it in GitHub Desktop.
A few privacy enhancements for browsers
// ==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