// ==UserScript== // @author GMOogway // @id local-storage-manager@GMOogway // @name Local Storage Manager // @category Controls // @version 0.1.0.20190214 // @description [local-2019-02-14] LocalStorageManager plugin by GMOogway. // @downloadURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/GMOogway/local-storage-manager.user.js // @updateURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/GMOogway/local-storage-manager.meta.js // @namespace https://github.com/GMOogway/iitc-plugins // @include https://intel.ingress.com/* // @match https://intel.ingress.com/* // @grant none // ==/UserScript== function wrapper(plugin_info) { // ensure plugin framework is there, even if iitc is not yet loaded if(typeof window.plugin !== 'function') window.plugin = function() {}; //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! //(leaving them in place might break the 'About IITC' page or break update checks) plugin_info.buildName = 'local'; plugin_info.dateTimeVersion = '20190214'; plugin_info.pluginId = 'LocalStorageManager'; //END PLUGIN AUTHORS NOTE // PLUGIN START //////////////////////////////////////////////////////// // use own namespace for plugin window.plugin.LocalStorageManager = function() {}; window.plugin.LocalStorageManager.IS_DEBUG = false; window.plugin.LocalStorageManager.getDateTime = function() { var date=new Date(); var year=date.getFullYear(); var month=date.getMonth()+1; var day=date.getDate(); var hour="00"+date.getHours(); hour=hour.substr(hour.length-2); var minute="00"+date.getMinutes(); minute=minute.substr(minute.length-2); var second="00"+date.getSeconds(); second=second.substr(second.length-2); var week=date.getDay(); switch(week) { case 1:week="Monday ";break; case 2:week="Tuesday ";break; case 3:week="Wednesday ";break; case 4:week="Thursday ";break; case 5:week="Friday ";break; case 6:week="Saturday ";break; case 0:week="Sunday ";break; default:week="";break; } return (year+"/"+month+"/"+day+"/"+" "+week+" "+hour+":"+minute+":"+second); } window.plugin.LocalStorageManager.debug = function(msg) { if (window.plugin.LocalStorageManager.IS_DEBUG){ console.log(' '); console.log('********** ' + window.plugin.LocalStorageManager.getDateTime() + ' **********'); console.log(msg); console.log('*************************************************************************'); console.log(' '); } } window.plugin.LocalStorageManager.setupContent = function() { plugin.LocalStorageManager.htmlCallSetBox = 'LocalStorageManager Opt'; var actions = ''; actions += 'Add'; actions += 'Delete'; actions += 'View'; actions += 'Import' actions += 'Export'; plugin.LocalStorageManager.htmlSetbox = '
' + actions + '
'; } window.plugin.LocalStorageManager.optAdd = function() { var addKey = prompt('Input the key.', ''); if (addKey == null || addKey == '') { return; } var addValue = prompt('Input the value.', ''); if (addValue == null || addValue == '') { return; } try{ localStorage[addKey] = addValue; window.plugin.LocalStorageManager.optAlert('Add successful.'); }catch(e){ window.plugin.LocalStorageManager.optAlert('Add failed: ' + e + ''); } } window.plugin.LocalStorageManager.optDelete = function() { var deleteKey = prompt('Input the key.', ''); if (deleteKey == null || deleteKey == '') { return; } try{ var data = JSON.stringify(localStorage) var key; for (key in localStorage){ if (deleteKey == key){ delete localStorage[key]; } } window.plugin.LocalStorageManager.optAlert('Delete successful.'); }catch(e){ window.plugin.LocalStorageManager.optAlert('Delete failed: ' + e + ''); } } window.plugin.LocalStorageManager.optImport = function() { var data = prompt('Press CTRL+V to paste it.', ''); if (data == null || data == '') { return; } try{ var key; for (key in localStorage){ delete localStorage[key]; } var json = JSON.parse(data); for(key in json){ localStorage[key] = json[key]; } window.plugin.LocalStorageManager.optAlert('Import successful.'); }catch(e){ window.plugin.LocalStorageManager.optAlert('Import failed: ' + e + ''); } } window.plugin.LocalStorageManager.optExport = function() { try{ var data = JSON.stringify(localStorage); dialog({ html: '

Select all and press CTRL+C to copy it.

', dialogClass: 'ui-dialog-LocalStorageManager-copy', id: 'plugin-LocalStorageManager-export', title: 'LocalStorageManager Export' }); var json = JSON.parse(data); for(var key in json){ window.plugin.LocalStorageManager.debug(key); window.plugin.LocalStorageManager.debug(json[key]); } window.plugin.LocalStorageManager.optAlert('Export successful.'); }catch(e){ window.plugin.LocalStorageManager.optAlert('Export failed: ' + e + ''); } } window.plugin.LocalStorageManager.optView = function() { var html = ''; var json = JSON.parse(JSON.stringify(localStorage)); window.plugin.LocalStorageManager.debug(json); for(var key in json){ html += '' + key + '
' + json[key].substr(0, 40) + '
'; } dialog({ html: html, dialogClass: 'ui-dialog', id: 'plugin-LocalStorageManager-View', title: 'LocalStorageManager View' }); } window.plugin.LocalStorageManager.optAlert = function(message, ms) { $('.ui-dialog .ui-dialog-buttonset').prepend('

' + message + '

'); if (ms === undefined){ $('.alert').delay(2000).fadeOut(); }else{ $('.alert').delay(ms).fadeOut(); } } window.plugin.LocalStorageManager.manualOpt = function() { dialog({ html: plugin.LocalStorageManager.htmlSetbox, dialogClass: 'ui-dialog', id: 'plugin-LocalStorageManager-options', title: 'LocalStorageManager Options' }); } window.plugin.LocalStorageManager.setupCSS = function() { $('