[q.hatena]回答へのコメントをリストで表示

  • /*
     * @title [q.hatena]回答へのコメントをリストで表示
     * @description 新着順に並べたリスト (リンク) を作ります。仕様変更前の返信は含まれません。
     * @include http://q.hatena.ne.jp/*
     * @license MIT License
     */
    
    (function() {
    
    var l = [],
     u = $('<ul>').css({
      'background-color': '#EEE',
      'font-size' : '75%',
      'width': '26em',
      'height': '20em',
      'overflow': 'auto',
      'position': 'fixed',
      'right': '0px',
      'bottom': '0px',
      'z-index': '999'
     }).append(
      $('<li>').css({
       'color': '#FFF',
       'background-color': '#E95',
       'cursor': 'pointer',
       'text-align': 'center'
      }).click(function () {
       $(this).parent().remove();
      }).text('[close]')
     ).appendTo('#hatena-question-entry');
    
    $("div[id^='ac']").each(function() {
    
    	l.push(
    	 $('<li>').attr('id', 'l' + this.id).append(
    	  $('<a>').attr('href', '#' + this.id).text(
    	   $('span.timestamp', this).text().substr(5) + ' : '
    	    + $('div.section', this).text().replace(/^\s+/m, '').substr(0, 12) + '...'
    	  ).click(function() {
    	   $('div.answer-comment-more:visible', $($(this).attr('href')).parent()).click();
    	  })
    	 )
    	);
    
    });
    
    l.sort(function (a, b) {
     return((a.attr('id').substr(3) - 0 < b.attr('id').substr(3) - 0) ? 1 : -1);
    });
    $(l).each(function () { u.append(this); });
    
    
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/10/25 21:18:36 - 2011-10-25
  2. 2011/10/24 16:18:13 - 2011-10-24
  3. 2011/10/23 17:34:09 - 2011-10-23