Neopets : Dice-A-Roo

By w35l3y Last update Jun 22, 2011 — Installed 11,018 times.

There are 3 previous versions of this script.

// ==UserScript==
// @name           Neopets : Dice-A-Roo
// @namespace      http://gm.wesley.eti.br/neopets
// @description    Plays Dice-a-Roo until your pet get tired.
// @author         w35l3y
// @email          w35l3y@brasnet.org
// @copyright      2011+, w35l3y (http://www.wesley.eti.br)
// @license        GNU GPL
// @homepage       http://gm.wesley.eti.br
// @version        2.0.0.0
// @language       en
// @include        http://www.neopets.com/games/dicearoo.phtml
// @include        http://www.neopets.com/games/play_dicearoo.phtml
// @resource       meta http://userscripts.org/scripts/source/28461.meta.js
// @resource       i18n http://pastebin.com/download.php?i=1F0jQb5L
// @require        http://userscripts.org/scripts/source/63808.user.js
// @require        http://userscripts.org/scripts/source/85618.user.js
// @require        http://userscripts.org/scripts/source/87940.user.js
// @require        http://userscripts.org/scripts/source/87942.user.js
// @cfu:version    version
// ==/UserScript==

/**************************************************************************

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

**************************************************************************/

(function() {	// script scope
	var config = {
		"repeat"		: GM_getValue("repeat", -1),
		"silver_dice"	: GM_getValue("silver_dice", false),
		"current"		: GM_getValue("current", 0),
		"stop_alerting"	: GM_getValue("stop_alerting", false)
	}

	GM_registerMenuCommand("[Neopets : Dice-A-Roo] Stop when silver dice is reached.", function() {
		var result = !GM_getValue("silver_dice", false);
		GM_setValue("silver_dice", result);
		alert(result ? "Activated!" : "Deactivated!");
	});

	if (config.current == config.repeat) {
		GM_setValue("current", 0);
	} else if (config.repeat == -1 || config.current < config.repeat) {
		var dform = xpath(".//form[contains(@action, 'dicearoo.phtml')]")[0];

		if (dform) {
			if (config.repeat > 0 && !/play_dicearoo\.phtml$/.test(dform.action)) {
				GM_setValue("current", ++config.current);
			}

			var is_silver = xpath(".//td[@class = 'content']//div/center/img[1][contains(@src, '/games/dice/silver')]")[0] != null;
			if (is_silver && config.silver_dice) {
				if (!config.stop_alerting) {
					GM_setValue("stop_alerting", true);
					alert("[Neopets : Dice-A-Roo]\nReached the silver dice!");
				}
			} else {
				if (config.stop_alerting) {
					GM_setValue("stop_alerting", false);
				}

				setTimeout(function() {
					dform.submit();
				}, Math.floor(1000 + 1500 * Math.random()));
			}
		}
	}
})();