Script Summary: Shop Function
Version: 2.0.0.0
Copyright: 2009+, w35l3y (http://gm.wesley.eti.br)
License: GNU GPL
FOR SCRIPTERS/PROGRAMMERS only
If you are neither scripter nor programmer, you're discouraged to install this script directly.But if you are and intend to use this script, please warn your users to install Mason (Firefox plugin) and follow the steps below (BEFORE INSTALLING section).
Implementing
// @require http://userscripts.org/scripts/source/63808.user.js // @require http://userscripts.org/scripts/source/56489.user.js // @require http://userscripts.org/scripts/source/56562.user.js
Examples
Shop.list({
"link" : "...", // /browseshop.phtml
"onsuccess" : function(params)
{
var items = [];
for ( var ai = 0 , at = params.list.length ; ai < at ; ++ai )
{
var item = params.list[ai];
items.push([
item.Id,
// item.Link,
// item.Image,
item.Name,
// item.Description,
item.Quantity,
item.Price
].join("\t"));
}
alert(items.join("\n"));
}
});
var item = "plain omelette";
Wizard.find({ // <--- http://userscripts.org/scripts/show/56503
"text" : item,
"onsuccess" : function(params)
{
// wizard : first link exists
if (params.list[0])
setTimeout(Shop.list, 1000, {
"link" : params.list[0].Link, // /browseshop.phtml
"onsuccess" : function(params)
{
// shop : first link exists
// (first link should be the searched item, but it is not guaranteed)
if (params.list[0] && params.text.toLowerCase() == params.list[0].Name.toLowerCase())
setTimeout(Shop.buy, 1000, {
"link" : params.list[0].Link // /buy_item.phtml
});
else
alert(params.text + " was sold out!");
},
"parameters" : { "text" : params.text }
});
},
"parameters" : { "text" : item }
});Shop.buy({
"link" : "...", // /buy_item.phtml
"onsuccess" : function(params)
{
if (params.error)
alert(params.message && params.message.textContent || "Unknown error");
}
});


