Neopets : Shop Wizard

By w35l3y Last update Nov 10, 2008 — Installed 2,742 times. Daily Installs: 7, 6, 9, 5, 13, 7, 7, 9, 1, 5, 3, 9, 5, 4, 8, 9, 1, 1, 2, 6, 11, 2, 3, 8, 0, 3, 8, 3, 13, 4, 4, 4

There are 6 previous versions of this script.

// ==UserScript==
// @name           Neopets : Shop Wizard
// @namespace      http://gm.wesley.eti.br/neopets
// @description    Allows you to use the Shop Wizard even if you are in a Faerie Quest
// @include        http://www.neopets.com/market.phtml?type=wizard
// @include        http://www.neopets.com/market.phtml
// @require        http://www.wesley.eti.br/includes/js/php.js?v=1
// @require        http://www.wesley.eti.br/includes/js/php2js.js?v=1
// @require        http://gm.wesley.eti.br/gm_default.js?v=1
// @language       en
// @author         w35l3y
// @email          w35l3y@brasnet.org
// @version        1.1.3
// @copyright      w35l3y 2008
// @license        GNU GPL
// @homepage       http://www.wesley.eti.br
// ==/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/>.

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

checkForUpdate({
	'file':'http://userscripts.org/scripts/source/33958.user.js',
	'name':'Neopets : Shop Wizard',
	'namespace':'http://gm.wesley.eti.br/neopets',
	'version':'1.1.3'
});

(function(){	// script scope
	var user = {
		interval:GM_getValue('interval',	'500-1000').split('-').array_map(parseInt,array_fill(0,2,10)),
		fill:GM_getValue('fill',		true)
	};

	var sw = xpath("string(//table/tbody/tr/td/img[contains(@src,'shopwizard')]/@src)");

	if (!sw)
	{
		var shopWizard = (<r><![CDATA[
			<b>Shop Wizard</b>
			<br /><br />
			Alakazam!!! It&#039;s the Shop Wizard!  The Shop Wizard is your friendly guide to online comparison shopping.  Type in what you want to buy and he will search through all the shops in the market to find you the best prices. (He searches a different section of the market each time to get more results!)
			<br /><br />
			<div class="contentModule" style="height: 100%">
				<table cellpadding="3" cellspacing="0" border="0" class="contentModuleTable">
					<tr><td class="contentModuleHeaderAlt"> What are you looking for?</td></tr>
					<tr>
						<td align="left" valign="top" class="contentModuleContent">
						<form action="market.phtml" method="post">
							<div align="center">
								<table cellpadding="4" cellspacing="0" border="0">
								    	<tr>
								    		<td align="center" valign="top"><img src="http://images.neopets.com/shopkeepers/shopwizard.gif" width="150" height="150" alt="" border="0" align="left" /></td>
								    		<td align="left" valign="top">
											<input type="hidden" name="type" value="process_wizard" />
											<input type="hidden" name="feedset" id="feedset" value="0" />
											<table align="center" cellpadding="4" cellspacing="1" border="0">
												<tr>
													<td valign="middle" style="background-color: #EFEFEF;"><b>Search Text</b></td>
													<td valign="top"><input type="text" name="shopwizard" value="" size="50" maxlength="60" style="width: 300px" /></td>
												</tr>
												<tr>
													<td valign="top" style="background-color: #EFEFEF;"><b>Area</b></td>
													<td valign="top"><input type="radio" name="table" value="shop" checked="checked" /> Shop<br />
													<input type="radio" name="table" value="gallery" /> Gallery</td>
												</tr>
												<tr>
													<td valign="middle" style="background-color: #EFEFEF;"><b>Search Items</b></td>
													<td valign="top"><select name="criteria"><option selected="selected" value="containing">containing my phrase</option><option value="exact">identical to my phrase</option></select></td>
												</tr>
												<tr>
													<td valign="middle" style="background-color: #EFEFEF;"<b>Min Price</b></td>
													<td valign="top"><input type="text" name="min_price" size="6" maxlength="6" value="0" /> <b>NP</b></td>
												</tr>
												<tr>
													<td valign="middle" style="background-color: #EFEFEF;"><b>Max Price</b></td>
													<td valign="top"><input type="text" name="max_price" size="6" maxlength="6" value="99999" /> <b>NP</b></td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</div>
							<div align="center" style="background-color: #EFEFEF; padding: 4px;"><input type="submit" value="Search" /></div>
						</form>
						<!--/<img src="chrome://greasemonkey/content/status_on.gif" onload="var a=document.getElementById('feedset'); a.value='0';" style="display:none" />/-->
						</td>
					</tr>
				</table>
			</div>
			<br /><br />
		]]></r>).toString();

		var faerieQuest = xpath("id('content')/table/tbody/tr/td[2]/center")[0];
		var newDiv = document.createElement("div");
		newDiv.innerHTML = shopWizard;
		faerieQuest.parentNode.insertBefore(newDiv,faerieQuest);

		if (user.fill)
		{
			setTimeout(function()
			{
				resourceText("http://www.neopets.com/quests.phtml", function(e)
				{
					var input = xpath("//form/div[1]/table/tbody/tr/td[2]/table/tbody/tr[1]/td[2]/input")[0];
					input.value = e.responseText.match(/(?:\/\w+ |\s{2}|(?:the|ho) )([\w ]+)[!.][\x22\x27]>/)[1];
				});
			},randomValue(user.interval));
		}
	}
})();