@
TomXx 目前是监听**OnUpdatedChangeInfoType**事件,也就是新开 tab 的事件内容,文档在这里
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated> When the user navigates to a new URL in a tab, this typically generates several onUpdated events as various properties of the [tabs.Tab](
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/Tab) object are updated. This includes the url, but also potentially the title and favIconUrl properties. The status property will cycle through "loading" and "complete".
解决方法:插件开启,或者暂停时间到了以后,有个**setTimoutOut**方法,来 iterate 所有的 tab ,检测 url 匹配后关闭。
```js
var tabs = await chrome.tabs.query({});
tabs.forEach(function (tab) {
// do whatever you want with the tab
});
```
我个人认为这个需求比较小众吧,没必要监听当前页面,暂停(放松)过后,关闭抖音就行,开始工作,自动关闭不是太友好,万一再看关键内容呢,也意义不大。以后有相似需求我会加上。