我正在尝试修改网站的JavaScript功能:
function example(pExample){
...
}
到:
function example(pExample){
...
console.log(pExample)
}
我已经尝试在加载Chrome开发者工具的“源代码”选项卡中更改上述功能,但是更改似乎无效。我已经考虑过使用某种扩展名用自己的脚本替换脚本的源代码,但是该脚本会在每次重新加载页面时更改其名称,因此我认为这是不可能的。有什么想法吗?
function example(x) {
console.log("-->calling the original function");
return x + 1;
}
///////
// 1. take the reference
let originalReference = example;
// 2. make the function
function custom() {
console.log("->custom function called");
// 3. call the original one
let originalResult = originalReference.apply(this, arguments);
console.log("->original was called with:", arguments, "\nand produced:", originalResult);
return originalResult;
}
// 4. replace the original
example = custom;
console.log(example(4));