quyo random autopagerize

    
      
  • /*
     * @title quyo random autopagerize
     * @description quyo random auopagerize
     * @include http://quyo.hatelabo.jp/item/
     * @license MIT
     */
    
    (function() {
      var loading = false;
      var x = new XMLHttpRequest();
      var lastElement = function() {
        var e = document.querySelectorAll('.container-mini.section');
        return e[e.length - 1];
      }();
      var insertPoint = lastElement.nextSibling;
    
      x.onload = function(e) {
        if (x.status <= 200) {
          var doc = e.target.response;
          Array.prototype.forEach.call(doc.querySelectorAll('.container-mini.section'), function(elem) {
            lastElement.parentElement.insertBefore(elem, insertPoint);
          });
        }
        loading = false;
      };
    
      function loadNext() {
        loading = true;
        x.open('GET', '/items/next', true);
        x.responseType = 'document';
        x.send(null);
      };
    
      window.addEventListener('scroll', function() {
        if (loading) return;
        var remain = document.documentElement.scrollHeight - window.innerHeight - window.pageYOffset;
        if (remain < 2000) {
          loadNext();
        }
      }, false);
    
      loadNext();
    }());
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2015/02/02 19:36:27 - 2015-02-02
  2. 2015/02/02 18:00:04 - 2015-02-02
  3. 2014/12/19 17:42:56 - 2014-12-19
  4. 2014/12/19 17:41:24 - 2014-12-19