JS_常用HOOK函数


一。。

vscode + node

容易出现TextEncoder未定义。

需要安装下载

npm install text-encoding

然后哪里出错都改成这句

const {TextDecoder, TextEncoder} = require("util");

出错解决

-------------------------------

定义NODE window环境
npm install jsdom

const jsdom
= require("jsdom"); const {JSDOM} = jsdom; const dom = new JSDOM(`

Hello world

`); window = dom.window; document = window.document; XMLHttpRequest = window.XMLHttpRequest;

函数写法HOOk charAt

var hookCharAt = String.prototype.charAt;
String.prototype.charAt = function (index) {
    var res = hookCharAt.call(this, index)
    console.log(this, index)
    return res
}

// hook debugger
Function.prototype.constructor_= Function.prototype.constructor;
Function.prototype.constructor=function(x){
    
    if (x=="debugger"){
        return function(){}
    }
    return Function.prototype.constructor_(x);
};

//hook 定时器
window.setInterval_ = setInterval;
setInterval = function(x,x2){
    if (x2 !=0x7d0){
        return window.setInterval_(x,x2)
    }
    
};

相关