简体   繁体   English

Chrome扩展程序的内容脚本未注入特定网站

[英]Chrome extension's content script not getting injected on specific websites

I have developed a basic chrome extension that appends some DOM elements to the website's HTML body. 我已经开发了一个基本的chrome扩展程序,该扩展程序将一些DOM元素附加到网站的HTML正文中。 I'm using content scripts to achieve this. 我正在使用内容脚本来实现这一目标。 It is working fine on most websites, but on few (especially on net-banking websites), content script is not getting executed. 它在大多数网站上都能正常工作,但是在少数网站上(尤其是在网上银行网站上),内容脚本无法执行。

My question is, can a website block content script to inject any code into its webpage (as part of security measure or something)? 我的问题是,网站能否阻止内容脚本以将任何代码注入其网页(作为安全措施的一部分)? If so, is there any other alternative? 如果是这样,还有其他选择吗? I tried using background script that programmatically executes content scripts, but background script is not getting executed each time a load a new page. 我尝试使用后台脚本以编程方式执行内容脚本,但是每次加载新页面时都不会执行后台脚本。

Please make sure if these websites contain iframe. 请确保这些网站是否包含iframe。 If so, you need to add the following in your manifest.json. 如果是这样,则需要在manifest.json中添加以下内容。

"all_frames": true

Update your manifest.json with below permission 使用以下权限更新您的manifest.json

 "content_scripts": [{
                            "matches"       :   ["https://specificURL/*","https://*/*","http://*/*"],
                             "all_frames"   :   true
                        }]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM