简体   繁体   English

Chrome扩展程序-自动运行

[英]Chrome Extension - Autorun

I am wondering if it is possible to automatically run my extension (or a function in my extension) each time a page loads? 我想知道是否可以在每次页面加载时自动运行扩展程序(或扩展程序中的功能)? Right now, I have it set that you would click the icon Browser Action icon to run my extension. 现在,我已设置好您可以单击图标“浏览器操作”图标来运行我的扩展程序。

You've got two options: 您有两种选择:

  1. Inject code as a Content scripts , using the matching rules as defined in the manifest file . 使用清单文件中定义的匹配规则,将代码作为Content脚本注入。
  2. A background page , using the chrome.tabs.onUpdated event. 使用chrome.tabs.onUpdated事件的背景页面 Use the chrome.tabs.executeScript method to inject script. 使用chrome.tabs.executeScript方法来注入脚本。

See also: 也可以看看:

  1. Building a Chrome extension 构建一个Chrome扩展程序
  2. Inject chrome browser extension content script based on URL 根据网址注入Chrome浏览器扩展程序内容脚本

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

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