Changeset 14888
- Timestamp:
- 06/30/08 08:29:19 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/autopageloader.user.js
r14721 r14888 60 60 var Cache = new Class(); 61 61 Cache.reset = function () { 62 GM_setValue('cache', ' {}');62 GM_setValue('cache', 'new Object()'); 63 63 } 64 64 Cache.normalize = function () { … … 155 155 onscroll: function () { 156 156 if (this.state == 'on') { 157 var pos = this._insertBefore.getBoundingClientRect().top; 157 var pos = $X('following::*', 158 this._insertPoint).shift().getBoundingClientRect().top || 159 window.scrollMaxY - window.scrollY; 158 160 if (pos - window.innerHeight < Config.remain_height) this.loadNext(); 159 161 } … … 182 184 } 183 185 this.state = 'on'; 184 AutoPageLoader.documentFilters.forEach(function (fn) { fn(doc); }); 186 AutoPageLoader.documentFilters.forEach(bind(function (fn) { 187 fn(doc, this._nextUrl, this._info); 188 }, this)); 185 189 var navi = document.createElement('div'); 186 190 navi.innerHTML = 'page: <a class="autopagerize_link" href"' + … … 190 194 df.appendChild(elem); 191 195 }); 192 this._insertBefore.parentNode.insertBefore(df, this._insertBefore);196 insertAfter(this._insertPoint, df); 193 197 AutoPageLoader.filters.forEach(function (fn) { fn(pageElements); }); 194 this._insert Before = nextElement(pageElements.pop());198 this._insertPoint = pageElements.pop(); 195 199 var nElem = $X(this._info.nextLink, doc).shift(); 196 200 if (nElem == null) { … … 198 202 return; 199 203 } 204 this._loaded.push(this._nextUrl); 200 205 this._nextUrl = nElem.href; 206 if (this._loaded.indexOf(this._nextUrl) != -1) this.state = 'finish'; 201 207 }, this), 202 208 3000, … … 211 217 this.state = Config.auto_start ? 'on': 'off'; 212 218 this._page = 1; 213 this._insert Before= this._info.insertBefore ?214 $X(this._info.insertBefore). pop() :215 nextElement($X(this._info.pageElement).pop());219 this._insertPoint = this._info.insertBefore ? 220 $X(this._info.insertBefore).shift() : 221 $X(this._info.pageElement).pop(); 216 222 this._nextUrl = $X(this._info.nextLink).shift().href; 223 this._loaded = []; 217 224 window.addEventListener('scroll', 218 225 this._scroll = bind(this.onscroll, this), … … 314 321 fn.apply(thisObj, arguments); 315 322 316 function nextElement(elem) 317 $X('./following::*', elem).shift(); 323 function insertAfter(elem, newElem) 324 elem.nextSibling ? 325 elem.parentNode.insertBefore(newElem, elem.nextSibling) : 326 elem.parentNode.appendChild(newElem); 318 327 319 328 function $X (exp, context, type /* want type */) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)