del.icio.us のコメント内にある URL をリンクにする
// ==UserScript== // @name del.icio.us comments replace URL // @namespace http://opera.higeorange.com/ // @include http://del.icio.us/* // ==/UserScript== (function() { var comments = document.evaluate( '//p[@class="notes"]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); var notes; while(notes = comments.iterateNext()) { notes.innerHTML = notes.innerHTML.replace( /(https?|ftp)(:\/\/[-_.!~*\'a-zA-Z0-9;\/?:\@&=+\$,%#]+)/g, '<a href="$&">$&</a>' ); } })();
イテレータ使った方が短くかけるな < XPathResult
うゎーん。Firefox でエラーでるよー。調査中
上でエラーが出る場合はこちらを
(function() { var comments = document.evaluate( '//p[@class="notes"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); for(var i=0,len=comments.snapshotLength;i<len;i++) { comments.snapshotItem(i).innerHTML = comments.snapshotItem(i).innerHTML.replace( /(https?|ftp)(:\/\/[-_.!~*\'a-zA-Z0-9;\/?:\@&=+\$,%#]+)/g, '<a href="$&">$&</a>' ); } })();