Gerald 12 rokov pred
rodič
commit
537427a9e7
5 zmenil súbory, kde vykonal 12 pridanie a 12 odobranie
  1. 4 2
      background.js
  2. 1 1
      manifest.json
  3. 1 1
      options.html
  4. 6 7
      options.js
  5. 0 1
      style.css

+ 4 - 2
background.js

@@ -378,8 +378,10 @@ function getOption(k,src,callback){
 	return true;
 }
 function setOption(o,src,callback){
-	localStorage.setItem(o.key,JSON.stringify(o.value));
-	settings[o.key]=o.value;
+	if(!o.check||(o.key in settings)) {
+		localStorage.setItem(o.key,JSON.stringify(o.value));
+		settings[o.key]=o.value;
+	}
 	if(callback) callback(o.value);
 }
 function initSettings(){

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 	"name": "Violent monkey",
-	"version" : "2.0.0.4",
+	"version" : "2.0.0.5",
 	"manifest_version" : 2,
 	"description" : "__MSG_extDescription__",
 	"developer": {"name" : "Gerald", "url" : "http://gera2ld.blog.163.com"},

+ 1 - 1
options.html

@@ -122,7 +122,7 @@
 			<fieldset>
 				<legend class=i18n>labelData</legend>
 				<button id=aExport class=i18n>buttonExportData</button>
-				<button id=aImport class=i18n>buttonImportData</button>
+				<button id=aImport class=i18n>buttonImportData</button><input type=file class=hide id=iImport>
 				<button id=aVacuum class=i18n>buttonVacuumData</button>
 			</fieldset>
 			<div class=right><button id=aClose class=i18n>buttonClose</button></div>

+ 6 - 7
options.js

@@ -153,13 +153,13 @@ function confirmCancel(dirty){
 initCSS();initI18n(function(){switchTo(N);});
 
 // Advanced
-var A=$('advanced');
+var A=$('advanced'),H=$('iImport');
 $('bAdvanced').onclick=function(){showDialog(A);};
 $('cUpdate').onchange=function(){chrome.runtime.sendMessage({cmd:'AutoUpdate',data:this.checked});};
 $('bDefSearch').onclick=function(){$('tSearch').value=_('defaultSearch');};
 $('tSearch').title=_('hintSearchLink');
 $('aExport').onclick=function(){showDialog(X);xLoad();};
-function importFile(e){
+H.onchange=function(e){
 	zip.createReader(new zip.BlobReader(e.target.files[0]),function(r){
 		r.getEntries(function(e){
 			function getFiles(){
@@ -187,17 +187,16 @@ function importFile(e){
 					console.log('Error parsing ViolentMonkey configuration.');
 				}
 				if(vm.values) for(z in vm.values) chrome.runtime.sendMessage({cmd:'SetValue',data:{uri:z,values:vm.values[z]}});
-				if(vm.settings) for(z in vm.settings) chrome.runtime.sendMessage({cmd:'SetOption',data:{key:z,value:vm.settings[z]}});
+				if(vm.settings) for(z in vm.settings) chrome.runtime.sendMessage({cmd:'SetOption',data:{key:z,value:vm.settings[z],check:true}});
 				getFiles();
 			}); else getFiles();
 		});
 	},function(e){console.log(e);});
-}
+};
 $('aImport').onclick=function(){
-	var e=document.createEvent('MouseEvent'),iH=document.createElement('input');
-	iH.setAttribute('type','file');iH.onchange=importFile;
+	var e=document.createEvent('MouseEvent');
 	e.initMouseEvent('click',true,true,window,0,0,0,0,0,false,false,false,false,0,null);
-	iH.dispatchEvent(e);
+	H.dispatchEvent(e);
 };
 $('aVacuum').onclick=function(){
 	this.disabled=true;

+ 0 - 1
style.css

@@ -51,7 +51,6 @@ fieldset{border-radius:5px;}
 #overlay{background:#000;position:fixed;top:0;bottom:0;left:0;right:0;transition:all .5s linear;opacity:0;}
 #overlay.overlay{opacity:0.6;}
 #advanced{padding:20px;}
-#advanced fieldset>*:not(legend){display:inline-block;}
 #advanced legend{margin:0;}
 .list{background:white;overflow-x:hidden;overflow-y:auto;}
 .list>div{display:block;padding:2px 10px;cursor:pointer;border-bottom:1px dashed lightgray;}