// GM_config // version 1.2.5 // copyright JoeSimmons & SizzleMcTwizzle & IzzySoft var GM_config = { storage: 'GM_config', // This needs to be changed to something unique for localStorage init: function() { for(var i=0,l=arguments.length,arg; i0) for(var i=radios.length-1; i>=0; i--) { if(radios[i].checked) this.values[f] = radios[i].value; } break; } } if(this.onSave) this.onSave(); // Call the save() callback function this.save(); } if(this.frame) this.remove(this.frame); delete this.frame; if(this.onClose) this.onClose(); // Call the close() callback function }, set: function(name,val) { this.values[name] = val; }, get: function(name) { return this.values[name]; }, isGM: typeof GM_getValue != 'undefined' && typeof GM_getValue('a', 'b') != 'undefined', log: (this.isGM) ? GM_log : ((window.opera) ? opera.postError : console.log), save: function(store, obj) { try { var val = (typeof JSON == 'object' ? JSON.stringify : uneval)((obj||this.values)); (this.isGM?GM_setValue:(function(name,value){return localStorage.setItem(name,value)}))((store||this.storage),val); } catch(e) { this.log("GM_config failed to save settings!"); } }, read: function(store) { try { var val = (this.isGM?GM_getValue:(function(name,def){return localStorage.getItem(name)||def}))((store||this.storage), '{}'), rval; if (typeof JSON == 'object') try { rval = JSON.parse(val); } catch(e) { rval = eval(val); } else rval = eval('(' + val + ')'); } catch(e) { this.log("GM_config failed to read saved settings!"); rval = {}; } return rval; }, reset: function(e) { e.preventDefault(); var type, obj = GM_config, fields = obj.settings; for(f in fields) { var field = obj.frame.contentDocument.getElementById('field_'+f); if(field.type=='radio'||field.type=='text'||field.type=='checkbox') type=field.type; else type=field.tagName.toLowerCase(); switch(type) { case 'text': field.value = obj.settings[f]['default'] || ''; break; case 'hidden': field.value = obj.settings[f]['default'] || ''; break; case 'textarea': field.value = obj.settings[f]['default'] || ''; break; case 'checkbox': field.checked = obj.settings[f]['default'] || false; break; case 'select': if(obj.settings[f]['default']) { for(var i=field.options.length-1; i>=0; i--) if(field.options[i].value==obj.settings[f]['default']) field.selectedIndex=i; } else field.selectedIndex=0; break; case 'div': var radios = field.getElementsByTagName('input'); if(radios.length>0) for(var i=radios.length-1; i>=0; i--) { if(radios[i].value==obj.settings[f]['default']) radios[i].checked=true; } break; } } }, values: {}, settings: {}, css: { basic: 'body {background:#FFFFFF;}\n' + '.indent40 {margin-left:40%;}\n' + '* {font-family: arial, tahoma, sans-serif, myriad pro;}\n' + '.field_label {font-weight:bold; font-size:12px; margin-right:6px;}\n' + '.block {display:block;}\n' + '.saveclose_buttons {\n' + 'margin:16px 10px 10px 10px;\n' + 'padding:2px 12px 2px 12px;\n' + '}\n' + '.reset, #buttons_holder, .reset a {text-align:right; color:#000000;}\n' + '.config_header {font-size:20pt; margin:0;}\n' + '.config_desc, .section_desc, .reset {font-size:9pt;}\n' + '.center {text-align:center;}\n' + '.section_header_holder {margin-top:8px;}\n' + '.config_var {margin:0 0 4px 0;}\n' + '.section_header {font-size:13pt; background:#414141; color:#FFFFFF; border:1px solid #000000; margin:0;}\n' + '.section_desc {font-size:9pt; background:#EFEFEF; color:#575757; border:1px solid #CCCCCC; margin:0 0 6px 0;}\n' + 'input[type="radio"] {margin-right:8px;}', stylish: ''}, create: function(a,b) { var ret=window.document.createElement(a); if(b) for(var prop in b) { if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false); else if(prop=="kids" && (prop=b[prop])) for(var i=0; i