0
在chrome.webRequest.onBeforeRequest
我們得到的URL的種種 - 的JavaScript,CSS等獲取文檔的URL中chrome.webRequest.onBeforeRequest
對於每一個網址我想知道主選項卡URL。
什麼是最簡單的方法來同步?
現在,我用這種方式:
如果details.frameId == 0
然後details.url
包含該標籤ID主選項卡URL
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
if (details.tabId == -1)
{
return;
}
if ("type" in details && ['main_frame', 'sub_frame'].indexOf(details.type) !== -1)
{
if (details.frameId == 0) {
all_tabs_info.add_tab_info(details.tabId, details.url);
}
}
},
{
urls: ['<all_urls>']
},
["blocking"]);
所以現在起,如果任何請求到來的這個標籤ID我們已經有了標籤url。這種粗略的邏輯似乎在起作用。