MCPcopy Create free account
hub / github.com/hoothin/UserScripts / loadPrefs

Function loadPrefs

Picviewer CE+/dist.user.js:28655–28696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28653 }
28654
28655 function loadPrefs() {
28656 // 根据 GM_config 的 key 载入设置到 prefs
28657 Object.keys(GM_config.fields).forEach(function(keyStr) {
28658 var keys = keyStr.split('.');
28659 var lastKey = keys.pop();
28660
28661 var lastPref = prefs;
28662 var curKey = keys.shift();
28663 while(curKey){
28664 lastPref = lastPref[curKey];
28665 curKey = keys.shift();
28666 }
28667
28668 var value = GM_config.get(keyStr);
28669 if (typeof value != 'undefined') {
28670 // 特殊的
28671 if (keyStr == 'magnifier.wheelZoom.range' || keyStr == 'imgWindow.zoom.range') {
28672 lastPref[lastKey] = value.split(/[,,]\s*/).map(function(s) { return parseFloat(s)});
28673 } else if(keyStr == 'floatBar.butonOrder') {
28674 lastPref[lastKey] = value.trim().split(/\s*[,,]\s*/);
28675 } else {
28676 lastPref[lastKey] = value;
28677 }
28678 }
28679 });
28680 try {
28681 if (!storage.getItem('inited')) {
28682 _GM_openInTab("https://pv.hoothin.com/first-run", {active:true});
28683 storage.setItem('inited', true);
28684 }
28685 } catch(e) {}
28686 if (typeof prefs.gallery.formatConversion == 'undefined') {
28687 prefs.gallery.formatConversion = "webp>png";
28688 }
28689 prefs.gallery.formatConversion.split("\n").forEach(str => {
28690 let pair = str.split(">");
28691 if (pair.length !== 2) return;
28692 formatDict.set(pair[0].trim(), pair[1].trim());
28693 });
28694
28695 debug = prefs.debug ? console.log.bind(console) : function() {};
28696 }
28697
28698 };
28699

Callers 1

initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected