Script Summary: Course Function
Version: 1.0.0.1
Copyright: 2009, w35l3y (http://gm.wesley.eti.br/includes/neopets)
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).
BEFORE INSTALLING
- Make sure to install Mason (Firefox plugin) first
- Once installed, right-click on Mason icon in statusbar or go to menu Tools > Mason Option...
- Click "Add..."
- Add:
Description : Training School : Course.start URL : ^http:\/\/www\.neopets\.com\/island\/process_training\.phtml$ Content-Type : (leave it blank) Function : referrer to specified site Config... : http://www.neopets.com/island/training.phtml?type=courses (click "Config..." button to type the value above)
Description : Training School : Course.pay URL : ^http:\/\/www\.neopets\.com\/island\/process_training\.phtml\?type=pay&pet_name= Content-Type : (leave it blank) Function : referrer to specified site Config... : http://www.neopets.com/island/training.phtml?type=status (click "Config..." button to type the value above)
- Click OK
- Make sure to have the new option Activated
- Click OK again
- Then you may install the script
Documentation
- Object Course.fromDocument(Document dom);
- Returns a list of pets from the Status page (if you're already have the document object)
- Void Course.status({
"onsuccess" : Void callback_function(Object params)
}); - Requests a list of pets from the Status page (if you don't have the document object)
- Void Course.start({
"type" : String course_type, // Strength, Defence, Agility, Endurance, Level
"pet" : String pet_name,
"onsuccess" : Void callback_function(Object params)
}); - Starts a course to the specified pet
- Void Course.pay({
"pet" : String pet_name,
"onsuccess" : Void callback_function(Object params)
}); - Pays the course of the specified pet
- Void Course.complete({
"pet" : String pet_name,
"onsuccess" : Void callback_function(Object params) *
}) - Removes the specified pet from the finished course
- list : list of pets *
- response : response from the GM xmlhttpRequest
- error : number of error (0 is success)
- message : some kind of message that may appear during the process
* all callback functions receives the current list of pets from the status page, except the one in Course.complete
Implementing
// @require http://userscripts.org/scripts/source/54389.user.js // @require http://userscripts.org/scripts/source/54987.user.js // @require http://userscripts.org/scripts/source/56489.user.js // @require http://userscripts.org/scripts/source/56592.user.js
Examples
WinConfig.loadDefaultCss();
Course.status({
"onsuccess" : function(params)
{
var pets = [];
for ( var key in params.list )
{
var pet = params.list[key];
pets.push([
key, // key = pet.Name
pet.Status,
pet.Level,
pet.Strength,
pet.Defence,
pet.Agility,
pet.Endurance,
pet.Time,
"\n" + (function(i)
{
var items = [];
for ( var key in i )
{
items.push([key,i[key].Name,i[key].Quantity].join("-"));
}
return items.join("\n");
})(pet.Items)
]);
}
alert(pets.join("\n"));
}
});


