個人用

    @@ -36,19 +36,19 @@ elList = elList.sort(function(a, b) { return a.count - b.count }); var otherCount = 0; -var usernameList = []; -var countList = []; +var labelList = []; +var dataList = []; for (var i = 0; i < elList.length; i++) { if (elList[i].count / totalCount < 0.1) { otherCount += elList[i].count; } else { - usernameList.push(elList[i].username); - countList.push(elList[i].count); + labelList.push(elList[i].username + elList[i].count / totalCount * 100 + '%'); + dataList.push(elList[i].count / totalCount); } } -usernameList.push('other'); -countList.push(otherCount); +usernameList.push('other' + otherCount / totalCount * 100 + '%'); +countList.push(otherCount / totalCount); location.href = 'http://chart.apis.google.com/chart?cht=p3&chd=t:' + countList.join(',') + '&chs=800x300&chl=' + usernameList.join('|')
  • /*
     * @title クリック数をグラフで見る
     * @description クリック数をグラフで見る
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    var parentEl = document.getElementById('bookmarked_user');
    var nodes = parentEl.childNodes;
    
    var ElementInfo = function(el, count, username) {
        this.el = el;
        this.count = count;
        this.username = username;
    };
    
    var totalCount = 0;
    var elList = [];
    for (var i = 0, l = nodes.length; i < l; i++) {
        var el = nodes[i];
        if (el.nodeType === 1) {
            var usernameEl = Ten.DOM.getElementsByClassName('username', el)[0];
            var countEl = Ten.DOM.getElementsByClassName('click-count', el)[0];
            if (countEl) {
                var username = usernameEl.innerText || usernameEl.textContent;
                var count = countEl.innerText || countEl.textContent;
                var m = count.match(/\d+/);
                count = +m[0];
                elList.push(new ElementInfo(el, count, username));
                totalCount += count;
            }
        }
    }
    
    elList = elList.sort(function(a, b) { return a.count - b.count });
    
    var otherCount = 0;
    var labelList = [];
    var dataList = [];
    for (var i = 0; i < elList.length; i++) {
        if (elList[i].count / totalCount < 0.1) {
            otherCount += elList[i].count;
        }
        else {
            labelList.push(elList[i].username + elList[i].count / totalCount * 100 + '%');
            dataList.push(elList[i].count / totalCount);
        }
    }
    
    usernameList.push('other' + otherCount / totalCount * 100 + '%');
    countList.push(otherCount / totalCount);
    
    location.href = 'http://chart.apis.google.com/chart?cht=p3&chd=t:' + countList.join(',') + '&chs=800x300&chl=' + usernameList.join('|')
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/10/14 22:20:27 - 2010-10-14
  2. 2010/10/13 18:43:38 - 2010-10-13
  3. 2010/08/27 00:43:18 - 2010-08-27
  4. 2010/08/27 00:42:35 - 2010-08-27
  5. 2010/08/27 00:41:23 - 2010-08-27
  6. 2010/08/27 00:23:48 - 2010-08-27
  7. 2010/08/27 00:21:12 - 2010-08-27
  8. 2010/08/27 00:19:38 - 2010-08-27
  9. 2010/08/27 00:11:53 - 2010-08-27
  10. 2010/08/27 00:10:51 - 2010-08-27
  11. 2010/08/27 00:09:17 - 2010-08-27
  12. 2010/08/27 00:08:48 - 2010-08-27
  13. 2010/08/27 00:07:57 - 2010-08-27
  14. 2010/08/27 00:07:07 - 2010-08-27
  15. 2010/08/27 00:05:59 - 2010-08-27
  16. 2010/08/27 00:00:40 - 2010-08-27
  17. 2010/08/26 23:59:51 - 2010-08-26