Created
January 10, 2009 19:19
-
-
Save emergent/45532 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 add_d_link_on_hbm | |
// @namespace http://nitamago.org/ | |
// @include http://b.hatena.ne.jp/entry/* | |
// ==/UserScript== | |
var w = this.unsafeWindow || window; | |
w.addEventListener("load", function() { | |
var my_div_id = "gm_add_d_link"; | |
var my_atag_id = "gm_add_d_link_atag"; | |
function popupDiaryLink(evt) { | |
//alert("mouse over: " + evt.target.innerHTML); | |
var mydiv = document.getElementById(my_div_id); | |
mydiv.style.display = 'block'; | |
mydiv.style.left = evt.clientX+w.scrollX+10; | |
mydiv.style.top = evt.clientY+w.scrollY; | |
var dlink = document.getElementById(my_atag_id); | |
dlink.href = 'http://d.hatena.ne.jp/'+evt.target.innerHTML+'/'; | |
} | |
var hlink = document.getElementsByClassName("hatena-id"); | |
if (hlink.length > 0) { | |
for (var i = 0; i < hlink.length; i++) { | |
hlink[i].addEventListener('mouseover', | |
popupDiaryLink, false); | |
} | |
var mydiv = document.createElement('div'); | |
mydiv.id = my_div_id; | |
mydiv.style.position = 'absolute'; | |
mydiv.style.top = '0px'; | |
mydiv.style.left = '0px'; | |
mydiv.style.opacity = '0.8'; | |
mydiv.style.backgroundColor = '#A9A9A9'; | |
mydiv.style.display = 'none'; | |
var dlink = document.createElement('a'); | |
dlink.id = my_atag_id; | |
dlink.innerHTML = 'diary'; | |
mydiv.appendChild(dlink); | |
document.body.appendChild(mydiv); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment