放飞 disable-devtool

在禁用 disable-devtool 和 devtools-detector 的同时,使网站完美运行。

  1. // ==UserScript==
  2. // @name No DisableDevTool
  3. // @name:zh-CN 放飞 disable-devtool
  4. // @name:ja disable-devtool をぶち壊せ
  5. // @namespace NoDisableDevTool
  6. // @version 1.1.2
  7. // @description Break disable-devtool and devtools-detector while keeping the website working perfectly.
  8. // @description:zh-CN 在禁用 disable-devtool 和 devtools-detector 的同时,使网站完美运行。
  9. // @description:ja disable-devtool と devtools-detector を壊すながら、ウェブサイトに影響を及ぼさず。
  10. // @author FurryR
  11. // @match *://*/*
  12. // @license MIT
  13. // @grant none
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. if (document instanceof XMLDocument) {
  21. return;
  22. }
  23.  
  24. const slice = Array.prototype.slice;
  25. Array.prototype.slice = function (...args) {
  26. if (args.length === 0 && Array.prototype.every.call(this, v => v && typeof v === 'object' && typeof v.name === 'string' && typeof v.isOpen === 'function' && typeof v.isEnable === 'function')) {
  27. Array.prototype.slice = slice;
  28. return [];
  29. }
  30. return slice.call(this, args);
  31. };
  32.  
  33. const assign = Object.assign;
  34. Object.assign = function (...args) {
  35. if (args.length === 2 && typeof args[0] === 'function' && typeof args[1] === 'object' && args[1] !== null && typeof args[1].isDevToolOpened === 'function' && typeof args[1].version === 'string' && typeof args[1].isRunning === 'boolean' && typeof args[1].isSuspend === 'boolean') {
  36. Object.assign = assign;
  37. const result = Object.assign(...args);
  38. console.log('Detected disable-devtool component', result);
  39. return Object.assign(function () {
  40. console.trace('disable-devtool called here');
  41. }, args[1]);
  42. }
  43. return assign.call(this, ...args);
  44. }
  45. })();