某音 js 补环境代码块,通配基础环境

window = global

document = {}
document.all = {}  // 全局搜索document.all发现并没有检测,因此这里不补typeof
navigator = {}
navigator.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
document.createElement = function (name) {
    if (name == 'span') {
        return [{}]
    }
}
document.documentElement = '<html></html>'
document.createEvent = function () {
    return 'createEvent() { [native code] }'
}
document.createElement = function () {
    return 'createElement() { [native code] }'
}
window.requestAnimationFrame = function () {
    return 'requestAnimationFrame() { [native code] }'
}
window._sdkGlueVersionMap = {
    "sdkGlueVersion": "1.0.0.51",
    "bdmsVersion": "1.0.1.5",
    "captchaVersion": "4.0.2"
}
XMLHttpRequest = function () {
    return 'XMLHttpRequest() { [native code] }'
}

window.fetch = function () {
    return `(input, init) {
	        var _this6 = this;
	        var url, method;
	        if (IS_REQUEST_API_SUPPORTED && input instanceof Request) {
	          url = input.url;
	          method = input.method…`
}

window.onwheelx = {
    "_Ax": "0X21"
}

navigator.vendorSubs = {
    "ink": 1718453241914
}
window.innerWidth = 1920
window.innerHeight = 1080
window.outerWidth = 1914
window.outerHeight = 1026
window.screenX = 2563
window.screenY = 412
window.pageYOffset = 0
window.pageYOffset = 0
window.screen = {
    availWidth: 1920,
    availHeight: 1032,
    width: 1920,
    height: 1080,
    colorDepth: 24,
    pixelDepth: 24,
    orientation: {
        type: "landscape-primary",
        angle: 0
    },
};
navigator.platform = 'Win32'
document.body = '<body></body>'


// window.requestAnimationFrame = function () {}
// window.XMLHttpRequest = function () {}


//  挂代理补环境
function setProxy(proxyObjs) {
    for (let i = 0; i < proxyObjs.length; i++) {
        const handler = `{
          get: function(target, property, receiver) {
          if (property!="Math" && property!="isNaN"){
             if (target[property] && typeof target[property] !="string" &&  Object.keys(target[property]).length>3){
              }else{
            console.log("方法:", "get  ", "对象:", "${proxyObjs[i]}", "  属性:", property, "  属性类型:", typeof property, ", 属性值:", target[property]);}}
            return target[property];
          },
          set: function(target, property, value, receiver) {
            console.log("方法:", "set  ", "对象:", "${proxyObjs[i]}", "  属性:", property, "  属性类型:", typeof property, ", 属性值:", value, ", 属性值类型:", typeof target[property]);
            return Reflect.set(...arguments);
          }
        }`;
        eval(`try {
            ${proxyObjs[i]};
            ${proxyObjs[i]} = new Proxy(${proxyObjs[i]}, ${handler});
        } catch (e) {
            ${proxyObjs[i]} = {};
            ${proxyObjs[i]} = new Proxy(${proxyObjs[i]}, ${handler});
        }`);
    }
}

setProxy(['window', 'document', ' navigator', 'screen', 'localStorage', 'location'])
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值