Created
March 9, 2010 14:55
-
-
Save taizooo/326660 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 gyazzzzzz_skid_slide_show.user.js | |
// @namespace http://taizooo.tumblr.com/ | |
// @include http://gyazz.com/*/slide?jk | |
// ==/UserScript== | |
// http://gyazz.com/taizooo/goodevening/slide | |
// j : next photo, k : prev photo | |
with(unsafeWindow){ | |
var display = function(next){ | |
// cur += next ? 1 : -1 | |
cur = (next == 'init')? 0 : (next ? cur + 1 : cur - 1) | |
if(cur >= image.length) | |
cur = 0; | |
else if(cur < 0) | |
cur = image.length -1; | |
photo.src = image[cur]; | |
c.style.top = top[cur]; | |
c.style.left = left[cur]; | |
c.style.width = width[cur]; | |
c.style.fontSize = '20pt'; | |
c.style.color = color[cur]; | |
c.innerHTML = comment[cur]; | |
} | |
display('init'); | |
image.forEach(function(s){ | |
(new window.Image()).src = s; | |
}) | |
} | |
var display = unsafeWindow.display; | |
var KEY_NEXT = charCode('J'); | |
var KEY_PREVIOUS = charCode('K'); | |
window.addEventListener('keydown', onKeyDown, false); | |
function onKeyDown(e){ | |
if(e.ctrlKey || e.altKey) | |
return; | |
switch(e.keyCode){ | |
case KEY_NEXT: | |
display(true); | |
return; | |
case KEY_PREVIOUS: | |
display(false); | |
return; | |
} | |
} | |
function charCode(c){ | |
return c.charCodeAt(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment