Remove Experimental / Deprecated Useless APIs

to remove useless APIs (either experimental or deprecated) like IdleDetector

目前为 2023-06-11 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Experimental / Deprecated Useless APIs
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.0
  5. // @description to remove useless APIs (either experimental or deprecated) like IdleDetector
  6. // @author CY Fung
  7. // @match https://*/*
  8. // @match http://*/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
  10. // @grant none
  11. // @run-at document-start
  12. // @license MIT
  13. // @compatible chrome
  14. // @compatible firefox
  15. // @compatible opera
  16. // @unwrap
  17. // @allFrames
  18. // @inject-into page
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. 'use strict';
  23.  
  24. if (typeof IdleDetector === 'function') {
  25. IdleDetector = undefined;
  26. delete window.IdleDetector;
  27. }
  28.  
  29. if (typeof webkitCancelAnimationFrame === 'function') {
  30. webkitCancelAnimationFrame = undefined;
  31. delete window.webkitCancelAnimationFrame;
  32. }
  33.  
  34. if (typeof webkitRequestAnimationFrame === 'function') {
  35. webkitRequestAnimationFrame = undefined;
  36. delete window.webkitRequestAnimationFrame;
  37. }
  38.  
  39. if (typeof styleMedia === 'function') {
  40. // This feature is deprecated/obsolete and should not be used.
  41. styleMedia = undefined;
  42. delete window.styleMedia;
  43. }
  44. if (typeof launchQueue === 'object') {
  45. // This feature is experimental. Use caution before using in production.
  46. launchQueue = undefined;
  47. delete window.launchQueue;
  48. }
  49.  
  50. if (typeof webkitRequestFileSystem === 'function') {
  51. // This feature is deprecated/obsolete and should not be used.
  52. webkitRequestFileSystem = undefined;
  53. delete window.webkitRequestFileSystem;
  54. }
  55.  
  56. if (typeof webkitResolveLocalFileSystemURL === 'function') {
  57. // This feature is non-standard and should not be used without careful consideration.
  58. webkitResolveLocalFileSystemURL = undefined;
  59. delete window.webkitResolveLocalFileSystemURL;
  60. }
  61.  
  62. if (typeof VRDisplayEvent === 'function') {
  63. // This feature is deprecated/obsolete and should not be used.
  64. VRDisplayEvent = undefined;
  65. delete window.VRDisplayEvent;
  66. }
  67.  
  68. if (typeof HTMLFrameSetElement === 'function') {
  69. // This feature is deprecated/obsolete and should not be used.
  70. HTMLFrameSetElement = undefined;
  71. delete window.HTMLFrameSetElement;
  72. }
  73.  
  74. if (typeof CanMakePaymentEvent === 'function'){
  75. // This feature is experimental. Use caution before using in production.
  76. CanMakePaymentEvent = undefined;
  77. delete window.CanMakePaymentEvent;
  78. }
  79.  
  80.  
  81. if (typeof PositionSensorVRDevice === 'function'){
  82. // This feature is deprecated/obsolete and should not be used.
  83. PositionSensorVRDevice = undefined;
  84. delete window.PositionSensorVRDevice;
  85. }
  86.  
  87. if (typeof PerformanceTiming === 'function') {
  88. // This feature is deprecated/obsolete and should not be used.
  89. PerformanceTiming = undefined;
  90. delete window.PerformanceTiming;
  91. }
  92.  
  93. if (typeof navigation === 'function') {
  94. // This feature is experimental. Use caution before using in production.
  95. navigation = undefined;
  96. delete window.navigation;
  97. }
  98.  
  99.  
  100.  
  101. /*
  102.  
  103. let arr = ["navigation", "onsearch", "trustedTypes",
  104. "onappinstalled", "onbeforeinstallprompt", "onbeforexrselect", "oncancel", "oncontextlost",
  105. "oncontextrestored", "onmousewheel", "onpointerrawupdate",
  106. "scheduler", "chrome", "credentialless", "launchQueue",
  107. "onbeforematch", "onbeforetoggle", "originAgentCluster",
  108. "oncontentvisibilityautostatechange", "openDatabase", "webkitRequestFileSystem", "webkitResolveLocalFileSystemURL"];
  109.  
  110. */
  111.  
  112. // Your code here...
  113. })();