function Notify(header,content,image){
var note = webkitNotifications.createNotification(image||"",header,content);
note.show();
return note;}
var extensions = ["pbjhaapnigfhipfahcfkeakpcgkmnklc"];
function CheckReload(){
for(var CN=0;CN<extensions.length;CN++){
var id = extensions[CN];
var ex = chrome.management.get(id);
console.log("Checking",ex,"-",id);
if(!ex.enabled){
Notify("Extension reloaded!",ex.name+" was found crashed, and reloaded!");
chrome.management.setEnabled(id,true);
}
}
}
setInterval(CheckReload,1000);
好的,所以我期待的是检查“扩展”数组中的扩展,如果它们没有被启用,它会创建一个通知说它不是,然后启用它。但是, chrome.management.get(id) 似乎返回未定义。
我期望输出如下:检查对象 - [id]
相反,我得到的是: Checking undefined - pbjhaapnigfhipfahcfkeakpcgkmnklc Uncaught TypeError: Cannot read property 'enabled' of undefined
我怎样才能解决这个问题?