GreaseMonkey April Fools Script
Posted on | March 27, 2012 | No Comments
April 1st is typically associated with playing pranks on friends and co-workers. Sometimes these can be as simple as putting a bit of paper over the sensor on their mouse, unplugging a keyboard, or changing their desktop background to a broken LCD display image.
GreaseMonkey is a Firefox add-on that allows you to customize the way a web page displays or behaves, by using small bits of JavaScript.
This April Fools Script will randomly insert a random character of the alphabet where the user is typing in Firefox (for example an email in Gmail).
Install GreaseMonkey
The first step of our prank involves installing GreaseMonkey onto the users (hereto referred to as “The Target”) computer. Keep in mind that if the user doesn’t have Firefox, then this whole prank falls apart.
Fire up Firefox and point the browser to https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ and click on the ‘Add To Firefox’ button to install GreaseMonkey into Firefox. You may need to restart the browser.
Next, click on this April Fools Script and GreaseMonkey will automatically pop up asking if you want to install it:
After clicking on ‘install’, refresh the page. The script is now up and running. In any text editable component in the browser, after 30 to 100 characters (by default -this is editable in the script) a random character will be inserted. Now sit back and watch in humour as your friend / work colleague / enemy attempts to work out why they are suddenly so rubbish at sepelling ;)
Extra Credit
If you are interested, here is the April Fools Script:
[javascript]
// ==UserScript==
// @name April Fools
// @namespace aprilFools@www.richard.parnaby-king.co.uk
// @description Randomly insert a character after several keystrokes
// @include *
// ==/UserScript==
/**
* Number of keypresses since last character insertion
* @var int count
*/
var count = 0;
/**
* After how many characters before next random character is inserted
* @var int limit
*/
var limit = 0;
/**
* The letters we want to insert
* @var string alphabet
*/
var alphabet = ‘abcdefghijklmnopqrstuvwxyz’;
/**
* Return a random number between min and max
* @param int min
* @param int max
* @return int
*/
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max – min + 1)) + min;
}
/**
* Count every keypress. If between 50 and 100 keypresses, add a random character.
* @param Event e
*/
document.onkeypress = function (e) {
count++;
limit = getRandomInt(50,100);
if (count > limit)
{
count = 0;
//get the element that is currently being typed into, then append the random character.
document.activeElement.value = document.activeElement.value + alphabet.charAt(getRandomInt(0, 25));
}
};
[/javascript]
This code is available on GitHub.
Posted By:Richard Parnaby-King