クリック数で並べ替える

    @@ -22,7 +22,7 @@ if (countEl) { var count = countEl.innerText || countEl.textContent; var m = count.match(/\d+/); - elList.push(new ElementInfo(el, +m[1])); + elList.push(new ElementInfo(el, +m[0])); } } }
  • /*
     * @title クリック数で並べ替える
     * @description クリック数で並べ替え
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    var parentEl = document.getElementById('bookmarked_user');
    var nodes = parentEl.childNodes;
    
    var ElementInfo = function(el, count) {
        this.el = el;
        this.conut = count;
    };
    
    var elList = [];
    for (var i = 0, l = nodes.length; i < l; i++) {
        var el = nodes[i];
        if (el.nodeType === 1) {
            var countEl = Ten.DOM.getElementsByClassName('click-count', el)[0];
            if (countEl) {
                var count = countEl.innerText || countEl.textContent;
                var m = count.match(/\d+/);
                elList.push(new ElementInfo(el, +m[0]));
            }
        }
    }
    
    elList = elList.sort(function(a, b) { return a.count - b.count });
    
    for (var i = 0; i < elList.length; i++) {
        parentEl.insertBefore(elList[i].el, parentEl.firstChild);
    }
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/06/28 12:26:04 - 2010-06-28
  2. 2010/06/28 12:24:32 - 2010-06-28
  3. 2010/06/28 12:22:02 - 2010-06-28
  4. 2010/06/28 12:20:35 - 2010-06-28
  5. 2010/06/28 12:19:37 - 2010-06-28
  6. 2010/06/28 12:19:13 - 2010-06-28
  7. 2010/06/28 12:18:46 - 2010-06-28
  8. 2010/06/28 12:18:11 - 2010-06-28
  9. 2010/06/28 12:17:43 - 2010-06-28