Anti Devtools Detector

Blocks loading of JavaScript files containing "devtools" or "test" in their names

当前为 2024-04-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Anti Devtools Detector
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Blocks loading of JavaScript files containing "devtools" or "test" in their names
  6. // @author Your name
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Intercept requests and block those containing "devtools" or "test" in their names
  16. const originalFetch = window.fetch;
  17. window.fetch = function(resource, init) {
  18. const url = resource instanceof Request ? resource.url : resource;
  19. if (url.includes("devtools") || url.includes("test")) {
  20. console.log("Blocked request:", url);
  21. return new Promise((resolve, reject) => {
  22. reject(new Error("Blocked by Tampermonkey"));
  23. });
  24. } else {
  25. return originalFetch.apply(this, arguments);
  26. }
  27. };
  28. })();