Last active
August 29, 2015 14:04
-
-
Save jvatic/07a60099b4821e971c2b to your computer and use it in GitHub Desktop.
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 Canvas Tracking Blocker | |
// @namespace ctb | |
// @description Monkey patches toDataURL for canvas to make it non-deterministic | |
// @include * | |
// @version 1 | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
var toDataURL = HTMLCanvasElement.prototype.toDataURL; | |
HTMLCanvasElement.prototype.toDataURL = function () { | |
if ( !this.__obstructed ) { | |
var ctx = this.getContext("2d"); | |
ctx.fillStyle = "rgba(255, 255, 255, 0.1)"; | |
ctx.fillRect(Math.random(1), Math.random(1), Math.random(0.2), Math.random(0.2)); | |
this.__obstructed = true; | |
} | |
return toDataURL.apply(this, arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment