Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作 Chrome 扩展程序。
我需要在 [内容脚本 ---> 注入代码] 或 [背景 ---> 注入代码] 之间进行通信。
注入代码是通过这种方法注入的代码。
这个答案说
注入脚本的行为就像它们被页面本身包含一样,并且没有以任何方式连接到扩展
它是否正确?有没有单一的方法可以做到这一点?
您可以使用 chrome.extension.sendMessage 和它的侦听器从内容脚本\注入脚本与后台页面和 chrome.tabs.sendMessage 与其侦听器进行通信,以从后台页面与内容脚本\注入脚本进行通信
我在<a>带有背景图像的标签上使用了特殊的链接效果:CSS。链接看起来不错,但该网站还包含很多<img>链接,这些链接也获得了 CSS。
<a>
<img>
我目前正在用 jQuery 解决这个问题:$("img").parent().css("background", "
$("img").parent().css("background", "