Storage Viewer

Check the use of new kind of cookies: sessionStorage, localStorage, globalStorage and databaseStorage.

  1. // <![CDATA[
  2. // ==UserScript==
  3. // @name Storage Viewer
  4. // @fullname Storage Viewer
  5. // @author GIJoe
  6. // @version 0.13b
  7. // @licence http://creativecommons.org/licenses/by-nc-sa/3.0/
  8. // @license (CC) by-nc-sa
  9. // @namespace http://userscripts.org/scripts/show/62673
  10. // @description Check the use of new kind of cookies: sessionStorage, localStorage, globalStorage and databaseStorage.
  11. // @include http://*
  12. // @include https://*
  13. // @unwrap
  14. // ==/UserScript==
  15.  
  16. ( function() {
  17.  
  18. //============================= User Config ===============================================
  19. const DIV_OPACITY = 0.90; // between 0 and 1
  20. const DEFAULT_POS = 2; // 1=top-left / 2=top-right / 3=bottom-left / 4=bottom-right
  21. const RESET_KEYCODE = 19; // 19=VK_PAUSE
  22. const SHOW_AT_START = 1; // 0=no / 1=if storage used / 2=if storage available / 3=yes
  23. const SHOW_AT_CHANGE = 1; // 0=no / 1=yes
  24.  
  25. const COLOR_TITLE = '#AAAAFF';
  26. const COLOR_TITLE_TEXT = '#666666';
  27. const COLOR_UNAVAILABLE = '#FF8888';
  28. const COLOR_PROTECTED = '#FFAA44';
  29. const COLOR_NOT_USED = '#88CCCC';
  30. const COLOR_USED = '#44FF44';
  31. const COLOR_INFO_TEXT = '#000000';
  32. const COLOR_CLOSE = '#CCCCDD';
  33. const COLOR_CLOSE_TEXT = '#000000';
  34. const COLOR_BG_SESSION = '#444400';
  35. const COLOR_BG_LOCAL = '#220066';
  36. const COLOR_BG_GLOBAL = '#225522';
  37.  
  38. //=========================================================================================
  39. //=========================================================================================
  40. //=========================================================================================
  41. const FONT_COURIER_NEW = '"Courier New", Courier, monospace';
  42. const FONT_ARIAL = 'Arial, Tahoma, Helvetica, sans-serif';
  43. const DIV_HEIGHT = 18;
  44. const DIV_ZINDEX = 999999999;
  45. const KEY_DIV_WIDTH = 250;
  46.  
  47. //=============================== Compatibility Routines ==================================
  48. var gvar=function() {}; if(typeof(unsafeWindow)=='undefined') { unsafeWindow=window; }
  49. if(typeof(GM_log)=='undefined') { GM_log=function(msg) { if((typeof(unsafeWindow.console)!='undefined') && (typeof(unsafeWindow.console.log)!='undefined')) { unsafeWindow.console.log(msg); } }; }
  50. if(window.navigator.appName.match(/^opera/i) && typeof(window.opera)!='undefined') { gvar.isOpera=true; GM_log=window.opera.postError; } else { gvar.isOpera=false; }
  51.  
  52. //=============================== Useful Routines =========================================
  53. // void show_alert(message :string[,display :int] ) => Log and display a message
  54. // display: 0=console only / 1=top of document / 2=bottom of document
  55. function show_alert(msg, display) {
  56. if(arguments.callee.counter>=0) { arguments.callee.counter++; } else { arguments.callee.counter=0; }
  57. GM_log('['+arguments.callee.counter+'] '+msg);
  58. if(display==1 || display==2) {
  59. warningelem=document.createElement('div');
  60. warningelem.setAttribute("style","color:#FFFFFF; background:#FF8000; width:auto; text-align:center; font-size:24px; border: 3px solid #CC0088; margin:2px; background:#FF8800; color:#000000;");
  61. warningelem.textContent=msg;
  62. if(display==1) { document.body.insertBefore(warningelem, document.body.firstChild); }
  63. else { document.body.appendChild(warningelem); }
  64. }
  65. }
  66.  
  67. function isDefined(x) { return !(x == null && x !== null); }
  68. function isUndefined(x) { return x == null && x !== null; }
  69. function removeElement(el) { el.parentNode.removeChild(el); }
  70. function replaceElement(el,nel) { var elp=el.parentNode; var eln=el.nextSibling; elp.removeChild(el); elp.insertBefore(nel,eln); }
  71. function user_select(element,value) {
  72. var els = element.style;
  73. if(!els) { return; }
  74. if(isDefined(els.userSelect)) {els.userSelect=value;} // CSS3
  75. else if (isDefined(els.MozUserSelect)) {els.MozUserSelect=value;} // Mozilla
  76. else if (isDefined(els.webkitUserSelect)) {els.webkitUserSelect=value;} // WebKit
  77. else if (isDefined(els.OUserSelect)) {els.OUserSelect=value;} // Opera
  78. }
  79. function getKeyCode(event) {
  80. var key=event.keyCode;
  81. if(gvar.isOpera) { if(key>96 && key<123) { key=key-32; } } // key.toUpperCase();
  82. if(event.ctrlKey) { key=key+1000; }
  83. if(event.shiftKey) { key=key+2000; }
  84. if(event.altKey) { key=key+4000; }
  85. if(event.metaKey) { key=key+8000; }
  86. return key;
  87. }
  88.  
  89. //============================== Storage routines ========================================
  90. function sessionStorageType() {
  91. var res=''; try { res=typeof(unsafeWindow.sessionStorage) } catch(e) { res='Error'; } // Catch Security error
  92. return res;
  93. }
  94. function localStorageType() {
  95. var res=''; try { res=typeof(unsafeWindow.localStorage) } catch(e) { res='Error'; } // Catch Security error
  96. return res;
  97. }
  98. function globalStorageType() {
  99. var res=''; try { res=typeof(unsafeWindow.globalStorage) } catch(e) { res='Error'; } // Catch Security error
  100. return res;
  101. }
  102. function databaseStorageType() {
  103. var res=''; try { res=typeof(unsafeWindow.openDatabase) } catch(e) { res='Error'; } // Catch Security error
  104. return res;
  105. }
  106.  
  107. function sessionStorageLength() {
  108. var lg=0; try { lg=unsafeWindow.sessionStorage.length; } catch(e) { lg='Unreadable'; } // Catch Security error
  109. return lg;
  110. }
  111. function localStorageLength() {
  112. var lg=0; try { lg=unsafeWindow.localStorage.length; } catch(e) { lg='Unreadable'; } // Catch Security error
  113. return lg;
  114. }
  115. function globalStorageLength() {
  116. var lg=0; try { lg=unsafeWindow.globalStorage[location.hostname].length; } catch(e) { lg='Unreadable'; } // Catch Security error
  117. return lg;
  118. }
  119. function databaseStorageLength() {
  120. var lg=0;
  121. for(var name in unsafeWindow) {
  122. //show_alert(name+" "+unsafeWindow[name],1);
  123. try { if(unsafeWindow[name]=="[object Database]") { lg+=1; } } catch(e) {} // Catch Security error
  124. }
  125. if(lg==0 && unsafeWindow.opera) { return 'Available'; }
  126. return lg;
  127. }
  128.  
  129. //=============================== Main functions =========================================
  130. function keyPressed(event) {
  131. var keyCode=getKeyCode(event);
  132. if(keyCode==RESET_KEYCODE) {
  133. resetPos();
  134. refresh();
  135. refresh_data();
  136. gvar.infoBox.style.setProperty('display','block','');
  137. }
  138. }
  139.  
  140. function hideInfoBox(event) {
  141. gvar.infoBox.style.setProperty('display','none','');
  142. }
  143.  
  144. function downTitleInfoBox(event) {
  145. if(event.button!=0) { gvar.moveM=false; return; }
  146. gvar.offX=event.screenX-gvar.infoBox.offsetLeft;
  147. gvar.offY=event.screenY-gvar.infoBox.offsetTop;
  148. gvar.moveM=true;
  149. }
  150. function upTitleInfoBox(event) {
  151. gvar.moveM=false;
  152. }
  153. function moveTitleInfoBox(event) {
  154. if(gvar.moveM) {
  155. gvar.infoBox.style.left=(event.screenX-gvar.offX)+'px';
  156. gvar.infoBox.style.top =(event.screenY-gvar.offY)+'px';
  157. gvar.infoBox.style.removeProperty('right');
  158. gvar.infoBox.style.removeProperty('bottom');
  159. }
  160. }
  161.  
  162. function resetPos() {
  163. gvar.infoBox.style.removeProperty('left');
  164. gvar.infoBox.style.removeProperty('right');
  165. gvar.infoBox.style.removeProperty('top');
  166. gvar.infoBox.style.removeProperty('bottom');
  167. switch(DEFAULT_POS) {
  168. case 1: gvar.infoBox.style.setProperty('left' ,'3px',''); gvar.infoBox.style.setProperty('top' ,'3px',''); break;
  169. default:
  170. case 2: gvar.infoBox.style.setProperty('right','3px',''); gvar.infoBox.style.setProperty('top' ,'3px',''); break;
  171. case 3: gvar.infoBox.style.setProperty('left' ,'3px',''); gvar.infoBox.style.setProperty('bottom','3px',''); break;
  172. case 4: gvar.infoBox.style.setProperty('right','3px',''); gvar.infoBox.style.setProperty('bottom','3px',''); break;
  173. }
  174. }
  175.  
  176. function storageEvent(event) {
  177. //show_alert('Storage Event');
  178. refresh();
  179. refresh_data();
  180. if(SHOW_AT_CHANGE) { gvar.infoBox.style.setProperty('display','block',''); }
  181. }
  182.  
  183. function refresh() {
  184. function refreshStorage(ws,lgS,divS,divSitem,cbaf) {
  185. if((ws=='object') || (cbaf && ws=='function')) {
  186. if(lgS>=0) {
  187. divSitem.style.setProperty('text-align','right','');
  188. divSitem.style.setProperty('padding-right','6px','');
  189. divSitem.textContent=lgS+' item(s)';
  190. if(lgS>0) { divS.style.setProperty('background',COLOR_USED,''); } else { divS.style.setProperty('background',COLOR_NOT_USED,''); }
  191. } else {
  192. divSitem.style.setProperty('text-align','left','');
  193. divSitem.style.setProperty('padding-right','0','');
  194. divSitem.textContent=lgS;
  195. if(lgS=='Available') {
  196. divS.style.setProperty('background',COLOR_NOT_USED,'');
  197. } else {
  198. divS.style.setProperty('background',COLOR_PROTECTED,'');
  199. }
  200. }
  201. } else {
  202. divSitem.style.setProperty('text-align','left','');
  203. divSitem.style.setProperty('padding-right','0','');
  204. if(ws=='Error') {
  205. divSitem.textContent='Protected';
  206. divS.style.setProperty('background',COLOR_PROTECTED,'');
  207. } else if(ws=='undefined') {
  208. divSitem.textContent='Unavailable';
  209. divS.style.setProperty('background',COLOR_UNAVAILABLE,'');
  210. } else {
  211. divSitem.textContent='Bad type';
  212. divS.style.setProperty('background',COLOR_UNAVAILABLE,'');
  213. }
  214. }
  215. }
  216. // Show Data
  217. refreshStorage(sessionStorageType() ,sessionStorageLength() ,gvar.divSS,gvar.divSSitem,false);
  218. refreshStorage(localStorageType() ,localStorageLength() ,gvar.divLS,gvar.divLSitem,false);
  219. refreshStorage(globalStorageType() ,globalStorageLength() ,gvar.divGS,gvar.divGSitem,false);
  220. refreshStorage(databaseStorageType(),databaseStorageLength(),gvar.divDS,gvar.divDSitem,true);
  221. }
  222.  
  223. //========================
  224. function sessionStorageDisplayEvent(e) {
  225. e.preventDefault();
  226. storageDisplay(0);
  227. }
  228.  
  229. function localStorageDisplayEvent(e) {
  230. e.preventDefault();
  231. storageDisplay(1);
  232. }
  233.  
  234. function globalStorageDisplayEvent(e) {
  235. e.preventDefault();
  236. storageDisplay(2);
  237. }
  238.  
  239. function storageDisplay(storageId) {
  240. if(gvar.overlay!=null) { return; }
  241. gvar.storageId=storageId; gvar.storage=null; gvar.name='N/A'; var lg='N/A'; var bg='#000000'; var title='';
  242. switch(storageId) {
  243. case 0:
  244. lg=sessionStorageLength(); bg=COLOR_BG_SESSION; gvar.name='sessionStorage'; title=gvar.name+' [ this page ]';
  245. if(lg>=0) { gvar.storage=unsafeWindow.sessionStorage; } else { lg='no'; }
  246. break;
  247. case 1:
  248. var domain=location.protocol+'//'+location.hostname; if(location.port!='') { domain+=':'+location.port; }
  249. lg=localStorageLength(); bg=COLOR_BG_LOCAL; gvar.name='localStorage'; title=gvar.name+' [ '+domain+'/* ]';
  250. if(lg>=0) { gvar.storage=unsafeWindow.localStorage; } else { lg='no'; }
  251. break;
  252. case 2:
  253. lg=globalStorageLength(); bg=COLOR_BG_GLOBAL; gvar.name='globalStorage'; title=gvar.name+' [ '+location.hostname+' ]';
  254. if(lg>=0) { gvar.storage=unsafeWindow.globalStorage[location.hostname]; } else { lg='no'; }
  255. break;
  256. }
  257.  
  258. gvar.overlay = document.createElement('div');
  259. gvar.overlay.setAttribute('style','position:fixed; top:0; bottom:0; left:0; right:0; height:100%; width:100%; background:'+bg+'; opacity:0.5; overflow:auto; z-index:'+(DIV_ZINDEX-2));
  260. document.body.appendChild(gvar.overlay);
  261.  
  262. gvar.panel = document.createElement('div');
  263. gvar.panel.setAttribute('style','position:fixed; top:8px; bottom:8px; left:0; right:0; margin-left:auto; margin-right:auto; width:800px; z-index:'+(DIV_ZINDEX-1)+'; background:'+bg+'; color:#FFFFFF; overflow:auto; font-family:'+FONT_ARIAL+'; font-size:15px; font-weight:normal; text-decoration:none; line-height:15px;');
  264.  
  265. var pdiv=document.createElement('div');
  266. pdiv.setAttribute('style','position:absolute; left:0; right:0; padding:20px; padding-left:14px; padding-right:0px; text-align:left;');
  267. gvar.panel.appendChild(pdiv);
  268.  
  269. // Title...
  270. var tabElem=document.createElement('table');
  271. tabElem.setAttribute('style','width:760px; border-collapse:collapse; border:0; margin:0; padding:0;');
  272. var tr=document.createElement('tr');
  273. var td1=document.createElement('td'); tr.appendChild(td1);
  274. td1.setAttribute('style','border:0; margin:0; padding:0;');
  275. var td2=document.createElement('td'); tr.appendChild(td2);
  276. td2.setAttribute('style','width:100%; border:0; margin:0; padding:0;');
  277. var td3=document.createElement('td'); tr.appendChild(td3);
  278. td3.setAttribute('style','border:0; margin:0; padding:0;');
  279. tabElem.appendChild(tr); pdiv.appendChild(tabElem);
  280.  
  281. var elem=document.createElement('input'); elem.setAttribute('type','button');
  282. elem.setAttribute('style','width:80px; padding:4px; background: #C0C0C0 !important; color:#000000 !important; border-width:1px; cursor: pointer;');
  283. elem.value='Reset';
  284. elem.addEventListener('click', panel_clear, true);
  285. if(gvar.storage==null) { elem.style.setProperty('visibility','hidden',''); }
  286. td1.appendChild(elem);
  287.  
  288. var titleElem=document.createElement('div');
  289. titleElem.setAttribute('style','padding:4px; background:transparent !important; color:#FFFFFF !important; text-align:center; font-size:20px;');
  290. titleElem.textContent=title; td2.appendChild(titleElem);
  291.  
  292. elem=document.createElement('input'); elem.setAttribute('type','button');
  293. elem.setAttribute('style','width:80px; padding:4px; background: #C0C0C0 !important; color:#000000 !important; border-width:1px; cursor: pointer;');
  294. elem.value='Close';
  295. elem.addEventListener('click', panel_close, true);
  296. td3.appendChild(elem);
  297.  
  298. // Editor...
  299. var newElem=document.createElement('div');
  300. newElem.setAttribute('style','width:100%; margin-top:20px;');
  301.  
  302. var div=document.createElement('div');
  303. div.setAttribute('style','position:relative; display:block; margin-top:3px; color:black; height:30px; font-family:'+FONT_ARIAL);
  304. newElem.appendChild(div);
  305. var divC=document.createElement('div');
  306. divC.setAttribute('style','position:absolute; left:0px; top:0; width:26px; height:18px; padding:0px; text-align:center; font-size:9px; padding-top:4px; background:rgba(192,192,192,0.8); border:1px solid gray; cursor:pointer;');
  307. divC.textContent='Clear';
  308. div.appendChild(divC);
  309. var div1=document.createElement('textarea');
  310. div1.setAttribute('style','position:absolute; left:30px; top:0; width:'+(KEY_DIV_WIDTH+2)+'px; height:18px; padding:2px; margin:0px; margin-top:1px; border:0px; font-size:15px; background:rgba(255,255,255,0.75);');
  311. div1.value='';
  312. div.appendChild(div1);
  313. var div2=document.createElement('textarea');
  314. div2.setAttribute('style','position:absolute; left:'+(KEY_DIV_WIDTH+38)+'px; top:0; width:'+(704-KEY_DIV_WIDTH)+'px; height:18px; padding:2px; margin:0px; margin-top:1px; border:0px; font-size:15px; background:rgba(255,255,255,0.75);');
  315. div2.value='';
  316. div.appendChild(div2);
  317. var divS=document.createElement('div');
  318. divS.setAttribute('style','position:absolute; left:748px; top:0; width:24px; height:18px; padding:0px; text-align:center; font-size:9px; padding-top:4px; background:rgba(192,192,192,0.8); border:1px solid gray; cursor:pointer;');
  319. divS.textContent='Save';
  320. div.appendChild(divS);
  321. newElem.appendChild(div);
  322. pdiv.appendChild(newElem);
  323.  
  324. gvar.editKey=div1;
  325. gvar.editData=div2;
  326. divC.addEventListener('click', clear_Edit, true);
  327. divS.addEventListener('click', save_Edit, true);
  328. // Data...
  329. gvar.dataElem=document.createElement('div');
  330. gvar.dataElem.setAttribute('style','position:relative; left:0; right:0;');
  331. pdiv.appendChild(gvar.dataElem);
  332.  
  333. document.body.appendChild(gvar.panel);
  334. refresh_data();
  335. }
  336.  
  337. function clear_Edit(e) {
  338. e.preventDefault();
  339. gvar.editKey.value='';
  340. gvar.editData.value='';
  341. }
  342.  
  343. function save_Edit(e) {
  344. e.preventDefault();
  345. switch(gvar.storageId) {
  346. case 0: case 1: case 2:
  347. gvar.storage.setItem(gvar.editKey.value,gvar.editData.value);
  348. clear_Edit(e);
  349. }
  350. }
  351.  
  352. function fill_Edit(e) {
  353. e.preventDefault();
  354. var id=parseInt(e.target.textContent,10);
  355. gvar.editKey.value=gvar.storage.key(id);
  356. gvar.editData.value=gvar.storage.getItem(gvar.editKey.value);
  357. }
  358.  
  359. function panel_close(e) {
  360. e.preventDefault();
  361. if(gvar.overlay!=null) { removeElement(gvar.overlay); gvar.overlay=null; removeElement(gvar.panel); gvar.panel=null; }
  362. }
  363.  
  364. function panel_clear(e) {
  365. e.preventDefault();
  366. if(gvar.storage!=null) {
  367. if(confirm('Clear all '+gvar.name+' data ?')) { gvar.storage.clear(); }
  368. }
  369. }
  370.  
  371. function refresh_data() {
  372. if(!gvar.storage) { return; }
  373. if(!gvar.dataElem) { return; }
  374.  
  375. var lg=0;
  376. switch(gvar.storageId) {
  377. case 0: lg=sessionStorageLength(); break;
  378. case 1: lg=localStorageLength(); break;
  379. case 2: lg=globalStorageLength(); break;
  380. }
  381. if(!(lg>=0)) { return; }
  382.  
  383. var newElem=document.createElement('div');
  384. newElem.setAttribute('style','width:100%; margin-top:10px;');
  385.  
  386. var div=document.createElement('div');
  387. div.setAttribute('style','position:relative; display:block; margin-top:3px;');
  388. newElem.appendChild(div);
  389. var div1=document.createElement('div');
  390. div1.setAttribute('style','position:relative; left:0; top:0; width:24px; height:17px; padding:2px; text-align:center; background:rgba(255,255,255,0.4);');
  391. div1.textContent='#';
  392. div.appendChild(div1);
  393. var div2=document.createElement('div');
  394. div2.setAttribute('style','position:absolute; left:30px; top:0; width:'+KEY_DIV_WIDTH+'px; height:17px; padding:2px; padding-left:4px; background:rgba(255,255,255,0.4);');
  395. div2.textContent='Key';
  396. div.appendChild(div2);
  397. var div3=document.createElement('div');
  398. div3.setAttribute('style','position:absolute; left:'+(KEY_DIV_WIDTH+38)+'px; top:0; width:'+(702-KEY_DIV_WIDTH)+'px; height:17px; padding:2px; padding-left:4px; background:rgba(255,255,255,0.4);');
  399. div3.textContent='Data';
  400. div.appendChild(div3);
  401. newElem.appendChild(div);
  402.  
  403. for(var h=0;h<lg;h++) {
  404. var key=gvar.storage.key(h);
  405. if(typeof key=='undefined') { key='<undefined>'; }
  406. var data=gvar.storage.getItem(key);
  407. if(typeof data=='undefined') { data='<undefined>'; }
  408.  
  409. var div=document.createElement('div');
  410. div.setAttribute('style','position:relative; display:block; margin-top:3px;');
  411. var div1=document.createElement('div');
  412. div1.setAttribute('style','position:relative; left:0; top:0; width:24px; height:17px; text-align:right; padding:2px; background:rgba(255,255,255,0.2); font-size:13px; cursor:pointer;');
  413. div1.textContent=h;
  414. div.appendChild(div1);
  415. var div2=document.createElement('div');
  416. div2.setAttribute('style','position:absolute; left:30px; top:0; width:'+(KEY_DIV_WIDTH+2)+'px; height:17px; padding:2px; background:rgba(255,255,255,0.2); font-size:13px; overflow:hidden;');
  417. div2.textContent=key;
  418. div.appendChild(div2);
  419. var div3=document.createElement('div');
  420. div3.setAttribute('style','position:absolute; left:'+(KEY_DIV_WIDTH+38)+'px; top:0; width:'+(704-KEY_DIV_WIDTH)+'px; height:17px; padding:2px; background:rgba(255,255,255,0.2); font-size:13px; overflow:hidden;');
  421. div3.textContent=data;
  422. div.appendChild(div3);
  423. var div4=document.createElement('div');
  424. div4.setAttribute('style','position:absolute; left:748px; top:0; width:10px; height:15px; text-align:center; padding:2px; background:rgba(128,128,128,0.8); border:1px solid gray; color:#660000; font-weight:bold; cursor:pointer;');
  425. div4.textContent='X';
  426. div4.setAttribute('value',key);
  427. div.appendChild(div4);
  428. div4.addEventListener('click',deleteItem,true);
  429. newElem.appendChild(div);
  430.  
  431. div1.addEventListener('click', fill_Edit, true);
  432. }
  433. replaceElement(gvar.dataElem,newElem);
  434. gvar.dataElem=newElem;
  435. }
  436.  
  437. function deleteItem(event) {
  438. event.preventDefault();
  439. if(!gvar.storage) { return; }
  440. var key=event.target.getAttribute('value');
  441. if(confirm('Delete '+key+' ?')) { gvar.storage.removeItem(key); }
  442. }
  443.  
  444.  
  445. /******************************************** License ******************************************************
  446. *** Creative Commons 3.0 ***
  447. *** by: BY-attribution (Requirement to acknowledge or credit the author "GIJoe") ***
  448. *** nc: Non-Commercial (Use for commercial purpose is forbidden) ***
  449. *** sa: Share Alike (Derivative works must be under the same or similar license to this one) ***
  450. ***********************************************************************************************************/
  451.  
  452. function main() {
  453. // Check if html page with div or table or link...
  454. var check=null; try { check=document.evaluate('//div',document,null,XPathResult.ANY_UNORDERED_NODE_TYPE,null).singleNodeValue; } catch(e) {}
  455. if(!check) { try { check=document.evaluate('//table',document,null,XPathResult.ANY_UNORDERED_NODE_TYPE,null).singleNodeValue; } catch(e) {} }
  456. if(!check) { try { check=document.evaluate('//a',document,null,XPathResult.ANY_UNORDERED_NODE_TYPE,null).singleNodeValue; } catch(e) {} }
  457. if(!check) { return; }
  458.  
  459. // Create infoBox
  460. var top1=DIV_HEIGHT+1; var htot=(DIV_HEIGHT+1)*5+1;
  461. var infoBox=document.createElement('div');
  462. infoBox.setAttribute('style','position:fixed; display:none; width:149px; height:'+htot+'px; opacity:'+DIV_OPACITY+'; right:3px; top:3px; background:'+COLOR_TITLE+'; color:'+COLOR_INFO_TEXT+'; white-space:nowrap; text-align:center; vertical-align:middle; overflow:auto; z-index:'+DIV_ZINDEX+'; font-family:'+FONT_ARIAL+' !important; font-size:15px; font-weight:normal; text-decoration:none; line-height:17px;');
  463.  
  464. var div5=document.createElement('div');
  465. div5.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0; left:0px; right:0px; border:1px solid gray; cursor: move; font-weight:bold; padding-right:'+DIV_HEIGHT+'px; color:'+COLOR_TITLE_TEXT);
  466. div5.textContent='Storage Viewer';
  467. user_select(div5,'none');
  468. infoBox.appendChild(div5);
  469. var div6=document.createElement('div');
  470. div6.setAttribute('style','position: absolute; display :block; height:'+(DIV_HEIGHT-4)+'px; width:'+(DIV_HEIGHT-4)+'px; top:2px; right:2px; border:1px solid gray; cursor:pointer; background:'+COLOR_CLOSE+'; font-size:13px; line-height:14px; color:'+COLOR_CLOSE_TEXT);
  471. div6.textContent='X';
  472. user_select(div6,'none');
  473. infoBox.appendChild(div6);
  474.  
  475. var divSS=document.createElement('div');
  476. divSS.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:'+top1+'px; left:0; right:0; border:1px solid gray; cursor:pointer;');
  477. var divSS1=document.createElement('div');
  478. divSS1.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; left:2px;');
  479. divSS1.textContent='Session:';
  480. divSS.appendChild(divSS1);
  481. var divSS2=document.createElement('div');
  482. divSS2.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; right:0; width:86px; text-align:left;');
  483. divSS2.textContent='N/A';
  484. divSS.appendChild(divSS2);
  485. infoBox.appendChild(divSS);
  486.  
  487. var divLS=document.createElement('div');
  488. divLS.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:'+(top1*2)+'px; left:0; right:0; border:1px solid gray; cursor:pointer;');
  489. var divLS1=document.createElement('div');
  490. divLS1.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; left:2px;');
  491. divLS1.textContent='Local:';
  492. divLS.appendChild(divLS1);
  493. var divLS2=document.createElement('div');
  494. divLS2.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; right:0; width:86px; text-align:left;');
  495. divLS2.textContent='N/A';
  496. divLS.appendChild(divLS2);
  497. infoBox.appendChild(divLS);
  498.  
  499. var divGS=document.createElement('div');
  500. divGS.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:'+(top1*3)+'px; left:0; right:0; border:1px solid gray; cursor:pointer;');
  501. var divGS1=document.createElement('div');
  502. divGS1.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; left:2px;');
  503. divGS1.textContent='Global:';
  504. divGS.appendChild(divGS1);
  505. var divGS2=document.createElement('div');
  506. divGS2.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; right:0; width:86px; text-align:left;');
  507. divGS2.textContent='N/A';
  508. divGS.appendChild(divGS2);
  509. infoBox.appendChild(divGS);
  510.  
  511. var divDS=document.createElement('div');
  512. divDS.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:'+(top1*4)+'px; left:0; right:0; border:1px solid gray; cursor:default;');
  513. var divDS1=document.createElement('div');
  514. divDS1.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; left:2px;');
  515. divDS1.textContent='DB:';
  516. divDS.appendChild(divDS1);
  517. var divDS2=document.createElement('div');
  518. divDS2.setAttribute('style','position: absolute; display :block; height:'+DIV_HEIGHT+'px; top:0px; right:0; width:86px; text-align:left;');
  519. divDS2.textContent='N/A';
  520. divDS.appendChild(divDS2);
  521. infoBox.appendChild(divDS);
  522.  
  523.  
  524. gvar.infoBox=infoBox; gvar.divSS=divSS; gvar.divSSitem=divSS2; gvar.divLS=divLS; gvar.divLSitem=divLS2;
  525. gvar.divGS=divGS; gvar.divGSitem=divGS2; gvar.divDS=divDS; gvar.divDSitem=divDS2;
  526. document.body.appendChild(infoBox);
  527.  
  528. gvar.moveM=false;
  529. div5.addEventListener('mousedown',downTitleInfoBox, true);
  530. window.addEventListener('mouseup',upTitleInfoBox, true);
  531. window.addEventListener('mousemove',moveTitleInfoBox, true);
  532. div6.addEventListener('click', hideInfoBox, true);
  533. divSS.addEventListener('click', sessionStorageDisplayEvent, true);
  534. divLS.addEventListener('click', localStorageDisplayEvent , true);
  535. divGS.addEventListener('click', globalStorageDisplayEvent , true);
  536.  
  537. if(gvar.isOpera) {
  538. window.addEventListener('keypress',keyPressed,true);
  539. } else {
  540. window.addEventListener('keydown',keyPressed,true);
  541. }
  542. resetPos();
  543.  
  544. var used=false;
  545. if(SHOW_AT_START>2) { gvar.infoBox.style.setProperty('display','block',''); }
  546. else if(SHOW_AT_START>1 && (sessionStorageLength()>=0 || localStorageLength()>=0)) { gvar.infoBox.style.setProperty('display','block',''); }
  547. else if(SHOW_AT_START>0 && (sessionStorageLength()>0 || localStorageLength()>0 )) { gvar.infoBox.style.setProperty('display','block',''); }
  548.  
  549. unsafeWindow.addEventListener('storage', storageEvent, true);
  550. refresh();
  551. }
  552.  
  553. function waitForReady(callback) {
  554. var docState=null; try { docState=unsafeWindow.document.readyState; } catch(e) { docState=null; }
  555. if(docState) {
  556. if(docState!='complete') {
  557. GM_log('Document not loaded ('+docState+'), waiting...',0);
  558. window.setTimeout(waitForReady,150,callback); return;
  559. } else { GM_log('Document loaded ('+docState+'), launching...',0); }
  560. }
  561. callback();
  562. }
  563.  
  564. waitForReady(main);
  565.  
  566. })();
  567. // ]]>

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址