首页 > 其他分享 >浏览器环境自吐模块

浏览器环境自吐模块

时间:2023-04-03 16:45:27浏览次数:65  
标签:浏览器 target WatchName 自吐 propKey result 模块 return dtavm

https://github.com/daisixuan/r0chrome

使用chromium查看js使用那些环境

dtavm = {}
dtavm.log = console.log
dtavm.proxy = function (obj, objname, type){
    function getMethodHandler(WatchName, target_obj) {
    let methodhandler = {
        apply(target, thisArg, argArray) {
			if (this.target_obj){
				thisArg = this.target_obj
			}
            let result = Reflect.apply(target, thisArg, argArray)
            if (target.name !== "toString"){
                if (target.name === "addEventListener"){
                    dtavm.log(`[${WatchName}] apply function name is [${target.name}], argArray is [${argArray[0]}], result is [${result}].`)
                }else if (WatchName === "window.console"){
                }else {
                    dtavm.log(`[${WatchName}] apply function name is [${target.name}], argArray is [${argArray}], result is [${result}].`)
                }
            }else{
                dtavm.log(`[${WatchName}] apply function name is [${target.name}], argArray is [${argArray}], result is [${result}].`)
            }
			return result
        },
        construct(target, argArray, newTarget) {
            var result = Reflect.construct(target, argArray, newTarget)
            dtavm.log(`[${WatchName}] construct function name is [${target.name}], argArray is [${argArray}], result is [${(result)}].`)
            return result;
        }
    }
	methodhandler.target_obj = target_obj
    return methodhandler
}

    function getObjhandler(WatchName) {
    let handler = {
        get(target, propKey, receiver) {
            let result = target[propKey]
            if (result instanceof Object) {
                if (typeof result === "function") {
                    dtavm.log(`[${WatchName}] getting propKey is [${propKey}] , it is function`)
                    return new Proxy(result,getMethodHandler(WatchName, target))
                }
                else {
                    dtavm.log(`[${WatchName}] getting propKey is [${propKey}], result is [${(result)}]`);
                }
                return new Proxy(result, getObjhandler(`${WatchName}.${propKey}`))
            }
            if(typeof(propKey) !== "symbol"){
                dtavm.log(`[${WatchName}] getting propKey is [${propKey?.description ?? propKey}], result is [${result}]`);
            }
            return result;
        },
        set(target, propKey, value, receiver) {
            if (value instanceof Object) {
                dtavm.log(`[${WatchName}] setting propKey is [${propKey}], value is [${(value)}]`);
            } else {
                dtavm.log(`[${WatchName}] setting propKey is [${propKey}], value is [${value}]`);
            }
            return Reflect.set(target, propKey, value, receiver);
        },
        has(target, propKey) {
            var result = Reflect.has(target, propKey);
            dtavm.log(`[${WatchName}] has propKey [${propKey}], result is [${result}]`)
            return result;
        },
        deleteProperty(target, propKey) {
            var result = Reflect.deleteProperty(target, propKey);
            dtavm.log(`[${WatchName}] delete propKey [${propKey}], result is [${result}]`)
            return result;
        },
        defineProperty(target, propKey, attributes) {
            var result = Reflect.defineProperty(target, propKey, attributes);
            dtavm.log(`[${WatchName}] defineProperty propKey [${propKey}] attributes is [${(attributes)}], result is [${result}]`)
            return result
        },
        getPrototypeOf(target) {
            var result = Reflect.getPrototypeOf(target)
            dtavm.log(`[${WatchName}] getPrototypeOf result is [${(result)}]`)
            return result;
        },
        setPrototypeOf(target, proto) {
            dtavm.log(`[${WatchName}] setPrototypeOf proto is [${(proto)}]`)
            return Reflect.setPrototypeOf(target, proto);
        },
        preventExtensions(target) {
            dtavm.log(`[${WatchName}] preventExtensions`)
            return Reflect.preventExtensions(target);
        },
        isExtensible(target) {
            var result = Reflect.isExtensible(target)
            dtavm.log(`[${WatchName}] isExtensible, result is [${result}]`)
            return result;
        },
    }
    return handler;
}

    if (type === "method"){
        return new Proxy(obj, getMethodHandler(objname, obj));
    }
    return new Proxy(obj, getObjhandler(objname));
}

Object.defineProperties(globalThis, {
    'window': {
        configurable: false,
        enumerable: true,
        get: function get() {
            return dtavm.proxy(window_dta, "window")
        },
        set: undefined
    },
    'navigator': {
        configurable: true,
        enumerable: true,
        get: function get() {
            return dtavm.proxy(navigator_dta, "navigator")
        },
        set: undefined
    },
	'document': {
        configurable: false,
        enumerable: true,
        get: function get() {
            return dtavm.proxy(document_dta, "document")
        },
        set: undefined
    },
	'history': {
        configurable: true,
        enumerable: true,
        get: function get() {
            return dtavm.proxy(history_dta, "history")
        },
        set: undefined
    },
})
screen = dtavm.proxy(screen_dta, "screen")

下断点执行

成功监控对象

 

标签:浏览器,target,WatchName,自吐,propKey,result,模块,return,dtavm
From: https://www.cnblogs.com/yoyo1216/p/17283501.html

相关文章

  • 【Struts框架】第一节Action-模块包含和defaultAction
    1.模块包含:struts.xml:里面可以这么写<includefile="login.xml"></include>说明在struts.xml包含了一个login.xml文件login.xml:<?xmlversion="1.0"encoding="GBK"?><!DOCTYPEstrutsPUBLIC"-//apacheSoftwareFound......
  • Python 自动化指南(繁琐工作自动化)第二版:附录 A:安装第三方模块
    原文:https://automateboringuff.com/2e/appendix/出版后添加:你可以通过安装带有PIP的automateboringstuff模块来安装所有需要的模块(带有本书中使用的版本)。从命令提示符或终端窗口运行pipinstall--userautomateboringstuff。许多开发人员编写了他们自己的模块,将Pytho......
  • ansible 常用模块 copy
    模块说明该copy模块将文件从本地或远程机器复制到远程机器上的某个位置。参数说明ParameterCommentsattributes aliases:attrstringaddedinAnsible2.3生成的文件系统对象应具有的属性。要获得支持的标志,请查看目标系统上chattr的手册页......
  • chrome模拟微信浏览器内核
     1、ios-QQ——内置浏览器UAMozilla/5.0(iPhone;CPUiPhoneOS7_1_2likeMacOSX)>AppleWebKit/537.51.2(KHTML,likeGecko)Mobile/11D257>QQ/5.2.1.302NetType/WIFIMem/282、ios-微信——微信内置浏览器UAMozilla/5.0(iPhone;CPUiPhoneOS7_1_2......
  • 升级360浏览器到最新版本,收藏夹里数据不见了解决办法
    360为就旧版本,有时候会有些js的问题,今天将浏览器升级到最新版本,突然发现收藏夹里的链接都没有了。在360里的帮助与反馈,常见问题里,找到了这个解决办法,记录下我的解决过程。我这边点击收藏,备份/还原,从历史版本中恢复,里面有近几年的版本,找到前几天正常时候的,点击恢复即可。......
  • 【论文速递】MMM2020 - 电子科技大学提出一种新颖的局部变换模块提升小样本分割泛化性
    【论文速递】MMM2020-电子科技大学提出一种新颖的局部变换模块提升小样本分割泛化性能【论文原文】:ANewLocalTransformationModuleforFew-shotSegmentation【作者信息】:YuweiYang,FanmanMeng,HongliangLi,QingboWu,XiaolongXuandShuaiChen获取地址:https://arxi......
  • 默认python3版本,python2没有pip2模块,解决方案
    python2.7没有pip模块,需要安装pip2/usr/bin/python2:Nomodulenamedpip 直接通过pip安装出错,python3.6已经导入了 解决方案:下载pip安装文件: curlhttps://bootstrap.pypa.io/pip/2.7/get-pip.py -oget-pip.py用python2安装: python2get-pip.py   ......
  • Python导入的OpenCV模块的cv2不会提示,如何解决?
     1.找到opencv安装路径:python目录\Lib\site-packages\cv2  2.复制cv2.pyd一份到它的上级目录在这个目录下,将文件cv2.pyd,复制一份到它的上级目录:*\Lib\site-packages  3.重新启动pycharm4.测试验证,OK!              参考资料:h......
  • nginx 热加载stream模块
    报错:nginx:[emerg]unknowndirective"stream"in/usr/local/nginx/conf.d/ssh.conf判断模块是否存在 进入二进制部署包解压后目录 添加模块,与之前加载的模块一致,并新添加 --with-stream模块./configure--prefix=/usr/local/nginx--user=nginx--group=nginx......
  • BOSHIDA 电源模块使用时注意事项 ACDC DCDC
    电源模块需轻拿轻放,避免撞击或跌落造成产品损坏;禁止拆开产品外壳,禁止触摸电源内部任何器件,以避免产品遭受静电、器件应力等易损坏的情况;电源模块通电后,不要靠近模块或触摸外壳,避免模块异常工作时可能对身体造成伤害;在产品通电之前,请确认并严格按照产品技术手册,正确连接产品的输......