从网页触发/调用Chrome扩展程序 [英] Trigger/invoke a Chrome extension from a web page
问题描述
对于我目前正在处理的项目,我需要知道是否可以调用Chrome扩展程序。
For the project I'm currently working on, I need to know if it is possible to invoke a Chrome extension.
即,点击按钮(或一个链接)在我的页面上会调用Read It扩展,就像那样。
I.e., clicking on a button (or a link) on my page would call the "Read It" extension, something like that.
推荐答案
c $ c> content-script 到每个页面(在扩展清单< a>),然后修改页面html,将您的按钮
或 a
添加到您的自定义ID中。
You can inject your content-script
to every page (register it in extension manifest) and alter the page html to add your button
or a
with your custom id.
执行环境示例可以很好地解释您将如何触发从页面到您的内容脚本的事件。在你管理触发器之后,你可以做任何你想做的扩展逻辑。
The execution environment example explains it pretty good how you will trigger an event from the page to your content script. After you manage the trigger you can do anything you want as the extension logic.
请注意,这需要将您的扩展程序的 content-script
注入到用户访问的每个页面。如果你正在问的是什么,实际上不可能触发你的页面执行 content-script
。
Also keep in mind that this will require your extension's content-script
to be injected to every page the user visits. It is not possible to actually trigger the execution of your content-script
from the page if thats what you were asking.
这篇关于从网页触发/调用Chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!