就目前情况而言,Google Chrome 扩展程序可以在加载页面时触发页面上的内容脚本。
有没有办法在页面加载之前将脚本注入(inject)到页面中?它类似于内容脚本,只不过它在请求页面时触发,而不是等待页面加载。
最佳答案
您检查过内容脚本的 run_at
属性吗?
Optional. Controls when the files in js are injected. Can be "document_start", "document_end", or "document_idle". Defaults to "document_idle".
In the case of "document_start", the files are injected after any files from css, but before any other DOM is constructed or any other script is run. [...]
来源:http://developer.chrome.com/extensions/content_scripts.html
关于javascript - 内容脚本的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16825732/