Changeset 14888

Show
Ignore:
Timestamp:
06/30/08 08:29:19 (5 years ago)
Author:
javascripter
Message:

取得済みURLのチェック、継ぎ足し位置をAutoPagerize互換に、細かいバグの修正。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/autopageloader.user.js

    r14721 r14888  
    6060  var Cache = new Class(); 
    6161  Cache.reset = function () { 
    62     GM_setValue('cache', '{}'); 
     62    GM_setValue('cache', 'new Object()'); 
    6363  } 
    6464  Cache.normalize = function () { 
     
    155155    onscroll: function () { 
    156156      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; 
    158160        if (pos - window.innerHeight < Config.remain_height) this.loadNext(); 
    159161      } 
     
    182184          } 
    183185          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)); 
    185189          var navi = document.createElement('div'); 
    186190          navi.innerHTML = 'page: <a class="autopagerize_link" href"' + 
     
    190194              df.appendChild(elem); 
    191195            }); 
    192           this._insertBefore.parentNode.insertBefore(df, this._insertBefore); 
     196          insertAfter(this._insertPoint, df); 
    193197          AutoPageLoader.filters.forEach(function (fn) { fn(pageElements); }); 
    194           this._insertBefore = nextElement(pageElements.pop()); 
     198          this._insertPoint = pageElements.pop(); 
    195199          var nElem = $X(this._info.nextLink, doc).shift(); 
    196200          if (nElem == null) { 
     
    198202            return; 
    199203          } 
     204          this._loaded.push(this._nextUrl); 
    200205          this._nextUrl = nElem.href; 
     206          if (this._loaded.indexOf(this._nextUrl) != -1) this.state = 'finish'; 
    201207        }, this), 
    202208        3000, 
     
    211217      this.state = Config.auto_start ? 'on': 'off'; 
    212218      this._page = 1; 
    213       this._insertBefore = 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(); 
    216222      this._nextUrl = $X(this._info.nextLink).shift().href; 
     223      this._loaded = []; 
    217224      window.addEventListener('scroll', 
    218225                              this._scroll = bind(this.onscroll, this), 
     
    314321      fn.apply(thisObj, arguments); 
    315322 
    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); 
    318327 
    319328  function $X (exp, context, type /* want type */) {