GoogleニュースとCEEK.JP NEWSの記事にはてなブックマークへのリンクを貼るUserJS
ずっと前に作ったやつです。多分車輪の(ry です。
Opera 9.52, Firefox 3.0.1+Greasemonkey 0.8.20080609.0, Sleipnir 2.8.0+SeaHorse 1.1.2で動作確認済み。
ちなみにjQueryを外部から読み込むHackを使ってます。
ToDo
- 他の実装を検索する
- Gresemonkey 0.8の@requireを使ったバージョンを書く
Googleニュース用
// ==UserScript== // @name Google News add link of hatena bookmark on each articles // @namespace http://d.hatena.ne.jp/n2s/ // @version 0.0.1.08082301 // @include http://news.google.co.jp/* // ==/UserScript== (function() { if(typeof unsafeWindow == 'undefined'){ unsafeWindow = window; } // Add jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; GM_JQ.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(GM_JQ); // Check if jQuery's loaded function GM_wait() { if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { $ = unsafeWindow.jQuery; letsJQuery(); } } GM_wait(); // All your GM code must be inside this function function letsJQuery() { var _w = (typeof unsafeWindow != 'undefined') ? unsafeWindow : window; var _d = _w.document; var j$ = _w.jQuery.noConflict(); var show_users = true; /* trueならばusers表示 */ j$("a").each(function(){ var a = this; if(a.href.match(/google\.co/)){ return; } var e = _d.createElement("a"); var suf = a.href.replace(/#/, "%23"); e.href= "http://b.hatena.ne.jp/entry/" + suf; var img = _d.createElement("img"); img.src = show_users ? ("http://b.hatena.ne.jp/entry/image/normal/" + suf) : "http://b.hatena.ne.jp/images/entry.gif"; img.border=0; img.style.verticalAlign = "bottom"; e.appendChild(img); j$(a).after(e); }); }; })();
CEEK.JP NEWS用
// ==UserScript== // @name CEEK.JP NEWS add link of hatena bookmark on each articles // @namespace http://d.hatena.ne.jp/n2s/ // @version 0.0.1.08082301 // @include http://news.ceek.jp/* // ==/UserScript== (function() { if(typeof unsafeWindow == 'undefined'){ unsafeWindow = window; } // Add jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; GM_JQ.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(GM_JQ); // Check if jQuery's loaded function GM_wait() { if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { $ = unsafeWindow.jQuery; letsJQuery(); } } GM_wait(); // All your GM code must be inside this function function letsJQuery() { var _w = (typeof unsafeWindow != 'undefined') ? unsafeWindow : window; var _d = _w.document; var j$ = _w.jQuery.noConflict(); var show_users = true; /* trueならばusers表示 */ j$("table.margin tr").each(function(){ var td = j$("td", this)[0]; var a = j$("a", td)[0]; if(a){ var e = _d.createElement("a"); var suf = a.href.replace(/#/, "%23"); e.href= "http://b.hatena.ne.jp/entry/" + suf; var img = _d.createElement("img"); img.src = show_users ? ("http://b.hatena.ne.jp/entry/image/small/" + suf) : "http://b.hatena.ne.jp/images/entry.gif"; img.border=0; e.appendChild(img); j$(a).after(e); } }); }; })();