[英]Chrome extension can't modify the dom of a single page
I'm playing around with chrome extensions. 我在玩chrome扩展程序。 I've made a simple extension that deletes all the body content, just for learning purpose.
我做了一个简单的扩展,删除了所有内容,只是为了学习。
Works fine with almost all sites (facebook, yahoo, google) but somehow is not working here https://login.live.com/ 在几乎所有网站(facebook,yahoo,google)上都可以正常工作,但是在某种程度上无法在这里工作https://login.live.com/
This is my code: 这是我的代码:
manifest.json 的manifest.json
{
"name": "test",
"description": "test",
"version": "0.1",
"manifest_version": 2,
"permissions": [
"storage"
],
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["content_script.js"],
"run_at": "document_end"
}]
}
content_script.js content_script.js
document.body.innerHTML = '';
Why the extension is not effective on that page? 为什么该扩展名在该页面上无效? I'm missing something about chrome extensions or Microsoft implements some security measures?
我缺少有关chrome扩展的信息,或者Microsoft实施了一些安全措施?
DOM can be added after your document_end
-timed script executes. 可以在执行
document_end
-timed脚本之后添加DOM。
Quoting Chrome docs: 引用Chrome文档:
In the case of "document_end", the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded.
对于“ document_end”,文件在DOM完成之后但在子资源(例如图像和框架)加载之前立即注入。
So it is possible that your script executes before page's own $(document).ready(...)
or equivalent, that still adds some content. 因此,您的脚本有可能在页面自己的
$(document).ready(...)
或等效$(document).ready(...)
之前执行,这仍然会添加一些内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.