Guest User

Anti-privacy block userscript

a guest
Apr 24th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         NYTimes Privacy Blocker
  3. // @version      0.1
  4. // @description  Prevent sites detecting if you're in incognito by calling the success callback of webkitRequestFileSystem even if it's failing.
  5. // @author       You
  6. // @run-at       document-start
  7. // @match        *://*.nytimes.com/*
  8. // @match        *://*.wsj.com/*
  9. // @match        *://*.bloomberg.com/*
  10. // @match        *://*.newyorker.com/*
  11. // @match        *://*.vanityfair.com/*
  12. // @match        *://*.economist.com/*
  13. // @match        *://*.bostonglobe.com/*
  14. // @grant        none
  15. // ==/UserScript==
  16.  
  17. (function() {
  18.     'use strict';
  19.  
  20.     function injectScript(script, node) {
  21.         var element = document.createElement('script');
  22.         element.setAttribute('type', 'text/javascript');
  23.         element.setAttribute('async', false);
  24.         element.text = script;
  25.         node.appendChild(element);
  26.     }
  27.     var node = document.documentElement;
  28.     var script = '';
  29.     if ("[object SafariRemoteNotification]" === (!window.safari || safari.pushNotification).toString()) {
  30.         //Safari
  31.         script = `(function(openDatabase) {
  32.                      window.openDatabase = function(shortName, version, displayName, maxSize) {
  33.                      return {};
  34.                      }
  35.                   })(window.openDatabase);`;
  36.     } else if (window.indexedDB && /Firefox/.test(window.navigator.userAgent)) {
  37.         //Firefox
  38.         script = `(function(open) {
  39.                      window.indexedDB.open = function(name, version = 1){ return {readyState: "done", result: {} }; }
  40.                   })(window.indexedDB.open);`;
  41.     } else if (window.webkitRequestFileSystem) {
  42.         //Chrome
  43.         script = `(function(webkitRequestFileSystem) {
  44.                      window.webkitRequestFileSystem = function(type, size, successCallback, errorCallback) {
  45.                          webkitRequestFileSystem(type, size, successCallback, successCallback);
  46.                      }
  47.                   })(window.webkitRequestFileSystem);`;
  48.     } // TODO - MS Edge
  49.  
  50.     if (script) injectScript(script, node);
  51. })();
Advertisement
Add Comment
Please, Sign In to add comment