Created
December 6, 2008 16:05
-
-
Save cherenkov/32899 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 hatener_script | |
// @namespace http://d.hatena.ne.jp/Cherenkov/ | |
// @description userscript for hatener. | |
// @include http://*.hatena.ne.jp/* | |
// ==/UserScript== | |
var url; | |
if (/^http\:\/\/d\.hatena\.ne\.jp/.test(location.href)) {url = 'd.hatena.ne.jp'} | |
else if (/^http\:\/\/s\.hatena\.ne\.jp/.test(location.href)) {url = 's.hatena.ne.jp'} | |
else if (/^http\:\/\/b\.hatena\.ne\.jp/.test(location.href)) {url = 'b.hatena.ne.jp'} | |
//else if (/ /.test(location.href)) {url = ' '} | |
//else if (/ /.test(location.href)) {url = ' '} | |
// http://*.hatena.ne.jp/*なページで実行したいものはswitchの外に。 | |
// @name hatena_star_link_diary | |
// @include http://*.hatena.ne.jp/* | |
// @description スターのリンクをユーザーのダイアリーに換える。 | |
location.href = "javascript:if(window.Hatena&&Hatena.Star){Hatena.Star.User.prototype.userPage=function(){return 'http://d.hatena.ne.jp/'+this.name+'/'}};void(0)"; | |
switch (url){ | |
case 'd.hatena.ne.jp': | |
// @name hatena_diary_confirm | |
// @include http://d.hatena.ne.jp/*/edit | |
// @include http://d.hatena.ne.jp/*/draft?epoch=* | |
// @description ダイアリー編集ページからリンクに飛ぶときに確認する。 | |
if(/.+?\/edit/.test(location.href) || /.+?\/draft\?epoch\=/.test(location.href)){ | |
var link = document.evaluate("//a[not(@target='_blank')]", document, null, 7, null); | |
for(var i=0;i<link.snapshotLength;i++){ | |
link.snapshotItem(i).setAttribute("onclick","return confirm('ページ遷移しますがよろしいですか');"); | |
} | |
} | |
break; | |
case 's.hatena.ne.jp': | |
// @include http://s.hatena.ne.jp/* | |
// @description はてなスターのインデックスページのユーザアイコンのリンクをダイアリーに換える。 | |
var profileImage = document.evaluate('//img[@class="profile-image"]', document, null, 7, null); | |
for(var i=0;i<profileImage.snapshotLength;i++){ | |
profileImage.snapshotItem(i).parentNode.href = profileImage.snapshotItem(i).parentNode.href.replace('s', 'd'); | |
} | |
break; | |
case 'b.hatena.ne.jp': | |
//if(/b\.hatena\.ne\.jp\/entry/.test(location.href)){ | |
// @name hateb_link_user_diary2 | |
// @include http://b.hatena.ne.jp/entry/* | |
// @description はてブのエントリーページにあるユーザー名のリンクをダイアリーに換える。 | |
var icons = document.evaluate('//a[@class="username"][../../@id="bookmarked_user"]', document, null, 7, null); | |
for(var i=0;i<icons.snapshotLength;i++){ | |
icons.snapshotItem(i).href = icons.snapshotItem(i).previousSibling.previousSibling.href.replace('b','d'); | |
} | |
break; | |
} //switch | |
/* | |
case '': | |
break; | |
case '': | |
break; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment