Changeset 18863
- Timestamp:
- 09/05/08 01:05:33 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/search_autopagerize_site.user.js
r18857 r18863 20 20 21 21 (function(){ 22 if(!window.Minibuffer) return; 22 if(!window.Minibuffer) return; 23 23 24 24 var SITEINFOURL = 'http://wedata.net/databases/AutoPagerize/items.json'; … … 26 26 var _switch = false; 27 27 var _updated = false; 28 29 var SearchUrl = function(info){ 28 29 var SearchUrl = function(info){ 30 30 if(_switch){ 31 31 var oldnode = document.getElementById('SAS_SiteInfoCheck'); 32 32 document.body.removeChild(oldnode); 33 } 34 for(var i=0;i<info.length;i++){ 35 var loc = location.href.match(info[i].data.url) 36 if(loc != null && info[i].data.url != '^https?://.'){ 37 Keeper = info[i]; 38 var self = document.createElement("div"); 39 self.setAttribute("id","SAS_SiteInfoCheck"); 40 self.innerHTML = '<wedata>'; 41 with (self.style) { 42 textAlign = 'left' 43 background = '#cccccc' 44 fontSize = '10px' 45 position = 'fixed' 46 padding = '0 5px 0 5px' 47 top = '30px' 48 right = '0px' 49 width = 'auto' 50 height = 'auto' 51 border = '0px' 52 zindex = '257' 53 }; 54 document.body.appendChild(self); 55 self.addEventListener('mouseover',changeStatusView,false); 56 self.addEventListener('mouseout',changeStatusClose,false); 57 changeStatusClose('mouseout'); 58 _switch = true; 59 return; 33 } 34 info.some(function(item){ 35 var loc = location.href.match(item.data.url); 36 if(loc == null || item.data.url == '^https?://.'){ 37 return false; 60 38 } 61 } 39 Keeper = item; 40 var self = document.createElement("div"); 41 self.setAttribute("id","SAS_SiteInfoCheck"); 42 self.innerHTML = '<wedata>'; 43 with(self.style){ 44 textAlign = 'left' 45 background = '#cccccc' 46 fontSize = '10px' 47 position = 'fixed' 48 padding = '0 5px' 49 top = '30px' 50 right = '0px' 51 width = 'auto' 52 height = 'auto' 53 border = '0px' 54 zIndex = '257' 55 } 56 document.body.appendChild(self); 57 self.addEventListener('mouseover',changeStatusView,false); 58 self.addEventListener('mouseout',changeStatusClose,false); 59 changeStatusClose('mouseout'); 60 return (_switch = true); 61 }); 62 62 }; 63 63 64 64 var setMinibuffer = function(){ 65 65 window.Minibuffer.addCommand({ 66 66 name: 'SITEINFO::View-AutoPagerize', 67 command: function(){ 68 window.Minibuffer.status('Siteinfochecker','Checked', 1000); 67 command: function(){ 68 window.Minibuffer.status('Siteinfochecker','Checked', 1000); 69 69 setTimeout(checkData,1000); 70 }, 71 }); 72 70 }, 71 }); 72 73 73 window.Minibuffer.addShortcutkey({ 74 74 key: 'c', … … 77 77 window.Minibuffer.execute('SITEINFO::View-AutoPagerize'); 78 78 } 79 }); 80 } 81 79 }); 80 }; 81 82 82 var changeStatusClose = function(e){ 83 var self = document.getElementById("SAS_SiteInfoCheck"); 83 var self = document.getElementById("SAS_SiteInfoCheck"); 84 84 var style = document.defaultView.getComputedStyle(self, ''); 85 85 var changeStyle = ['top', 'left', 'height', 'width'].map(function(i) { … … 88 88 e.clientY < changeStyle[0] || e.clientY > (changeStyle[0] + changeStyle[2])){ 89 89 self.innerHTML = '<wedata>'; 90 with (self.style){90 with(self.style){ 91 91 background = '#cccccc' 92 92 fontSize = '10px' 93 padding = '0 5px 0 5px'93 padding = '0 5px' 94 94 border = '0px' 95 95 } 96 96 } 97 97 }; 98 98 99 99 var changeStatusView = function(){ 100 var self = document.getElementById("SAS_SiteInfoCheck"); 100 var self = document.getElementById("SAS_SiteInfoCheck"); 101 101 var regularBG = 'background:#ccffcc;font-size:11px;text-indent:1em;'; 102 self.innerHTML = '*pageElement<div style="' + regularBG + '">' + Keeper.data.pageElement + '</div>'; 102 self.innerHTML = '*pageElement<div style="' + regularBG + '">' + Keeper.data.pageElement + '</div>'; 103 103 self.innerHTML += '*url<div style="' + regularBG + '">' + Keeper.data.url + '</div>'; 104 104 self.innerHTML += '*nextLink<div style="' + regularBG + '">' + Keeper.data.nextLink + '</div>'; 105 with (self.style){105 with(self.style){ 106 106 background = 'white' 107 107 fontSize = '11px' 108 108 padding = '5px' 109 109 border = '1px solid #cccccc' 110 } 110 } 111 111 }; 112 112 113 113 var viewPopRemove = function(){ 114 114 if(_switch){ … … 119 119 checkData(); 120 120 } 121 } 122 121 }; 122 123 123 var setCache = function(info){ 124 124 GM_setValue('cacheInfo',info); 125 125 }; 126 126 127 127 var getCache = function(){ 128 128 return eval(GM_getValue('cacheInfo','[]')); 129 129 }; 130 130 131 131 var clearCache = function(){ 132 132 GM_setValue('cacheInfo','[]'); 133 } 134 133 }; 134 135 135 var checkData = function(){ 136 136 var info = getCache(); 137 137 if(info.length > 0){ 138 SearchUrl(info); 138 SearchUrl(info); 139 139 }else{ 140 140 var opt = { … … 146 146 } 147 147 }; 148 148 149 149 var getJson = function(res){ 150 150 clearCache(); … … 153 153 SearchUrl(info); 154 154 }; 155 155 156 156 GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Check", checkData); 157 157 GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Clear Cache", clearCache); 158 158 GM_registerMenuCommand("SiteInfo View(AutoPagerize) - Close/Open ", viewPopRemove); 159 setMinibuffer(); 159 setMinibuffer(); 160 160 })();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)