更新时间:2023-10-24 12:07:52
来自 背景脚本 您可以收听 chrome.tabs.onUpdated
事件并检查回调上的属性 changeInfo.status
.它可以是加载或完成.如果它完成,请执行操作.
From a background script you can listen to the chrome.tabs.onUpdated
event and check the property changeInfo.status
on the callback. It can be loading or complete. If it is complete, do the action.
示例:
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
// do your things
}
})
因为这可能会在每个选项卡完成时触发,您还可以检查选项卡是否在其 同名属性,像这样:
Because this will probably trigger on every tab completion, you can also check if the tab is active
on its homonymous attribute, like this:
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.active) {
// do your things
}
})