Window Name Eraser

Preventing data leakage through window.name

当前为 2023-02-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Window Name Eraser
  3. // @namespace https://tampermonkey.net/
  4. // @version 1.0
  5. // @description Preventing data leakage through window.name
  6. // @author Streampunk
  7. // @match http://*/*
  8. // @match https://*/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. 'use strict';
  14.  
  15. //Prevent the website from starting
  16. var a = window.onload;
  17. window.onload = "";
  18.  
  19. //Remove property
  20. var old = window.name;
  21. window.name = "";
  22.  
  23. if (old != "" ) {
  24. console.log("Evaluating results");
  25. Firefox.extension.sendMessage({url: document.domain, caption: old}, function(response)
  26. {
  27. switch (response.radio) {
  28. case "fallback":
  29. //White listed: bring back the property
  30. window.name = old;
  31. console.log("Window Name Eraser: Whitelisted domain");
  32. break;
  33. default:
  34. console.log("Window Name Eraser: Blocked domain");
  35. break;
  36. }
  37. //Let the website start
  38. var getType = {};
  39. if (a && getType.toString.call(a) == '[object Function]') {
  40. window.onload = function () { a(); }
  41. }
  42. });
  43. }
  44. else {
  45. //Let the website start
  46. var getType = {};
  47. if (a && getType.toString.call(a) == '[object Function]') {
  48. window.onload = function () { a(); }
  49. }
  50. console.log("Window Name Eraser: Nothing to block here");
  51. }