Skip to content

Instantly share code, notes, and snippets.

@IamTechknow
Created August 5, 2017 05:18
Show Gist options
  • Save IamTechknow/a1c82f6c8dd9bdebb0d03c5ab1314d4c to your computer and use it in GitHub Desktop.
Save IamTechknow/a1c82f6c8dd9bdebb0d03c5ab1314d4c to your computer and use it in GitHub Desktop.
Dice-A-Roo Hotkeys
// ==UserScript==
// @name Dice-A-Roo Hotkeys
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Dice-A-Roo Hotkeys
// @author iamtechknow
// @match http://www.neopets.com/games/play_dicearoo.phtml*
// @match http://www.neopets.com/games/dicearoo.phtml*
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
const SPACEBAR = 32;
var $ = window.jQuery;
document.onkeypress = function (e) {
e = e || window.event;
var charCode = e.charCode || e.keyCode,
character = String.fromCharCode(charCode);
if(charCode === SPACEBAR) {
var lets_play = $("input[value=\"Lets Play! (Costs 5 NP)\"]"), roll = $("input[value=\"Roll Again\"]"), press_me = $("input[value=\"Press Me\"]"), play = $("input[value=\"Play Dice-A-Roo\"]");
e.preventDefault();
if(lets_play.length > 0)
lets_play.click();
else if(press_me.length > 0)
press_me.click();
else if(play.length > 0)
play.click();
else if(roll.length > 0)
roll.click();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment