Last active
August 29, 2015 13:55
-
-
Save eyy/8696014 to your computer and use it in GitHub Desktop.
Bookmarklet: Jump to next image (J)
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
javascript:(function() { var i = 0; function nextImg() { var imgs = document.querySelectorAll('img'), el; while (i < imgs.length) { el = imgs[i]; i++; if (el.getBoundingClientRect().top > 0) { return el.scrollIntoView(); } } i = 0; } document.addEventListener('keypress', function(e) { var key = String.fromCharCode(e.keyCode || e.which); if (key == 'j') nextImg(); }); nextImg(); })(); |
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
(function() { | |
var i = 0; | |
function nextImg() { | |
var imgs = document.querySelectorAll('img'), | |
el; | |
while (i < imgs.length) { | |
el = imgs[i]; | |
i++; | |
if (el.getBoundingClientRect().top > 0) { | |
return el.scrollIntoView(); | |
} | |
} | |
i = 0; | |
} | |
document.addEventListener('keypress', function(e) { | |
var key = String.fromCharCode(e.keyCode || e.which); | |
if (key == 'j') | |
nextImg(); | |
}); | |
nextImg(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment