简体   繁体   English

如何不制作 chrome 扩展 onclick

[英]How to not make a chrome extension onclick

Ok So I converted a bookmarklet to a chrome extension and, basically what happened was that I had to click the chrome extension icon to activate the bookmarklet.好的,所以我将小书签转换为 chrome 扩展程序,基本上发生的事情是我必须单击 chrome 扩展程序图标才能激活小书签。 So my bookmarklet shows an alert whenever a website with the word 'unblocked" and that won't work, because I don't want it to be on click.因此,只要网站上有“解锁”一词,我的小书签就会显示一个警报,这将不起作用,因为我不希望它被点击。

chrome.browserAction.onClick.addListener(function(tab) {
chrome.tabs.executeScript(tab.id, {file: "bookmarklet.js"})

}); });

ok so how would i make the chrome extension just run in the background without clicking the icon好的,那么我如何让 chrome 扩展在后台运行而不点击图标

Your question is ambiguous.你的问题是模棱两可的。 From what I understood, you might want a content script which can read/modify the content shown by a page.据我了解,您可能需要一个内容脚本来读取/修改页面显示的内容。 You can use the matches property to specify URLs on which the content script will run.您可以使用matches属性指定运行内容脚本的 URL。

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

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