File tree Expand file tree Collapse file tree 5 files changed +27
-11
lines changed
Expand file tree Collapse file tree 5 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ class RequestAnalyzer {
5353 }
5454 let jsonpScore = 100 ;
5555
56+ // TODO 2024-12-22 01:32:28 如果是名称完全等于callback和包含callback,得到的分值是不是不应该一样?
5657 // 判断参数中的jsonp参数特征,参数名
5758 const paramName = param . name . toLowerCase ( ) ;
5859 if ( paramName . indexOf ( "callback" ) !== - 1 ) {
Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ class Debugger {
6666 }
6767 if ( ! jsonpCallbackFunctionName ) {
6868 // TODO 2023-8-22 01:00:27 完善错误提示信息
69- throw new Error ( "must give me analyzer function param name, example: callback" ) ;
69+ // throw new Error("must give me analyzer function param name, example: callback");
70+ console . error ( "Could not parse jsonp callback function" , jsonpCallbackFunctionName ) ;
71+ return ;
7072 }
7173
7274 // 为响应体中的回调函数增加hook
Original file line number Diff line number Diff line change @@ -24,7 +24,11 @@ class DocumentHook {
2424 this . document . createElement = function ( ) {
2525 const result = _this . documentCreateHolder . apply ( this , arguments ) ;
2626 if ( arguments . length && arguments [ 0 ] . toLowerCase ( ) === "script" ) {
27- new ScriptHook ( result ) . addHook ( ) ;
27+ try {
28+ new ScriptHook ( result ) . addHook ( ) ;
29+ } catch ( e ) {
30+ console . error ( e ) ;
31+ }
2832 }
2933 return result ;
3034 }
Original file line number Diff line number Diff line change @@ -38,8 +38,12 @@ class ObjectFunctionHook {
3838 // 为函数添加Hook
3939 this . object [ this . functionName ] = function ( ) {
4040
41- // TODO 2023-8-21 22:15:09 在函数执行的时候尝试触发各种断点
42- hookCallbackFunction . apply ( this )
41+ try {
42+ // TODO 2023-8-21 22:15:09 在函数执行的时候尝试触发各种断点
43+ hookCallbackFunction . apply ( this )
44+ } catch ( e ) {
45+ console . error ( e ) ;
46+ }
4347
4448 return functionHolder . apply ( this , arguments ) ;
4549 }
Original file line number Diff line number Diff line change @@ -30,16 +30,21 @@ class ScriptHook {
3030 return srcHolder ;
3131 } , set : function ( newSrc ) {
3232
33- // 初始化请求上下文
34- const requestContext = RequestContext . parseRequestContext ( newSrc ) ;
35- const scriptContext = new ScriptContext ( newSrc , requestContext , null ) ;
33+ // 尽量不要影响页面原有的流程
34+ try {
35+ // 初始化请求上下文
36+ const requestContext = RequestContext . parseRequestContext ( newSrc ) ;
37+ const scriptContext = new ScriptContext ( newSrc , requestContext , null ) ;
3638
37- const requestAnalyzer = new RequestAnalyzer ( ) ;
38- requestAnalyzer . analyze ( requestContext ) ;
39+ const requestAnalyzer = new RequestAnalyzer ( ) ;
40+ requestAnalyzer . analyze ( requestContext ) ;
3941
40- // 在请求发送之前测试断点
42+ // 在请求发送之前测试断点
4143
42- debuggerManager . testAll ( scriptContext ) ;
44+ debuggerManager . testAll ( scriptContext ) ;
45+ } catch ( e ) {
46+ console . error ( e ) ;
47+ }
4348
4449 // 这里认为script不会被复用,所以添加的hook在设置src的时候就会被删除掉,会有script复用的情况吗?
4550 delete _this . script . src ;
You can’t perform that action at this time.
0 commit comments