NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name VK Pikabu-like Navigation
// @version 0.1
// @description VK Pikabu-like Navigation. A/D/Z/C/R.
// @author Efog
// @match https://vk.com/*
// @match http://vk.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var current_address = null;
var current_post = null;
var feed_rows = null;
document.addEventListener('keydown', function(event) {
if (document.activeElement.nodeName != 'BODY') return;
if (current_post === null || current_address != location.href) {
feed_rows = document.querySelector('#feed_rows');
if (feed_rows === null) feed_rows = document.querySelector('#page_wall_posts');
current_post = feed_rows.children[0];
document.body.scrollTop = current_post.offsetTop;
current_address = location.href;
return;
}
var toScroll = true;
if (event.keyCode == 65) { //A
if (!current_post.previousElementSibling.classList.contains('feed_row') && !current_post.previousElementSibling.classList.contains('post')) return;
current_post = current_post.previousSibling;
} else if (event.keyCode == 68) { //D
if (!current_post.nextElementSibling.classList.contains('feed_row') && !current_post.nextElementSibling.classList.contains('post')) return;
current_post = current_post.nextElementSibling;
} else if (event.keyCode == 90) { //Z
document.body.scrollTop -= 45;
toScroll = false;
} else if (event.keyCode == 67) { //C
document.body.scrollTop += 45;
toScroll = false;
} else if (event.keyCode == 82) { //R
current_post.querySelector('.wrh_text').click();
} else return;
if (toScroll) document.body.scrollTop = current_post.offsetTop;
current_address = location.href;
});
})();