Vimfari

try to take over the world!

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Vimfari
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
	'use strict';

	// Settings
	var setings = {
		'j': 'scrollDown',
		'k': 'scrollUp',
		'gg': 'scrollToTop',
		'G': 'scrollToBottom',
		'u': 'scrollPageUp',
		'd': 'scrollPageDown'
	};

	// Methods
	window.scrollDown = function () {
		var yPos = $(window).scrollTop();
		$('html, body').animate({ scrollTop: yPos + 300 }, 150);
	};
	window.scrollUp = function () {
		var yPos = $(window).scrollTop();
		$('html, body').animate({ scrollTop: yPos - 300 }, 150);
	};
	window.scrollToTop = function () {
		$("html, body").animate({ scrollTop: 0 }, 200);
	};
	window.scrollToBottom = function () {
		$("html, body").animate({ scrollTop: $(document).height() }, 200);
	};
	window.scrollPageDown = function () {
		var yPos = $(window).scrollTop();
		$("html, body").animate({ scrollTop: yPos + $(window).height() }, 150);
	};
	window.scrollPageUp = function () {
		var yPos = $(window).scrollTop();
		$("html, body").animate({ scrollTop: yPos - $(window).height() }, 150);
	};

	// Remove AutoFocus at the first time
	$('input').blur();


	// Controllers
	var timing = 500;
	var lastKeypressTime = 0;
	var prevKey = '';

	$('html').keypress(function(e) {
		var unicode = e.keyCode? e.keyCode : e.charCode;
		var key = String.fromCharCode(unicode);

		// Detect the double key press
		var thisKeypressTime = new Date();
		if ( thisKeypressTime - lastKeypressTime <= timing ) {
			key = prevKey + key;
			thisKeypressTime = 0;
		}
		lastKeypressTime = thisKeypressTime;

		var fn = window[setings[key]];

		if(typeof fn === 'function') {
			fn();
		}

		console.log(key + " : " + unicode);
		prevKey = key;
	});

})();