-
-
Save chelovekula/8e0818d1384db9eb073d87262e14d41a to your computer and use it in GitHub Desktop.
~ Spoof the reported window.screen as the most common one so that it can't be used to fingerprint browser.
This file contains 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 Spoof screen resolution & color depth | |
// @namespace https://skyzohlabs.be | |
// @version 1.0.5 | |
// @description Spoof the reported window.screen as the most common one so that it can't be used to fingerprint browser. | |
// @author SkyzohKey | |
// @include http://* | |
// @include https://* | |
// @run-at document-end | |
// @grant none | |
// @downloadURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/screen-spoofer.user.js | |
// @updateURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/screen-spoofer.user.js | |
// ==/UserScript== | |
(function() { | |
"use strict"; | |
/** | |
* Define property on an object. | |
*/ | |
var defineProp = function(obj, prop, val) { | |
Object.defineProperty(obj, prop, { | |
enumerable: true, | |
configurable: true, | |
value: val | |
}); | |
}; | |
/** | |
* Return screen attributes based on the most commons ones. | |
*/ | |
var getScreenAttrs = function() { | |
return { | |
width: 1366, | |
height: 768, | |
colorDepth: 24, | |
pixelDepth: 24 | |
}; | |
}; | |
/** | |
* Spoof screen resolution. | |
*/ | |
var spoofScreenResolution = function() { | |
var screen = getScreenAttrs(); | |
defineProp(window.screen, "width", screen.width); | |
defineProp(window.screen, "height", screen.height); | |
defineProp(window.screen, "availWidth", screen.width); | |
defineProp(window.screen, "availHeight", screen.height); | |
defineProp(window.screen, "top", 0); | |
defineProp(window.screen, "left", 0); | |
defineProp(window.screen, "availTop", 0); | |
defineProp(window.screen, "availLeft", 0); | |
defineProp(window.screen, "colorDepth", screen.colorDepth); | |
defineProp(window.screen, "pixelDepth", screen.pixelDepth); | |
/** | |
* @todo Implement window.innerHeight, window.innerWidth, etc... | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/Screen | |
*/ | |
}; | |
/** | |
* Initialize script | |
*/ | |
var init = function() { | |
// LET SPOOF THAT FUCKIN' RES/COLOR DEPTH | |
spoofScreenResolution(); | |
}; | |
init(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment