反 devtools-detector 反调试

麻麻再也不怕 https://github.com/AEPKILL/devtools-detector 不让我调试啦!

  1. /* eslint-disable no-multi-spaces */
  2.  
  3. // ==UserScript==
  4. // @name 反 devtools-detector 反调试
  5. // @name:zh-CN 反 devtools-detector 反调试
  6. // @name:en Anti devtools-detector
  7. // @namespace Anti-devtools-detector
  8. // @version 0.1
  9. // @description 麻麻再也不怕 https://github.com/AEPKILL/devtools-detector 不让我调试啦!
  10. // @description:zh-CN 麻麻再也不怕 https://github.com/AEPKILL/devtools-detector 不让我调试啦!
  11. // @description:en Anti https://github.com/AEPKILL/devtools-detector
  12. // @author PY-DNG
  13. // @license GPL-v3
  14. // @match http*://blog.aepkill.com/demos/devtools-detector/*
  15. // @icon none
  16. // @grant none
  17. // @run-at document-start
  18. // ==/UserScript==
  19.  
  20. (function __MAIN__() {
  21. 'use strict';
  22.  
  23. const LOG_KAWAII_HIKARI = true;
  24. const TEXT_HIKARI = ['%cdevtools-detector has been disabled', 'color: green;'] //'嘿嘿嘿,hikari,嘿嘿嘿…';
  25. const HIKARI_CODE = 'https://greatest.deepsurf.us/scripts/456001/code/script.js';
  26. const launchHikari = function() {
  27. if (LOG_KAWAII_HIKARI) {
  28. // Draw an cute image of hikari in the console when devtools-detector attempting to launch
  29. // Use xhr instead of @require / @resource / in-script-code aims to speed up
  30. // userscript loading, make disable_launch as fast as possible
  31. const xhr = new XMLHttpRequest();
  32. xhr.open('GET', HIKARI_CODE);
  33. xhr.onerror = logTextHikari;
  34. xhr.onload = function() {
  35. try {
  36. const code = xhr.responseText + '\nconsole.log.apply(console, KAWAII_HIKARI)';
  37. const func = new Function(code);
  38. func();
  39. } catch(err) {
  40. logTextHikari();
  41. }
  42. }
  43. xhr.send();
  44. } else {
  45. // Or, just log some text
  46. logTextHikari();
  47. }
  48.  
  49. function logTextHikari() {
  50. console.log.apply(console, TEXT_HIKARI);
  51. }
  52. }
  53. disable_launch(launchHikari);
  54.  
  55. // Disable devtools-detector by hooking devtoolsDetector.launch
  56. function disable_launch(alt) {
  57. console.log('disabling launch');
  58.  
  59. let map = new Map();
  60. const func = function() {
  61. delete Object.prototype.launch;
  62. Object.getPrototypeOf(this).launch = alt;
  63. this.launch();
  64. };
  65. Object.defineProperty(Object.prototype, 'launch', {
  66. set: function(f) {
  67. const checked = funcChecked(f);
  68. map.set(this, checked ? func : f);
  69. return true;
  70. },
  71. get: function() {
  72. return getVal(this);
  73.  
  74. function getVal(obj) {
  75. return obj ? (map.has(obj) ? map.get(obj) : getVal(Object.getPrototypeOf(obj))) : undefined;
  76. }
  77. },
  78. configurable: true,
  79. enumerable: false
  80. });
  81.  
  82. function funcChecked(f) {
  83. if (f && typeof f.toString === 'function') {
  84. const str = f.toString();
  85. if (typeof str === 'string' && str.includes('_detectLoopDelay')) {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. }
  92. })();