AA Sintax for Hatena Haiku

  • /*
     * @title AA Sintax for Hatena Haiku
     * @description はてなハイクでAA記法を使えるようにする
     * @include http://h.hatena.ne.jp/*
     * @exclude http://h.hatena.ne.jp/album*
     * @exclude http://h.hatena.ne.jp/guide*
     * @exclude http://h.hatena.ne.jp/setting*
     * @include http://h.hatena.com/*
     * @exclude http://h.hatena.com/album*
     * @exclude http://h.hatena.com/guide*
     * @exclude http://h.hatena.com/setting*
     * @include http://h1beta.hatena.ne.jp/*
     * @exclude http://h1beta.hatena.ne.jp/album*
     * @exclude http://h1beta.hatena.ne.jp/guide*
     * @exclude http://h1beta.hatena.ne.jp/setting*
     * @include http://h1beta.hatena.com/*
     * @exclude http://h1beta.hatena.com/album*
     * @exclude http://h1beta.hatena.com/guide*
     * @exclude http://h1beta.hatena.com/setting*
     * @license MIT License.
     */
    
    (function() {
    
    	function aaSintax(doc) {
    	  var startSintax = /^&gt\;\|aa\|$/;
    	  var endSintax = /^\|\|&lt\;$/;
    	  var sintaxFlag = false;
    
    	  var entry = document.getElementsByClassName('entry-body-content');
    	  for (i in entry) {
    	    var out = '';
    	    var body = entry[i].innerHTML;
    	    if (body) {
    	      var lines = body.split("<br>");
    	      var last  = lines.length - 1;
    	      for (l in lines) {
    	        if (l == 0) {
    	          lines[l] = lines[l].replace("\n            ", '');
    	        }
    	        if (startSintax.test(lines[l]) == true) {
    	          sintaxFlag = true;
    	          out += '<div style="font-family:IPAMonaPGothic,'+
    	                 "'" + 'MS Pゴシック' + "'" +
    	                 ',sans-serif;font-size:16px;line-height:18px;">';
    	        } else if (endSintax.test(lines[l]) == true && sintaxFlag == true) {
    	          sintaxFlag = false;
    	          out += '</div>';
    	        } else {
    	          out += lines[l];
    	          if (l != last) {
    	            out += '<br>';
    	          }
    	        }
    	      }
    	      if (sintaxFlag == true) {
    	        sintaxFlag = false;
    	        out += lines[l];
    	      }
    	      entry[i].innerHTML = out;
    	    }
    	  }
    	}
    
    	aaSintax(document.body);
    
    
    	if (typeof unsafeWindow == 'undefined') {
    		/* Bookmarklet, etc... */
    		var TEN = Ten;
    	} else {
    		/* Greasemonkey */
    		var TEN = unsafeWindow.Ten;
    	}
    
    	TEN.AsyncLoader.executeWhenFragmentLoadedOrNow(function(frag) {
    		aaSintax(document.body);
    	}.bind());
    
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/08/11 00:24:23 - 2011-08-11
  2. 2011/08/11 00:22:50 - 2011-08-11
  3. 2011/04/08 10:52:04 - 2011-04-08
  4. 2011/04/07 22:34:21 - 2011-04-07
  5. 2011/04/07 22:31:51 - 2011-04-07
  6. 2011/04/07 22:30:40 - 2011-04-07
  7. 2011/04/07 22:28:15 - 2011-04-07
  8. 2011/04/07 22:23:53 - 2011-04-07
  9. 2011/04/07 22:22:59 - 2011-04-07
  10. 2011/04/07 22:21:22 - 2011-04-07
  11. 2011/04/07 21:59:41 - 2011-04-07
  12. 2011/04/07 21:55:48 - 2011-04-07
  13. 2011/04/07 21:55:26 - 2011-04-07
  14. 2011/04/07 21:41:51 - 2011-04-07
  15. 2011/04/07 21:21:56 - 2011-04-07
  16. 2011/04/07 17:29:28 - 2011-04-07
  17. 2011/04/07 17:28:42 - 2011-04-07