拦截DOM和JS引擎调用

发布于 2024-09-26 18:40:12 字数 120 浏览 1 评论 0原文

我想在浏览器加载时拦截 JS 触发的 DOM 对象读写查询。拦截这些电话后,我希望对其进行筛选。我已经编写了筛选逻辑,但无法阻止呼叫。

除了修改浏览器源代码之外还有什么方法可以实现这一点吗?如果是这样请帮助我。

I want to intercept DOM object read and write queries fired by JS while getting loaded by the browser. After intercepting these calls, i wish to screen them. I have written the logic for screening but am not able to block the calls.

Is there any way other than modifying source code of the browser to achieve this? If so pls help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2024-10-03 18:40:12

你的意思是这样吗?
(由于某些原因Fx失败并进行非法操作)

<script>
var oldGet = document.getElementById;
document.getElementById=function(id) {
  return confirm('Someone wants to know about '+id+', is that ok?')?oldGet(id):null;
}
window.onload=function() {
  alert(document.getElementById('div1').innerHTML);
}

</script>
<div id="div1">Hello</div>

You mean like this?
(for some reason fails in Fx with illegal operation)

<script>
var oldGet = document.getElementById;
document.getElementById=function(id) {
  return confirm('Someone wants to know about '+id+', is that ok?')?oldGet(id):null;
}
window.onload=function() {
  alert(document.getElementById('div1').innerHTML);
}

</script>
<div id="div1">Hello</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文