V2EX strugglers
 strugglers 最近的时间轴更新
strugglers

strugglers

V2EX 第 431100 号会员,加入于 2019-07-22 14:23:11 +08:00
今日活跃度排名 22484
strugglers 最近回复了
// ==UserScript==
// @name 移除开发者工具防护
// @namespace http://tampermonkey.net/
// @version 2025-04-02
// @description 移除页面中监听开发者工具打开的行为
// @author struggler
// @match *://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-start
// ==/UserScript==

;(function () {
"use strict"

// 主防护函数
const applyProtectiOns= () => {
// 1. 重写关键函数和构造函数
overrideFunctionConstructors()

// 2. 修改定时器行为
modifyTimers()

// 3. 处理 eval 和错误捕获
handleEvalAndErrors()

// 4. 反开发者工具检测
antiDevToolsDetection()

// 5. 移除事件监听
//removeEventListeners()

// 6. 覆盖常见检测函数
overrideDetectionFunctions()

// 7. 阻止 debugger 检测
preventDebuggerDetection()

console.log("[开发者工具防护] 所有防护措施已激活")
}

// 1. 重写关键函数和构造函数
const overrideFunctiOnConstructors= () => {
// 重写 Function 构造函数
Function.prototype.constructor_ = Function.prototype.constructor
Function.prototype.cOnstructor= function (code) {
if (code === "debugger") {
return function () {}
}
return Function.prototype.constructor_.call(this, code)
}
}

// 2. 修改定时器行为
const modifyTimers = () => {
// 重写 setInterval 函数
const originalSetInterval = window.setInterval
window.setInterval = function (callback, delay) {
if (callback && callback.toString) {
var funString = callback.toString()
if (funString.indexOf("debugger") > -1) return
if (funString.indexOf("window.close") > -1) return
}
delay = delay * 10000
return originalSetInterval(callback, delay)
}
}

// 3. 处理 eval 和错误捕获
const handleEvalAndErrors = () => {
// 保存原始的 try-catch 逻辑
const originalTryCatch = {
try: window.eval,
catch: window.onerror,
}

// 劫持 eval
window.eval = function (code) {
return originalTryCatch.try.apply(this, arguments)
}

// 劫持全局错误处理
window.Onerror= function () {
return true
}
}

// 4. 反开发者工具检测
const antiDevToolsDetection = () => {
// 禁用基于 debugger 的检测
window.debugger = function () {}
window.debugger.toString = () => "function debugger() { [native code] }"
window.console.clear = () => {}

// 禁用基于 console.log 的检测
if (!window.console) window.cOnsole= {}

// 禁用基于时间差的检测
const originalDate = window.Date
window.Date = new Proxy(window.Date, {
construct(target, args) {
if (args.length === 0) {
return new originalDate(originalDate.now())
}
return new originalDate(...args)
},
})

// 禁用基于 Function.toString 的检测
const originalToString = Function.prototype.toString
Function.prototype.toString = function () {
if (this === window.console.log || this === window.debugger) {
return "function() { [native code] }"
}
return originalToString.call(this)
}

// 禁用基于窗口大小的检测
Object.defineProperty(window, "outerWidth", {
get: () => window.innerWidth + 100,
configurable: false,
})
Object.defineProperty(window, "outerHeight", {
get: () => window.innerHeight + 100,
configurable: false,
})
}

// 5. 移除事件监听
const removeEventListeners = () => {
// 覆盖 addEventListener
const originalAdd = EventTarget.prototype.addEventListener
EventTarget.prototype.addEventListener = function (type) {
if (["keydown", "resize"].includes(type)) {
return
}
originalAdd.apply(this, arguments)
}

// 清除特定事件属性
;["onkeydown", "onresize"].forEach((prop) => {
if (window[prop]) window[prop] = null
if (document[prop]) document[prop] = null
})
}

// 6. 覆盖常见检测函数
const overrideDetectiOnFunctions= () => {
window.__detectDevTools = function () {
return false
}
window.__CHROME_DEVTOOLS_EXTENSION_DETECTED__ = false
window.devtools = { isOpen: false }
window.performance.now = function () {
return Date.now()
}
}

// 7. 阻止 debugger 检测
const preventDebuggerDetection = () => {
const originalDebugger = Function.prototype.constructor
Function.prototype.cOnstructor= function () {
const fn = originalDebugger.apply(this, arguments)
if (arguments[0] && arguments[0].includes("debugger")) {
return function () {}
}
return fn
}
}

// 立即执行所有防护措施
applyProtections()
})()


写了个油猴脚本解决
2019-09-15 09:34:21 +08:00
回复了 xiaoliangtian 创建的主题 求职 [杭州] -19 毕业 找了快两个月的前端,还没找到。
电子专业的路过,感觉你里面的项目很难让人眼前一亮,我大学是做了一个学校里查询成绩的小程序,最后又加了很多乱七八糟等我功能,然后找工作就靠这个,告诉他们用户有多少,实际效果怎么样,然后顺利找到了工作,你现在也可以利用闲暇时间整一个有想法的项目,到时候就拿这个说话,既然没经验,那就拿项目说话
关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5204 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 13ms UTC 09:14 PVG 17:14 LAX 02:14 JFK 05:14
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86