Skip to content

Instantly share code, notes, and snippets.

@SkyzohKey
Last active June 4, 2024 10:23
Show Gist options
  • Save SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2 to your computer and use it in GitHub Desktop.
Save SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2 to your computer and use it in GitHub Desktop.

Revisions

  1. SkyzohKey revised this gist Apr 25, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion screen-spoofer.user.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Spoof screen resolution & color depth
    // @namespace https://skyzohlabs.be
    // @version 1.0.0
    // @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://*
  2. SkyzohKey revised this gist Apr 25, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions screen-spoofer.user.js
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    // @include https://*
    // @run-at document-end
    // @grant none
    // @downloadURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/7d66029a8306d6822ed47d0daf969adf34fddae1/screen-spoofer.user.js
    // @updateURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/7d66029a8306d6822ed47d0daf969adf34fddae1/screen-spoofer.user.js
    // @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";
  3. SkyzohKey revised this gist Apr 25, 2018. 1 changed file with 2 additions and 15 deletions.
    17 changes: 2 additions & 15 deletions screen-spoofer.user.js
    Original file line number Diff line number Diff line change
    @@ -54,26 +54,13 @@
    * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen
    */
    };
    /**
    * Called on any DOM change to handle "video" tags added dynamically
    */
    var handleDomChange = function(mutations) {
    if (mutations.length === 0) {
    spoofScreenResolution();
    }
    };

    /**
    * Initialize script
    */
    var init = function() {
    // Check existing elements first
    // LET SPOOF THAT FUCKIN' RES/COLOR DEPTH
    spoofScreenResolution();
    // Set up a mutation observer to handle dynamically added video tags
    /*var observer = new MutationObserver(handleDomChange);
    observer.observe(document.body, {
    childList: true,
    subtree: true
    });*/
    };
    init();
    })();
  4. SkyzohKey revised this gist Apr 25, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions screen-spoofer.user.js
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    // @include https://*
    // @run-at document-end
    // @grant none
    // @#downloadURL
    // @#updateURL
    // @downloadURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/7d66029a8306d6822ed47d0daf969adf34fddae1/screen-spoofer.user.js
    // @updateURL https://gist.github.com/SkyzohKey/1f8fe7c070cfe9e98f5dc9ec0c5caee2/raw/7d66029a8306d6822ed47d0daf969adf34fddae1/screen-spoofer.user.js
    // ==/UserScript==
    (function() {
    "use strict";
  5. SkyzohKey created this gist Apr 25, 2018.
    79 changes: 79 additions & 0 deletions screen-spoofer.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    // ==UserScript==
    // @name Spoof screen resolution & color depth
    // @namespace https://skyzohlabs.be
    // @version 1.0.0
    // @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
    // @#updateURL
    // ==/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
    */
    };
    /**
    * Called on any DOM change to handle "video" tags added dynamically
    */
    var handleDomChange = function(mutations) {
    if (mutations.length === 0) {
    spoofScreenResolution();
    }
    };
    /**
    * Initialize script
    */
    var init = function() {
    // Check existing elements first
    spoofScreenResolution();
    // Set up a mutation observer to handle dynamically added video tags
    /*var observer = new MutationObserver(handleDomChange);
    observer.observe(document.body, {
    childList: true,
    subtree: true
    });*/
    };
    init();
    })();