Created
June 22, 2010 10:28
-
-
Save todesking/448292 to your computer and use it in GitHub Desktop.
add external link to atnd user
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 atnd-user-link | |
// @namespace http://d.hatena.ne.jp/gnarl/ | |
// @include http://atnd.org/events/* | |
// ==/UserScript== | |
(function() { | |
function external_link_of(icon_url,user_name) { | |
if(/wwwhatena/.exec(icon_url)) { | |
return 'http://www.hatena.ne.jp/'+user_name; | |
} | |
} | |
function google_search_url(user_name) { | |
return 'http://google.co.jp/search?q='+encodeURIComponent(user_name); | |
} | |
$('.member_name>li').each(function(i,li) { | |
var icon_element=$('img',li)[0]; | |
var icon_url=$(icon_element).attr('src'); | |
var user_name=$('a',li).text(); | |
var user_page_url=external_link_of(icon_url,user_name); | |
var search_url=google_search_url(user_name); | |
link_to_search=$('<a>').attr('href',search_url).text('?'); | |
$('a',li).eq(0).after(link_to_search); | |
$('a',li).eq(0).after(document.createTextNode(' ')); | |
if(user_page_url) { | |
var link_to_user_page=$('<a>').attr('href',user_page_url); | |
$(li).prepend(link_to_user_page); | |
li.removeChild(icon_element); | |
link_to_user_page.append(icon_element); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment