Created
June 14, 2013 18:48
-
-
Save mallowlabs/5784261 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 nicovideo thumnail popup | |
// @author mallowlabs | |
// @version 0.0.2 | |
// @namespace http://mallowlabs.s206.xrea.com/ | |
// @updated 2008-05-19 | |
// @published 2007-05-22 | |
// @license public domain | |
// @description Show popup of thumnail in nicovideo.jp | |
// @include http://www.nicovideo.jp/* | |
// ==/UserScript== | |
(function () { | |
function onMouseOut(e) { | |
var divPopup = document.getElementById('thum_popup') | |
divPopup.innerHTML = "Could not get thumnail..." | |
divPopup.style.visibility = "hidden" | |
} | |
function onMouseOver(e) { | |
var divPopup = document.getElementById('thum_popup') | |
var refUrl = e.target.getAttribute('href') | |
if (refUrl == null) { | |
// "e" may be img tag | |
refUrl = e.target.parentNode.getAttribute('href') | |
} | |
var strs = refUrl.split("/") | |
divPopup.innerHTML = "<iframe src=\"http://ext.nicovideo.jp/thumb/" | |
+ strs[strs.length-1] | |
+ "\" width=\"100%\" height=\"198\" scrolling=\"no\" border=\"0\" frameborder=\"0\"></iframe>" | |
var st = divPopup.style | |
st.left = e.pageX + 10 + "px" | |
st.top = e.pageY - 150 + "px" | |
st.visibility = "visible" | |
} | |
function addEvent2AllATags(){ | |
var aTags = document.getElementsByTagName('a') | |
for (var i = 0, l = aTags.length; i < l; i++) { | |
var refUrl = aTags.item(i).getAttribute('href') | |
if (refUrl != null && refUrl.match(/watch\/\d*/)) { | |
aTags.item(i).addEventListener('mouseover', onMouseOver, false) | |
aTags.item(i).addEventListener('mouseout', onMouseOut, false) | |
} | |
} | |
} | |
function createPopupDiv() { | |
var popup = document.createElement('div') | |
var st = popup.style | |
st.visibility = 'hidden' | |
st.zindex = "99" | |
st.border = '1px solid #CCC' | |
st.position = 'absolute' | |
st.width = '318' + "px" | |
popup.id = "thum_popup" | |
document.body.appendChild(popup) | |
} | |
createPopupDiv(); | |
addEvent2AllATags() | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment