我正在构建一个检索最后一个关闭标签的扩展程序。但是,当我在MAC上运行它时,chrome会隐藏自己(崩溃),但是当我从Dock重新打开chrome时,最后一个url确实在新选项卡中打开了。
希望得到你的帮助,谢谢!
加载浏览时,会出现以下错误:
Uncaught TypeError: Cannot read property 'onUpdated' of undefined on background.js line 10
`这是background.js:
var tabToUrl = {};
var count = 0;
var urlRemoved = {};
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
tabToUrl[tabId] = tab.url;
});
chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
urlRemoved[count] = tabToUrl[tabId];
count++;
delete tabToUrl[tabId];
});
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if(msg.method == "openLast"){
while(count > 0){
count--;
chrome.tabs.create({'url': urlRemoved[count]}, function(tab){});
}
}
//alert("Removed Site Reloaded");
});`