Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Test : Food Club
- // @namespace http://gm.wesley.eti.br
- // @author w35l3y
- // @email [email protected]
- // @copyright 2016+, w35l3y (http://gm.wesley.eti.br)
- // @license GNU GPL
- // @homepage http://gm.wesley.eti.br
- // @version 1.0.0
- // @language en
- // @include http://www.neopets.com/pirates/foodclub.phtml?type=bet
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_xmlhttpRequest
- // @grant GM_getResourceText
- // @resource foodclubJson https://gist.github.com/w35l3y/fab231758eb0991f36a0/raw/foodclub.json
- // @require https://github.com/w35l3y/localStorageDB/raw/master/localstoragedb.js
- // @require https://github.com/w35l3y/userscripts/raw/master/includes/Includes_XPath/63808.user.js
- // @require https://github.com/w35l3y/userscripts/raw/master/includes/Includes_HttpRequest/56489.user.js
- // @require https://github.com/w35l3y/userscripts/raw/master/includes/Includes_Neopets_%5BBETA%5D/main.user.js
- // @require https://github.com/w35l3y/userscripts/raw/master/scripts/../../../raw/master/includes/Includes_Neopets_FoodClub/main.user.js?1
- // ==/UserScript==
- var np = new Neopets(document),
- fc = new FoodClub(np);
- fc.odds(function (o) { // could be replaced by fc.parse("bet") once the @include is the same of what fc.odds(cb) does
- var r = o.response;
- if (r.max_bet) { // check whether the food club is open
- fc.get(function (o) { // retrieve the bets of a custom page
- (function recursive (list) { // recursively iterate through the list of bets
- if (list.length) {
- var bet = list[0];
- list.shift();
- if (confirm("Place a bet?\n\n" + r.max_bet + " NP\t" + bet.odds + ":1\t" + (r.max_bet * bet.odds) + " NP\n\n" + bet.arenas.map(function (b) {
- return b.name + "\t" + b.pirate.name;
- }).join("\n"))) { // confirm the current bet
- try {
- fc.bet(function (o) {
- console.log(o);
- recursive(list);
- }, {
- check : r.arenas, // check whether the bets are possible
- value : r.max_bet, // value of the bets
- arenas : bet.arenas, // bets (may contain informations about arena, pirate and odds)
- odds : bet.odds, // odds - optional
- });
- } catch (e) {
- recursive(list);
- }
- } else {
- recursive(list);
- }
- } else {
- alert("Complete");
- }
- }(o.response.list.sort(function (a, b) { // sort and filter the list of bets
- if (a.round == b.round) {
- return 0;
- }
- return (a.round > b.round?-1:1);
- }).slice(0, 10)));
- }, {
- url : "http://www.neopets.com/~nopunchameplz" // page containing the bets
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment