Created
January 27, 2010 04:05
-
-
Save hasegawayosuke/287525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name fix-perlcodesample-date | |
// @namespace http://d.hatena.ne.jp/perlcodesample/ | |
// @include http://d.hatena.ne.jp/perlcodesample/* | |
// ==/UserScript== | |
(function(){ | |
GM_xmlhttpRequest( { | |
method : "get", | |
url : "http://d.hatena.ne.jp/perlcodesample/rss", | |
onload : function( res ){ | |
var xml = (new DOMParser).parseFromString( res.responseText, "application/xml" ); | |
var items = []; | |
var rssitems = xml.getElementsByTagName( "item" ); | |
for( var i = 0; i < rssitems.length; i++ ){ | |
var url = rssitems[ i ].getElementsByTagName( "link" )[ 0 ].textContent; | |
var d = rssitems[ i ].getElementsByTagName( "dc:date" )[ 0 ].textContent; | |
d = new Date( d.replace( /\-/g, "/" ).replace( /\+/, " +" ).replace( /T/, " " ) ); | |
items.push( { url : url.replace( /^http:\/\/d\.hatena\.ne\.jp/, "" ), date : d } ); | |
} | |
for( i = 0; i < items.length; i++ ){ | |
var elms = document.evaluate( "//h3[a/@href='" + items[ i ].url + "']", document.body, null, 7, null ); | |
if( !elms.snapshotLength ) continue; | |
var div = document.createElement( 'div' ); | |
div.innerHTML = "\u51FA\u5178\uFF1A" + items[ i ].date.toLocaleString() + "<br>" + | |
"\uFF08\u8A18\u4E8B\u306F\u57F7\u7B46\u6642\u306E\u60C5\u5831\u306B\u57FA\u3065\u3044\u3066\u304A\u308A" + | |
"\uFF0C\u73FE\u5728\u3067\u306F\u7570\u306A\u308B\u5834\u5408\u304C\u3042\u308A\u307E\u3059\uFF09" | |
div.style.border = 'solid 2px red'; | |
div.style.backgroundColor = 'lightpink'; | |
elms.snapshotItem( 0 ).parentNode.insertBefore( div, elms.snapshotItem( 0 ).nextSibling ); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment