File tree Expand file tree Collapse file tree 8 files changed +109
-0
lines changed
Expand file tree Collapse file tree 8 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 8787<td >移除常见网页的水印,请自行处理<code >@match</code >到匹配地址。</td >
8888</tr >
8989
90+ <tr >
91+ <td >移除 DevTools 拦截器</td >
92+ <td ><a href =" https://github.com/WindrunnerMax/TKScript/blob/master/packages/devtools/README.md " >详情</a ></td >
93+ <td >
94+ <a href =" https://windrunnermax.github.io/TKScript/devtools.user.js " >安装</a >
95+ <span >|</span >
96+ <a href =" https://cdn.jsdelivr.net/gh/WindrunnerMax/TKScript@gh-pages/devtools.user.js " >备用</a >
97+ </td >
98+ <td >移除调试器拦截器,防止浏览器<code >DevTools</code >被拦截。</td >
99+ </tr >
100+
90101<tr >
91102<td >自动展开阅读全文</td >
92103<td ><a href =" https://github.com/WindrunnerMax/TKScript/blob/master/packages/expansion/README.md " >详情</a ></td >
Original file line number Diff line number Diff line change 1+ # 移除 DevTools 拦截器
2+
3+ 移除调试器拦截器,防止浏览器 DevTools 被拦截。
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " Remove Debugger Interceptor" ,
3+ "namespace" : " https://github.com/WindrunnerMax/TKScript" ,
4+ "version" : " 1.0.0" ,
5+ "description" : " 移除调试器拦截器" ,
6+ "author" : " Czy" ,
7+ "match" : [" http://*/*" , " https://*/*" ],
8+ "supportURL" : " https://github.com/WindrunnerMax/TKScript/issues" ,
9+ "license" : " GPL License" ,
10+ "installURL" : " https://github.com/WindrunnerMax/TKScript" ,
11+ "run-at" : " document-start" ,
12+ "grant" : [ " unsafeWindow" ]
13+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " devtools" ,
3+ "version" : " 1.0.0" ,
4+ "author" : " Czy" ,
5+ "license" : " MIT" ,
6+ "repository" : {
7+ "type" : " git" ,
8+ "url" : " git://github.com/WindrunnerMax/TKScript"
9+ },
10+ "scripts" : {
11+ "lint:ts" : " ../../node_modules/typescript/bin/tsc --noEmit"
12+ },
13+ "sideEffects" : false ,
14+ "files" : [
15+ " src"
16+ ]
17+ }
Original file line number Diff line number Diff line change 1+ declare const unsafeWindow = window ;
2+
3+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4+ type Any = any ;
Original file line number Diff line number Diff line change 1+ let isHooked = false ;
2+
3+ const InitLog = unsafeWindow . console . log ;
4+ const InitSetInterval = unsafeWindow . setInterval ;
5+ const InitCloseWindow = unsafeWindow . close ;
6+ const InitFunctionConstructor = unsafeWindow . Function . prototype . constructor ;
7+
8+ ( < Any > unsafeWindow ) . logger = InitLog ;
9+
10+ function hookedFunctionConstructor ( ...args : unknown [ ] ) {
11+ if ( args [ 0 ] == "debugger" ) {
12+ return function ( ) {
13+ isHooked = true ;
14+ } ;
15+ }
16+ return InitFunctionConstructor ( ...args ) ;
17+ }
18+ unsafeWindow . Function . prototype . constructor = hookedFunctionConstructor ;
19+
20+ function hookedSetInterval < TArgs extends unknown [ ] > (
21+ callback : ( ...args : TArgs ) => void ,
22+ ms ?: number ,
23+ ...args : TArgs
24+ ) {
25+ if ( callback && callback . toString ( ) ) {
26+ const funString = callback . toString ( ) as string ;
27+ if (
28+ funString . includes ( "debugger" ) ||
29+ funString . includes ( "window.close" ) ||
30+ / \. o n d e v t o o l / i. test ( funString )
31+ ) {
32+ isHooked = true ;
33+ return - 1 ;
34+ }
35+ }
36+ return InitSetInterval ( callback , ms , ...args ) ;
37+ }
38+ unsafeWindow . setInterval = hookedSetInterval as typeof setInterval ;
39+
40+ function hookedCloseWindow ( ) {
41+ if ( isHooked ) return void 0 ;
42+ InitCloseWindow ( ) ;
43+ }
44+ unsafeWindow . close = hookedCloseWindow ;
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../../tsconfig.json" ,
3+ "include" : [" ./src/**/*.ts" , " ./src/**/*.tsx" ]
4+ }
Original file line number Diff line number Diff line change @@ -76,6 +76,19 @@ const scriptConfig = [
7676 injectCss : false ,
7777 } ,
7878 } ,
79+ {
80+ name : "Devtools" ,
81+ meta : {
82+ input : "./meta/blank.ts" ,
83+ output : "./dist/meta/devtools.meta.js" ,
84+ metaFile : "./packages/devtools/meta.json" ,
85+ } ,
86+ script : {
87+ input : "./packages/devtools/src/index.ts" ,
88+ output : "./dist/devtools.user.js" ,
89+ injectCss : false ,
90+ } ,
91+ } ,
7992] ;
8093
8194export default [
You can’t perform that action at this time.
0 commit comments