-
-
Save diceroll123/04fb835539530038795e to your computer and use it in GitHub Desktop.
Makes Food Club Bets into a reasonable reddit-formatted table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Food Club Bets to Reddit Table | |
// @namespace diceroll123 | |
// @match https://www.neopets.com/pirates/foodclub.phtml?type=current_bets | |
// @copyright diceroll123 2014+ | |
// ==/UserScript== | |
$("table:contains('Current Bets')").last().after("<button id='reddit'>Show Reddit Table</button>"); | |
$("#reddit").on('click', function() { | |
$(this).fadeOut(); | |
getBets(); | |
}); | |
function getBet(html, odds) { | |
function getPirate(bet) { | |
var pirates = { | |
"Federismo Corvallio": 'Federismo', | |
"Bonnie Pip Culliford": 'Bonnie', | |
"Puffo the Waister": 'Puffo', | |
"Orvinn the First Mate": 'Orvinn', | |
"Scurvy Dan the Blade": 'Dan', | |
"Young Sproggie": 'Sproggie', | |
"Squire Venable": 'Squire', | |
"Ol' Stripey": 'Stripey', | |
"Captain Crossblades": 'Crossblades', | |
"Franchisco Corvallio": 'Franchisco', | |
"Admiral Blackbeard": 'Blackbeard', | |
"Gooblah the Grarrl": 'Gooblah', | |
"Lucky McKyriggan": 'Lucky', | |
"Fairfax the Deckhand": 'Fairfax', | |
"Sir Edmund Ogletree": 'Edmund', | |
"The Tailhook Kid": 'Tailhook', | |
"Stuff-A-Roo": 'Stuff', | |
"Buck Cutlass": 'Buck', | |
"Peg Leg Percival": 'Peg Leg', | |
"Ned the Skipper": 'Ned' | |
}; | |
for(var key in pirates) { | |
if(bet.indexOf(key) != -1) { | |
return pirates[key]; | |
} | |
} | |
} | |
var shipwreck = "", | |
lagoon = "", | |
treasure = "", | |
hidden = "", | |
harpoon = ""; | |
// individual bets | |
bets = html.split("<br>"); | |
$(bets).each(function(k,v) { | |
if(v.indexOf("Shipwreck") != -1) { | |
shipwreck = getPirate(v); | |
} else if(v.indexOf("Lagoon") != -1) { | |
lagoon = getPirate(v); | |
} else if(v.indexOf("Treasure") != -1) { | |
treasure = getPirate(v); | |
} else if(v.indexOf("Hidden") != -1) { | |
hidden = getPirate(v); | |
} else if(v.indexOf("Harpoon") != -1) { | |
harpoon = getPirate(v); | |
} | |
}); | |
return "|" + shipwreck + "|" + lagoon + "|" + treasure + "|" + hidden + "|" + harpoon + "|" + odds + "\n"; | |
} | |
function getBets() { | |
table = $("table:contains('Current Bets')").last(); | |
round = table.find("tr[bgcolor='white']").first().children().first().text(); | |
bet_table = round + "|Shipwreck|Lagoon|Treasure|Hidden|Harpoon|Odds\n:-:|-|-|-|-|-|-:\n"; | |
table_bets = []; | |
table.find("tr[bgcolor='white']").each(function(k,v) { | |
if(k+1 <= 10) { | |
table_bets.push(getBet($(v).children().eq(1).html(), $(v).children().eq(3).text())); | |
} | |
}); | |
table_bets.sort(); | |
num = 1; | |
for(var bet in table_bets) { | |
bet_table += num + table_bets[bet]; | |
num++; | |
} | |
textarea = $('<br><textarea id="table" style="height: 196px; width: 491px;"/>'); | |
$("#reddit").after(textarea); | |
$("#table").val(bet_table); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to replace the 'http' with 'https' or Tampermonkey won't detect that it's the correct page.