非公開 非公式 RT 用リンク生成

  • /*
     * @title 非公式 RT 用リンク生成
     * @description 日記タイトルの上辺りに非公式 RT 用リンクを生成するので、それを編集画面にコピペして下さい。(http://let.hatelabo.jp/Lhankor_Mhy/let/gYC-yujygKLUFQ と趣旨は同じですが、こちらは記事単体のページ以外でも実行できます。あとブログのタイトルが付きません。)
     * @include http://d.hatena.ne.jp
     * @license MIT License
     * @private
     */
    
    (function (){
    
    // 「この記事をtwitterへRTする」(http://q.hatena.ne.jp/1285319726 準拠)
    var l = "\u3053\u306e\u8a18\u4e8b\u3092twitter\u3078RT\u3059\u308b",
    // この辺も元質問準拠なので、変えたい場合は適当に Fork して変えて下さい。
     p = '" target="_blank" title="' + l + '"><font size="4">' + l + '</font></a>',
     i, n, t, a, c, d = document, g = "getElementsByTagName", h = d[g]("h3");
    
    if (location.href.match(/d\.hatena\.ne\.jp\/([^\/\+]+)/)) {
    
    	n = RegExp.$1 + "+";
    
    	for (i = 0; i < h.length; i++) if ((a = h[i][g]("a")) && a.length) {
    
    		a = a[0].href;
    		t = h[i].lastChild;
    		t = t.innerText || t.textContent || t.nodeValue.replace(/^\]/, "");
    		c = d.createElement("textarea");
    		c.value = '<a href="http://twitter.com/home?status=RT%40' + n + encodeURIComponent(t + " " + a) + p;
    		h[i].parentNode.insertBefore(c, h[i]);
    
    
    	}
    
    }
    
    
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/09/25 14:18:40 - 2010-09-25