Skip to content

Commit 04d1076

Browse files
committed
eval-hook插件完善日志打印
1 parent 5181f23 commit 04d1076

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/global-assign-hook-component/plugins/eval-hook-plugins.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
(() => {
22

3+
// 是否要在在控制台上打印eval hook日志提醒
4+
const enableEvalHookLog = true;
5+
36
// 用eval执行的代码也要能够注入,我擦开个接口吧...
47
const evalHolder = window.eval;
58
window.eval = function (jsCode) {
6-
console.log("检测到eval执行代码: " + jsCode);
9+
10+
if (enableEvalHookLog) {
11+
const isNeedNewLine = jsCode && jsCode.length > 100;
12+
console.log("AST HOOK工具检测到eval执行代码: " + (isNeedNewLine ? "\n" : "") + jsCode);
13+
}
14+
715
let newJsCode = jsCode;
816
const xhr = new XMLHttpRequest();
917
xhr.addEventListener("load", () => {

0 commit comments

Comments
 (0)