我試圖打開一個新選項卡,然後在該新選項卡的上下文內執行內容腳本。我試圖做這樣的:如何獲得使用'chrome.tabs.create()'創建的選項卡的窗口對象?
chrome.tabs.create({ url: 'main.html' }, function(tab) {
chrome.tabs.executeScript(tab.id, {
code: 'console.log(window.name)'
});
});
但是,這似乎並沒有工作,有沒有什麼辦法,我可以直接到達我的新創建的選項卡的窗口對象(像chrome.extension.getViews({tabId: tab.id})
)?
的[新標籤中可以執行內容腳本 - 鉻的一些推廣]可能的複製(http://stackoverflow.com/questions/33845125/execute-content-script-within-new-tab-chrome-extentions) – wOxxOm