-
Notifications
You must be signed in to change notification settings - Fork 32
/
hookHead.js
78 lines (53 loc) · 1.81 KB
/
hookHead.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
if (!window.MyDb) {
window.MyDb = {};
window.MyXhr = XMLHttpRequest;
}
if(!window.ting_hook||!window.ting_search){
function ting_hook(s, n,functionType ) {
if (typeof s !== "string") {
return s
}
if (n==3){
console.log("解析:",functionType,"内容")
xhr = new window.MyXhr()
xhr.open("POST", "/handleJsCode", false);
xhr.send(s);
let res = xhr.responseText
return res
}
let _ting_obj = {};
Error.captureStackTrace(_ting_obj);
let _stack = _ting_obj.stack.split("\n")[n];
if (functionType!="eval" && "大Function"){
_stack = "源代码:"+functionType+" "+_stack;
}
window.MyDb[s]instanceof Array ? window.MyDb[s].push(_stack) : window.MyDb[s] = Array(_stack);
return s
}
function ting_search(res) {
let arr = window.MyDb[res];
if (arr) {
let d = {};
for (let i = 0; i < arr.length; i++) {
if (arr[i]){
let jsPath = arr[i]
// let jsPath = arr[i].split(":")
//
// jsPath.pop()
// jsPath = jsPath.join(":")
d[jsPath]? d[jsPath]+=1: d[jsPath]=1
}else{
d[typeof arr[i]] +=1
}
}
console.log("\t\t\t\t\t\t\t\t出现次数\t\t\t\t\t\t\t\t位置地址");
for(let i in d){
console.log("\t\t\t\t\t\t\t\t",d[i],"\t\t\t\t\t\t\t\t",i);
}
return
}
console.log("无数据!!");
}
window.ting_hook = ting_hook;
window.ting_search = ting_search;
}