Greasy Fork is available in English.

Tool For All Website

Block websites from knowing if you switched tabs/windows

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greasyfork.org/scripts/457405/1133633/Tool%20For%20All%20Website.js

  1. // ==UserScript==
  2. // @name Tool For All Website
  3. // @namespace SuperNova
  4. // @match *://*/*
  5. // @run-at document-start
  6. // @grant GM_xmlhttpRequest
  7. // @version 1.1
  8. // @author Saputra
  9. // @description Block websites from knowing if you switched tabs/windows
  10.  
  11. // ==/UserScript==
  12.  
  13. // This userscript blocks the page visibility API and to some extent the old blur/focus APIs.
  14.  
  15. let events_to_block = [
  16. "visibilitychange",
  17. "webkitvisibilitychange",
  18. "mozvisibilitychange",
  19. "hasFocus",
  20. "blur",
  21. "focus",
  22. "mouseleave"
  23. ]
  24.  
  25. for (event_name of events_to_block) {
  26. document.addEventListener(event_name, function (event) {
  27. event.preventDefault();
  28. event.stopPropagation();
  29. event.stopImmediatePropagation();
  30. }, true);
  31. }
  32.  
  33. for (event_name of events_to_block) {
  34. window.addEventListener(event_name, function (event) {
  35. event.preventDefault();
  36. event.stopPropagation();
  37. event.stopImmediatePropagation();
  38. }, true);
  39. }
  40.  
  41.  
  42. document.hasFocus = function () { return true; };
  43. document.onvisibilitychange = null;
  44. Object.defineProperty(document, "visibilityState", { value: "visible" });
  45. Object.defineProperty(document, "hidden", { value: false });
  46. Object.defineProperty(document, "mozHidden", { value: false });
  47. Object.defineProperty(document, "webkitHidden", { value: false });
  48. Object.defineProperty(document, "webkitVisibilityState", { value: "visible" });