// ==UserScript== // @name 反 devtools-detector (1.0 物理隔离版) // @namespace http://tampermonkey.net/ // @version 1.0 // @description 不重写关键 API,通过控制台静默绕过检测 // @author golyu // @match *://*/* // @run-at document-start // @grant none // @downloadURL https://update.greasyfork.icu/scripts/570123/%E5%8F%8D%20devtools-detector%20%2810%20%E7%89%A9%E7%90%86%E9%9A%94%E7%A6%BB%E7%89%88%29.user.js // @updateURL https://update.greasyfork.icu/scripts/570123/%E5%8F%8D%20devtools-detector%20%2810%20%E7%89%A9%E7%90%86%E9%9A%94%E7%A6%BB%E7%89%88%29.meta.js // ==/UserScript== (function() { 'use strict'; /** * 策略 A: 屏蔽控制台的所有输出。 * 只要控制台不尝试去渲染传入的对象,就永远不会触发那个探测用的 getter。 */ const noop = () => {}; const methods = ['log', 'warn', 'debug', 'info', 'error', 'table', 'dir', 'trace', 'group', 'groupCollapsed', 'groupEnd']; // 备份原始 console const _console = { ...console }; methods.forEach(m => { console[m] = noop; }); /** * 策略 B: 伪造窗口尺寸。 * 很多检测库通过 outerWidth - innerWidth 差值来判断。 */ try { Object.defineProperties(window, { 'outerWidth': { get: () => window.innerWidth, configurable: true }, 'outerHeight': { get: () => window.innerHeight, configurable: true } }); } catch (e) {} /** * 策略 C: 针对 aepkill 库的正则检测。 * 该库会检测正则执行时间,我们让它直接返回,不进行耗时匹配。 */ const originalTest = RegExp.prototype.test; RegExp.prototype.test = function(str) { if (str && str.length > 500) return false; // 拦截超长字符串探测 return originalTest.apply(this, arguments); }; /** * 策略 D: 恢复真正的控制台功能 (手动开关) * 因为我们禁用了 console.log,你可以通过这个全局变量在需要时看日志。 */ window.showLog = () => { methods.forEach(m => { console[m] = _console[m]; }); console.warn("警告:控制台日志已恢复,检测库可能会发现你!"); }; console.info("fuck-devtools-detector 1.0: 控制台已静默,检测逻辑已阻断。"); })();