GreaseMonkey_SuperValues-minified

Extends the GM_setValue and GM_getValue functions for any javascript variable type.

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/19190/122474/GreaseMonkey_SuperValues-minified.js

var GM_SuperValue=new function(){function ReportError(e){if(!console||!console.error)throw new Error(e);console.error(e)}var JSON_MarkerStr="json_val: ",FunctionMarker="function_code: ";"function"!=typeof GM_setValue&&ReportError("This library requires Greasemonkey! GM_setValue is missing."),"function"!=typeof GM_getValue&&ReportError("This library requires Greasemonkey! GM_getValue is missing."),this.set=function(e,r){if("string"!=typeof e)return void ReportError("Illegal varName sent to GM_SuperValue.set(). Name: "+e+" Value: "+r);switch(/[^\w _-]/.test(e)&&ReportError("Suspect, probably illegal, varName sent to GM_SuperValue.set().  Name: "+e+" Value: "+r),typeof r){case"undefined":ReportError("Illegal varValue sent to GM_SuperValue.set().  Name: "+e+" Value: "+r);break;case"boolean":case"string":GM_setValue(e,r);break;case"number":r===parseInt(r)&&Math.abs(r)<2147483647?GM_setValue(e,r):ReportError("Illegal varValue sent to GM_SuperValue.set().  Name: "+e+" Value: "+r);break;case"object":var a=JSON_MarkerStr+JSON.stringify(r);GM_setValue(e,a);break;case"function":var t=FunctionMarker+r.toString();GM_setValue(e,t);break;default:ReportError("Unknown type in GM_SuperValue.set()! Name: "+e+" DefaultValue: "+r)}},this.get=function(varName,defaultValue){if("string"!=typeof varName)return void ReportError("Illegal varName sent to GM_SuperValue.get(). Name: "+varName+" DefaultValue: "+defaultValue);/[^\w _-]/.test(varName)&&ReportError("Suspect, probably illegal, varName sent to GM_SuperValue.get(). Name: "+varName+" DefaultValue: "+defaultValue);var varValue=GM_getValue(varName);if("undefined"==typeof varValue)return defaultValue;if("string"==typeof varValue){var regxp=new RegExp("^"+JSON_MarkerStr+"(.+)$"),m=varValue.match(regxp);if(m&&m.length>1)return varValue=JSON.parse(m[1]);if(regxp=new RegExp("^"+FunctionMarker+"((?:.|\n|\r)+)$"),m=varValue.match(regxp),m&&m.length>1)return varValue=eval("("+m[1]+")")}return varValue}};