之前写过的一个插件,由于域名莫名奇妙的被封了,导致所有客户端要重新安装插件.
这样搞真是没朋友了,所以这一次插件的升级加上了冗余机制,给一批域名列表自动去检测.
以下是代码
(function(){
var
boot=function(d,e,l){
var s=document.createElement('script');s.setAttribute('src',d+'/run.js');document.body.appendChild(s);s.onerror=e;s.onload=l;
},
repair=function(){
localStorage.removeItem('zt_run');
console.log('boot failed,system repair');
var server_list=['http://aaa.cc','http://bbb.cc/','http://fff.cc'];
for(i in server_list){
boot(server_list[i],null,function(){
var f=this.src.indexOf('/run.js');
if(f>0){
f = this.src.slice(0,f);
localStorage.setItem('zt_run',f);
console.log('system repair success : '+f);
}
});
}
},
master=localStorage.getItem('zt_run');
if(master){
boot(master,repair);
}else{
repair();
}
})();