[英]Is there a way to run a content script after the page is loaded but before scripts are executed?
I'm writing a browser extension to intercept all the script tags on the page when it's loaded, but before they execute.我正在编写一个浏览器扩展来在页面加载时拦截页面上的所有脚本标签,但在它们执行之前。 To be clear, I'm not looking to block the scripts entirely;
需要明确的是,我并不想完全阻止脚本。 I just want to intercept and analyze/modify them before they're run.
我只想在它们运行之前拦截和分析/修改它们。
Is there a way to do this?有没有办法做到这一点?
I'm aware of onbeforescriptexecute
for Firefox and its polyfill for Chrome, but I'm hoping for something more "official" and cross-browser...我知道 Firefox 的
onbeforescriptexecute
及其适用于 Chrome 的 polyfill,但我希望有更多“官方”和跨浏览器的东西......
As answered by CertainPerformance in the comments, you can use a MutationObserver to observe changes to the DOM as shown here: https://stackoverflow.com/a/59518023正如CertainPerformance在评论中回答的那样,您可以使用 MutationObserver 来观察 DOM 的变化,如下所示: https://stackoverflow.com/a/59518023
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.