Last active
November 24, 2016 12:56
-
-
Save lypanov/5a16ac8c3cb69249fcbdc976d7a30c4e 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 New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.instagram.com/* | |
// @require http://code.jquery.com/jquery-latest.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function getTop() { | |
var winTop = $(window).scrollTop(); | |
var divs = $('article'); | |
var top = divs.filter(function(_, item) { | |
return $(item).position().top <= winTop; | |
}); | |
return top; | |
} | |
$(document).keypress(function(e) { | |
if (e.charCode == 106) { | |
getTop().last().next()[0].scrollIntoView(); | |
} else if (e.charCode == 107) { | |
getTop().last().prev()[0].scrollIntoView(); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment