MyMiniCityを便利にするGrasemonkeyScriptの微修正

で紹介されているhttp://blog.fulltext-search.biz/articles/2007/12/19/greasemonkey-myminicityが便利だったので使っていたんですが、ニックネームと町名が一致しない人も居るので、そこをちょっといじって、あらかじめ登録されている人については変換する様にしました。ニックネームと町名の対応表は適宜書き換えてください。

// ==UserScript==
// @name          minicityauthorLink+alpha+alpha
// @author        woinary
// @namespace     http://awagumo.net/
// @description   Auto link on MyMiniCity
// @released      2007-12-20 11:03:00
// @include       http://*.myminicity.com/
// ==/UserScript==

/*
 * user dictionary
 * "nickname":"town name",
*/

user_dic = { 
    "nickname" : "town-name",
};


/*
 * Based on minicityauthorLink
 * http://blog.webcreativepark.net/2007/12/19-184341.html
 * http://blog.fulltext-search.biz/articles/2007/12/19/greasemonkey-myminicity
 * thanks to
 * http://blog.grayash.com/archives/577
*/
(function() {
    var objAll = document.getElementsByTagName("*");
    var td = (new Date()).getTimezoneOffset() / 60 + 1;
    for (var i=0,len=objAll.length; i<len; i++) {
        if(objAll[i].className=="author"){
            var author = objAll[i].textContent.replace(/: $/, "");
            var url = author;
            if(user_dic[author] != undefined) {
                url = user_dic[author];
            }
            url = url.replace(/[^a-zA-Z0-9\-]/g,"");
            objAll[i].innerHTML = "<a href='http://"+url+".myminicity.com/'>"+author+"</a>: ";
        } else if(objAll[i].className=="date"){
            var times = objAll[i].textContent.replace(/[\[\]]/g,"")
            if(times.indexOf(':') != -1) {
                times = times.split(':');
                times[0] = (parseInt(times[0], 10) - td) % 24;
                if(times[0] < 10) times[0] = '0' + times[0];
                while ( objAll[i].firstChild )
                    objAll[i].removeChild( objAll[i].firstChild );
                objAll[i].appendChild(document.createTextNode(times[0] + ":" + times[1]));
            }
        }
    }
})();

このスクリプトの権利なんて主張しませんので、ご自由に改造して使ってください(再配布する場合には、@authorの所をご自分の名前に変えてくださいね)。気に入った方は我が町へお越しください。

あとで昨日以前の書込の日付表記をアメリカンな「日/月」から、日本人向けに「月/日」に直す様にしたい。誰かやっておいていただけるとうれしいです。