Skip to content

Instantly share code, notes, and snippets.

@lypanov
Last active November 24, 2016 12:56
Show Gist options
  • Save lypanov/5a16ac8c3cb69249fcbdc976d7a30c4e to your computer and use it in GitHub Desktop.
Save lypanov/5a16ac8c3cb69249fcbdc976d7a30c4e to your computer and use it in GitHub Desktop.
// ==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