Neopets : Dailies To-Do

By w35l3y Last update Feb 5, 2012 — Installed 2,192 times.

There are 3 previous versions of this script.

// ==UserScript==
// @name           Neopets : Dailies To-Do
// @namespace      http://neopets.wesley.eti.br
// @description    Plays those normal dailies that you need click a button
// @author         w35l3y
// @email          w35l3y@brasnet.org
// @copyright      2012+, w35l3y (http://gm.wesley.eti.br)
// @license        GNU GPL
// @homepage       http://gm.wesley.eti.br
// @version        2.0.0.1
// @language       en
// @include        http://www.neopets.com/altador/council.phtml?*
// @include        http://www.neopets.com/bank.phtml
// @include        http://www.neopets.com/desert/fruitmachine.phtml
// @include        http://www.neopets.com/desert/shrine.phtml
// @include        http://www.neopets.com/faerieland/springs.phtml
// @include        http://www.neopets.com/island/tombola.phtml
// @include        http://www.neopets.com/jelly/jelly.phtml
// @include        http://www.neopets.com/prehistoric/omelette.phtml
// @include        http://www.neopets.com/water/fishing.phtml
// @include        http://www.neopets.com/worlds/geraptiku/tomb.phtml
// @include        http://www.neopets.com/faerieland/tdmbgpop.phtml
// @include        http://www.neopets.com/faerieland/caverns/index.phtml
// @include        http://www.neopets.com/winter/adventcalendar.phtml
// @include        http://www.neopets.com/worlds/deadlydice.phtml
// @include        http://www.neopets.com/pirates/buriedtreasure/index.phtml
// @include        http://www.neopets.com/space/strangelever.phtml
// @include        http://www.neopets.com/medieval/pickyourown_index.phtml
// @include        http://www.neopets.com/medieval/pickyourown.phtml
// @include        http://www.neopets.com/petpetpark/daily.phtml
// @include        http://www.neopets.com/pirates/anchormanagement.phtml
// @include        http://www.neopets.com/pirates/forgottenshore.phtml
// @icon           http://www.gravatar.com/avatar.php?gravatar_id=81269f79d21e612f9f307d16b09ee82b&r=PG&s=92&default=identicon
// @resource       i18n http://pastebin.com/download.php?i=ULrVTsSg
// @resource       meta http://userscripts.org/scripts/source/32041.meta.js
// @require        http://userscripts.org/scripts/source/63808.user.js
// @require        http://userscripts.org/scripts/source/56489.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
// ==/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 dailies = {
		"/bank.phtml"	: [[1, /^Collect Interest \(\d+ NP\)$/]],
		"/jelly/jelly.phtml"	: [[3, "Grab some Jelly"]],
		"/water/fishing.phtml"	: [[3, "Reel In Your Line"]],
		"/desert/shrine.phtml"	: [[3, "Approach the Shrine"]],
		"/island/tombola.phtml"	: [[3, "Play Tombola!"]],
		"/altador/council.phtml"	: [[3, "Collect your gift"]],
		"/petpetpark/daily.phtml"	: [[2, ".//form[input[@name = 'go'] and contains(@action, '/petpetpark/daily.phtml')]"]],
		"/worlds/deadlydice.phtml"	: [[3, "Roll the dice..."], [1, /^Sure let\'s play for \d+ levels!$/]],
		"/faerieland/springs.phtml"	: [[3, "Heal my Pets"]],
//		"/space/strangelever.phtml"	: [[3, "Pull the Lever Anyway"]],
		"/desert/fruitmachine.phtml"	: [[3, "Spin the Wheel!!!"]],
		"/faerieland/tdmbgpop.phtml"	: [[3, "Talk to the Plushie"]],
		"/prehistoric/omelette.phtml"	: [[3, "Grab some Omelette"]],
		"/medieval/pickyourown.phtml"	: [[3, "Collect Berries and Leave Farm"]],
		"/worlds/geraptiku/tomb.phtml"	: [[3, "Open the stone door to the Deserted Tomb..."], [3, "Continue on, at the risk of never returning.  There's no turning back."]],
		"/faerieland/caverns/index.phtml"	: [[3, function () {
			return (Math.random() > 0.85 ? "Right" : "Left");
		}], [3, "Enter"], [3, "Click to see what you've found"]],
//		"/medieval/pickyourown_index.phtml"	: [[1, /^Click to Play!\s+Only \d+ NP!$/]],
//		"/pirates/buriedtreasure/index.phtml"	: [[1, /^Click to Play!\s+Only \d+ NP a game!$/]],
		"/pirates/anchormanagement.phtml" : [[2, "id('form-fire-cannon')"]],
		"/pirates/forgottenshore.phtml" : [[2, ".//a[contains(@href, '?confirm=1&_ref_ck=')]", function (a) {
			a.click();
		}]],
	};

	if (location.pathname in dailies) {
		a:for each (var btn in dailies[location.pathname]) {
			var txt = (btn[1] instanceof Function ? btn[1]() : btn[1]);
			switch (btn[0]) {
				case 1:	// RegExp + input[@value]
				for each (var inpt in Array.prototype.slice.apply(document.getElementsByTagName("INPUT"))) {
					if (txt.test(inpt.value.replace(/(\d),/g, "$1"))) {
						inpt.form.submit();
						break a;
					}
				}
				break;
				case 2:	// xpath + form/function
				var f = xpath(txt)[0];
				if (f) {
					if (btn[2] instanceof Function) {
						btn[2](f);
					} else {
						f.submit();
					}
					break a;
				}
				break;
				case 3:	// xpath + input[@value]
				var f = xpath('.//input[@value = "' + txt.replace(/"/g, '\\"') + '"][1]')[0];
				if (f) {
					f.form.submit();
					break a;
				}
				break;
			}
		}
	}
}());