Email filler

Fills your email on input and text fields

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        Email filler
// @namespace   https://github.com/Farow/userscripts
// @description Fills your email on input and text fields
// @include     *
// @version     1.0.0
// @grant       GM_setValue
// @grant       GM_getValue
// ==/UserScript==

const emails = [
	'[email protected]',
	'[email protected]',
];

document.addEventListener('keypress', keypress);

function keypress (event) {
	if (event.code != 'KeyE') {
		return;
	}

	if (!event.ctrlKey) {
		return;
	}

	if (event.target.tagName != 'INPUT' && event.target.tagName != 'TEXTAREA') {
		return;
	}

	fill_email(event.target);
	event.preventDefault();
}

function fill_email (target) {
	const email = emails.shift();

	/* save the selection as it gets reset when changing the input value */
	const selection_start = target.selectionStart;

	target.value = (
		/* before selection */
		target.value.substring(0, selection_start) +

		/* replace selection */
		email +

		/* after selection */
		target.value.substring(target.selectionEnd)
	);

	target.setSelectionRange(selection_start, selection_start + email.length);
	emails.push(email);
}