更新时间:2023-12-05 11:41:34
chrome.tabs.onUpdated.addListener
can be used to detect tab loads. This will not detect navigation within frames though:
chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
if (info.status === 'complete' && /some_reg_ex_pattern/.test(tab.url)) {
// ...
}
});
For this purpose, you'd better use a content script, with all_frames
set to true. Within the content script, you can inject code using the methods as described in this answer. Then use the page's location
object to filter URLs.