(function() {
'use strict';
var xzz = {}
!(function() {
'use strict';
const $toString = Function.toString;
const myFunction_toString_symbol = Symbol('('.concat('', ')_', (Math.random() + '').toString(36)));
const myToString = function toString() {
return typeof this == 'function' && this[myFunction_toString_symbol] || $toString.call(this);
};
function set_native(func,key,value) {
try {
Object.defineProperty(func, key, {
"enumerable": false,
"configurable": true,
"writable": true,
"value": value
})
} catch (e) {
console_log("保护函数出错 => ", e)
debugger
}
};
set_native(Function.prototype,"toString",myToString);
set_native(Function.prototype.toString,myFunction_toString_symbol,"function toString() { [native code] }")
this.functionprotect = (func,func_name,type) => {
set_native(func, myFunction_toString_symbol ,`function ${func_name || ''}() { [native code] }`);
};
}).call(xzz);
console.clear = function () {};
xzz.functionprotect(console.clear,'clear');
document.createElement = function(createElement) {
return function() {
var ret = createElement.apply(this, arguments);
var time = new Date();
console.log('[*] '+(this.__proto__ + '')+'正在创建标签'+arguments[0])
debugger
return ret;
};
}(document.createElement);
xzz.functionprotect(document.createElement,'createElement');
document.getElementsByTagName = function(getElementsByTagName) {
return function () {
var ret = getElementsByTagName.apply(this,arguments);
var time = new Date();
console.log('[*] '+(this.__proto__ + '')+'正在获取标签'+arguments[0]+',标签内html:'+ret.innerHTML)
debugger
return ret
}
}(document.getElementsByTagName);
xzz.functionprotect(document.getElementsByTagName,'getElementsByTagName');
document.getElementById = function(getElementById) {
return function () {
var ret = getElementById.apply(this,arguments);
var time = new Date();
console.log('[*] '+(this.__proto__ + '')+'正在获取标签id'+arguments[0]+',标签内html:'+ret.innerHTML)
debugger
return ret
}
}(document.getElementById);
xzz.functionprotect(document.getElementById,'getElementById');
})();
油猴 Hook createElement、getElementsByTagName、getElementById
于 2023-03-19 17:52:45 首次发布