// DrEvi1's Raid Manager
// Questions, comments, bug reports or donations to: DrEvi1 (yep that last character is a one)
//
// ==UserScript==
// @name DrEvi1's Raid Manager
// @namespace http://www.elsafes.com/kol/
// @description Version 3.26 - Organizes raid logs to a readable format
// @include *kingdomofloathing.com/topmenu.php*
// @include *kingdomofloathing.com/main.php*
// @include *kingdomofloathing.com/clan_raidlogs.php*
// @include *kingdomofloathing.com/clan_basement.php*
// @include *kingdomofloathing.com/clan_hobopolis.php*
// @include *kingdomofloathing.com/choice.php*
// @include *127.0.0.1:*/topmenu.php*
// @include *127.0.0.1:*/main.php*
// @include *127.0.0.1:*/clan_raidlogs.php*
// @include *127.0.0.1:*/clan_basement.php*
// @include *127.0.0.1:*/clan_hobopolis.php*
// @include *127.0.0.1:*/choice.php*
// @exclude http://images.kingdomofloathing.com/*
// @exclude http://forums.kingdomofloathing.com/*
// ==/UserScript==
// In the queue:
// - Lifetime boss drop amounts table
// - Lifetime adventure table
// - Optimize boss image loading
// - Count sewer points through combats and such
// 02/11/2009 Version 3.26 - Fixed minor pass the hat multiple times bug. Thanks Slyz
// 10/25/2008 Version 3.25 - Added an option to exclude richard turn cheese.
// 08/22/2008 Version 3.24 - Fix bug for open/closed tent image change.
// 08/22/2008 Version 3.23 - Fixed bug with sewer items table still showing up on choice adventures
// 08/22/2008 Version 3.22 - Fixed bug with clan basement loot logs
// 08/22/2008 Version 3.21 - Broke yodel adventures up into type, added options table for sewer item table loading, added option for loot table
// 08/22/2008 Version 3.20 - Added minor text to say how many scarehobos you can make if you try to make too many, fixed gatorskin umbrella bug.
// 08/22/2008 Version 3.19 - Minor prioritization issue with Richard part loading resolved
// 08/22/2008 Version 3.18 - Added the ability to make scarehobos from the main log manager page
// 08/21/2008 Version 3.17 - Added sewer totals in parenthesis to the total adventure table
// 08/19/2008 Version 3.16 - Fixed a bug with oils of oiliness
// 08/19/2008 Version 3.15 - Fixed a bug with inventory images turned off and the sewer item table.
// 08/19/2008 Version 3.1 - Put the load loot logs button on the main log page as well
// 08/19/2008 Version 3.0 - Added sewer item information and test tables to the sewer area and sewer choice results page.
// 08/15/2008 Version 2.95 - Fixed a bug that prevented loot distrobution. Oops!
// 08/14/2008 Version 2.9 - Made Richard section display work in lower width screens for real this time, added a title to the log
// page as a way of selfishly advertising myself, added the hamster to the loot table, moved loot table
// to the more logical place for it to be - on the basement page, changed the toppane image to a better one,
// added a link at the top of the logs to go to the clan basement (scrolling was getting annoying)
// 07/29/2008 Version 2.8 - Made Richard section display work in lower width screens, added Misc section to total adventures
// - table to count Hodgman turns spent
// 07/27/2008 Version 2.7 - Bugfix for image 125 and current loot
// 07/27/2008 Version 2.6 - Added Richard section to top table to help facilitate scarehobo organization, made all character
// names in the loot table lower case to avoid naming issues, added color shading for outfit pieces
// 07/04/2008 Version 2.5 - Ensured current run's loot distribution was included on loot tables.
// 07/02/2008 Version 2.4 - Minor bugfix. Organized and sorted tables better. Added links to player names in loot table.
// 06/30/2008 Version 2.3 - Loot table now sorts regardless of letter case. Fixed a bug where repeat of the header was overwriting a row
// 06/30/2008 Version 2.2 - Minor total bug fix.
// 06/30/2008 Version 2.1 - Fixed clan basement link in top nav to work with Mr. Script.
// - Added current run loot distrobution into loot logs
// - Fixed evil loot table screwup bug
// 06/30/2008 Version 2.0 - Redo loot table to use loot images. Add topmenu link to logs. Made images of bosses links to their
// zones. Minor bugfixes. Changed some text to be more accurate. Added small image to top menu
// that links directly to the logs page. Made loot table collapsible.
// 06/29/2008 Version 1.9 - Added a button to display lifetime loot logs. This will display a table that shows every player
// who has ever gotten loot, and what they received, and how many.
// 06/27/2008 Version 1.8 - Added progress percentages (based soley off of the section images) under each boss. If an area is
// not accessible, a message is displayed instead
// 06/27/2008 Version 1.7 - Minor bugfixes.
// 06/27/2008 Version 1.6 - Changed colors. Added totals row to adventure table. Adventure table now sorted in descending order.
// 06/26/2008 Version 1.5 - Added new table to show all non-swer adventure totals per player.
// 06/26/2008 Version 1.4 - Fixed sewer grate bug. Changed boss column in tables to defeats. Fixed total column accuracy. Added
// collapsable tables.
// 06/25/2008 Version 1.3 - Minor bugfixes.
// 06/24/2008 Version 1.2 - Minor bugfixes.
// 06/24/2008 Version 1.1 - Added boss table at the top of the log, because it's awesome. Thanks Spleenmaster for the idea.
// 06/24/2008 Version 1.0 - Initial version
// ---------------------------------------------------------------------------
// Picklish's VERSION CHECKER
// - BEGIN MANUAL SECTION -
var currentVersion = "3.26";
var scriptURL = "http://www.elsafes.com/kol/drevi1sraidmanager.user.js";
var scriptName = "DrEvi1's Raid Manager";
// The version checker will show non-errors if and only if this boolean
// is false and GM_getValue("showOnlyErrors") is false or unset.
var showOnlyErrors = true;
// - END MANUAL SECTION -
// - BEGIN CUT AND PASTE SECTION -
var datePrefix = "CheckTime-";
function MakeBullet(message)
{
return "
*" + message + "
";
}
// Check for an updated script version and print the result box...
function CheckScriptVersion()
{
// Preemptively set error, in case request fails...
GM_setValue("webVersion", "Error")
GM_xmlhttpRequest({
method: "GET",
url: scriptURL,
headers:
{
"User-agent": "Mozilla/4.0 (compatible) Greasemonkey",
"Accept": "text/html",
},
onload: function(responseDetails)
{
if (responseDetails.status == "200")
{
var m = responseDetails.responseText.match(
/description\s*Version (\w+(?:\.\w+)?)/);
if (m && !isNaN(m[1]))
{
GM_setValue("webVersion", m[1]);
}
}
var message;
var warningLevel = 0;
var forceGet = false;
var webVer = parseFloat(GM_getValue("webVersion"));
if (GM_getValue("webVersion", "Error") == "Error")
{
message = "Failed to check website for updated version of script.";
warningLevel = 1;
}
else if (isNaN(webVer))
{
message = "Couldn't find suitable version number.";
warningLevel = 1;
}
else
{
if (webVer > parseFloat(currentVersion))
{
message = "Right click here and select 'Install User Script' for Version " + webVer + ".";
warningLevel = 2;
}
else
{
if (webVer < parseFloat(currentVersion))
{
message = "Script is newer than web version.";
warningLevel = 0;
forceGet = true;
}
else
{
message = "Script is latest version.";
warningLevel = 0;
}
}
}
// In either case, check remaining resources...
PrintCheckVersionBox(warningLevel, MakeBullet(message), forceGet);
}
});
}
function PrintCheckVersionBox(resourceWarningLevel, resourceMessage, forceBox)
{
// set color from warning level
var color;
if (resourceWarningLevel > 1)
{
color = "red";
}
else if (resourceWarningLevel > 0)
{
color = "orange";
}
else
{
color = "blue";
// if no errors, return...
if (!forceBox && (showOnlyErrors ||
GM_getValue("showOnlyErrors", false)))
{
return;
}
}
var span = document.createElement("center");
span.innerHTML = "
" + scriptName + " " + currentVersion + ":
" + resourceMessage + "
";
document.body.insertBefore(span, document.body.firstChild);
}
if (window.location.pathname == "/main.php")
{
CheckScriptVersion();
}
// - END CUT AND PASTE SECTION -
// ---------------------------------------------------------------------------
// Function for returning response text to a callback function.
function GM_get(page, callback)
{
var url = "";
if (this.document.location.hostname.indexOf("127") >= 0)
url = 'http://'+ this.document.location.hostname + ":" + this.document.location.port + "/" + page;
else
url = 'http://'+ this.document.location.hostname + "/" + page;
GM_xmlhttpRequest(
{
method: 'GET',
url: url,
onload:function(details) {
if( typeof callback=='function' ){
callback(details.responseText);
}
}
});
}
function GM_post(page)
{
var url = "";
if (this.document.location.hostname.indexOf("127") >= 0)
url = 'http://'+ this.document.location.hostname + ":" + this.document.location.port + "/" + page;
else
url = 'http://'+ this.document.location.hostname + "/" + page;
GM_xmlhttpRequest(
{
method: 'POST',
url: url
});
}
var prefsPrefix = "DrEvi1RM";
var css = ().toString();
// Array of boss drop loot, put into sections then alphabetized
var lootSourceArray = new Array(
"Ol' Scratch's ash can|878278248|http://images.kingdomofloathing.com/itemimages/handcan.gif",
"Ol' Scratch's ol' britches|175959334|http://images.kingdomofloathing.com/itemimages/ninjapants.gif",
"Ol' Scratch's stovepipe hat|288475507|http://images.kingdomofloathing.com/itemimages/stovehat.gif",
"Ol' Scratch's infernal pitchfork|576715255|http://images.kingdomofloathing.com/itemimages/pitchfork2.gif",
"Ol' Scratch's manacles|877578886|http://images.kingdomofloathing.com/itemimages/cuffs.gif",
"Ol' Scratch's stove door|355068482|http://images.kingdomofloathing.com/itemimages/stovedoor.gif",
"Frosty's carrot|418045597|http://images.kingdomofloathing.com/itemimages/frostycarrot.gif",
"Frosty's nailbat|208890943|http://images.kingdomofloathing.com/itemimages/frostynailbat.gif",
"Frosty's old silk hat|535393288|http://images.kingdomofloathing.com/itemimages/frostyhat.gif",
"Frosty's arm|968257348|http://images.kingdomofloathing.com/itemimages/frostyarm.gif",
"Frosty's iceball|380631575|http://images.kingdomofloathing.com/itemimages/styore.gif",
"Frosty's snowball sack|858648754|http://images.kingdomofloathing.com/itemimages/knobsack.gif",
"Oscus's dumpster waders|878350523|http://images.kingdomofloathing.com/itemimages/yakpants.gif",
"Oscus's pelt|586085772|http://images.kingdomofloathing.com/itemimages/ratskin.gif",
"Oscus's Wand|872696571|http://images.kingdomofloathing.com/itemimages/oscuswand.gif",
"Oscus's flypaper pants|138953077|http://images.kingdomofloathing.com/itemimages/flypants.gif",
"Oscus's garbage can lid|203629025|http://images.kingdomofloathing.com/itemimages/trashield.gif",
"Oscus's neverending soda|445347637|http://images.kingdomofloathing.com/itemimages/soda.gif",
"Zombo's grievous greaves|587267531|http://images.kingdomofloathing.com/itemimages/bonepants.gif",
"Zombo's shield|935290105|http://images.kingdomofloathing.com/itemimages/zomboshield.gif",
"Zombo's skullcap|970898531|http://images.kingdomofloathing.com/itemimages/skullcap.gif",
"Zombo's empty eye|166850527|http://images.kingdomofloathing.com/itemimages/zomboeye.gif",
"Zombo's shoulder blade|909940484|http://images.kingdomofloathing.com/itemimages/skullsword.gif",
"Zombo's skull ring|202391134|http://images.kingdomofloathing.com/itemimages/skullring.gif",
"Chester's bag of candy|628538543|http://images.kingdomofloathing.com/itemimages/candybag.gif",
"Chester's cutoffs|505652258|http://images.kingdomofloathing.com/itemimages/cutoffs.gif",
"Chester's moustache|519707440|http://images.kingdomofloathing.com/itemimages/chestache.gif",
"Chester's Aquarius medallion|795271370|http://images.kingdomofloathing.com/itemimages/aquamedal.gif",
"Chester's muscle shirt|803397279|http://images.kingdomofloathing.com/itemimages/wifebeater.gif",
"Chester's sunglasses|898058153|http://images.kingdomofloathing.com/itemimages/chestershades.gif",
"Hodgman's bow tie|377044137|http://images.kingdomofloathing.com/itemimages/hobowtie.gif",
"Hodgman's porkpie hat|667103288|http://images.kingdomofloathing.com/itemimages/porkpiehat.gif",
"Hodgman's lobsterskin pants|159000068|http://images.kingdomofloathing.com/itemimages/bpcords.gif",
"Hodgman's almanac|326308790|http://images.kingdomofloathing.com/itemimages/book3.gif",
"Hodgman's cane|753829066|http://images.kingdomofloathing.com/itemimages/cane.gif",
"Hodgman's disgusting technicolor overcoat|727586163|http://images.kingdomofloathing.com/itemimages/hobovercoat.gif",
"Hodgman's garbage sticker|874739671|http://images.kingdomofloathing.com/itemimages/picker.gif",
"Hodgman's harmonica|607932819|http://images.kingdomofloathing.com/itemimages/harmonica.gif",
"Hodgman's lucky sock|494251681|http://images.kingdomofloathing.com/itemimages/tubesock.gif",
"Hodgman's metal detector|986607676|http://images.kingdomofloathing.com/itemimages/mdetector.gif",
"Hodgman's varcolac paw|307397478|http://images.kingdomofloathing.com/itemimages/varcolacpaw.gif",
"Hodgman's whackin' stick|118492859|http://images.kingdomofloathing.com/itemimages/whackstick.gif",
"Hodgman's imaginary hamster|648809275|http://images.kingdomofloathing.com/itemimages/blank.gif");
var lootOnlySourceArray = new Array(lootSourceArray.length);
var globalCount = {fun:0};
if (window.location.pathname == "/topmenu.php")
{
var tableAnchor = document.getElementsByTagName("table")[0];
var tdTags = tableAnchor.getElementsByTagName("td");
//Loop to last
, then insert new
tag with clan basement link
var anchor = tdTags[tdTags.length-1];
var clanTd = document.createElement('td');
var clanLink = document.createElement('a');
var clanImage = document.createElement('img');
clanImage.setAttribute("src","http://images.kingdomofloathing.com/adventureimages/hobofort.gif");
clanImage.setAttribute("width","50");
clanImage.setAttribute("height","50");
clanImage.setAttribute("align","right");
clanImage.setAttribute("border","0");
clanLink.setAttribute("href","clan_raidlogs.php");
clanLink.setAttribute('target','mainpane');
clanLink.appendChild(clanImage);
clanTd.appendChild(clanLink);
anchor.parentNode.insertBefore(clanTd, anchor.nextSibling);
}
if ((window.location.pathname == "/clan_basement.php"))
{
GM_addStyle(css);
var swr_chars = new Array();
// Loot table div
var lootTable = document.createElement("div");
with(lootTable)
{
id = "lootTable";
align = "center";
}
// Loot log button
var lootButton = document.createElement("input");
with(lootButton)
{
type = "button";
value = "Load Loot Logs";
style.cursor = "pointer";
className = "button_normal";
lootButton.addEventListener('click',function(evt)
{
disabled = true;
value = "Loading...";
getCurrentCharsLootTable();
},false);
}
lootTable.appendChild(lootButton);
document.body.appendChild(lootTable);
}
function getCurrentCharsLootTable()
{
GM_get("clan_raidlogs.php",
function findScarehobos(response)
{
var charArray = new Array();
var pageData = response;
var startIndex = pageData.indexOf("Sewers:");
if (startIndex >=0 )
{
var endIndex = pageData.indexOf("",startIndex);
var sectionData = pageData.substring(startIndex+19+7,endIndex);
var dataArray = sectionData.split(" ");
for (var j=0; j < dataArray.length; j++ ) // Cycle through each line entry
{
var character = getPlayer(dataArray[j]);
if (character != "" && charArray.indexOf(character) < 0)
charArray[charArray.length] = character;
}
}
swr_chars = charArray;
getLogIDs();
}
);
}
if ((window.location.pathname == "/choice.php"))
{
if (document.body.innerHTML.indexOf("sewertunnel.gif") >= 0 )
{
GM_addStyle(css);
var sewerTable = "";
if (GM_getValue("option_sewer","ON") == "ON")
sewerTable = getSewerTableDef();
document.body.innerHTML = sewerTable + getSewerTests() + document.body.innerHTML;
if (GM_getValue("option_sewer","ON") == "ON")
getSewerItems();
}
}
if ((window.location.pathname == "/clan_hobopolis.php"))
{
if (document.body.innerHTML.indexOf("The Old Sewers") >= 0)
{
if (GM_getValue("option_sewer","ON") == "ON")
{
GM_addStyle(css);
var sewerTable = getSewerTableDef();
getSewerItems();
document.body.innerHTML = sewerTable + document.body.innerHTML;
}
}
}
if ((window.location.pathname == "/clan_raidlogs.php"))
{
var loc = window.location + "";
var log_id = loc.match(/viewlog=(\w+(?:\.\w+)?)/); // I really wish I understood how the hell this works
if (log_id != null)
log_id = log_id[1]; // Now contains the item description number.
else
log_id = 0;
addScript('function toggleRow(theElement) { \n'+
' var div = document.getElementById(theElement);\n'+
' if (div.style.display=="none")\n'+
' div.style.display = "block";\n'+
' else\n'+
' div.style.display = "none";\n'+
'}');
GM_addStyle(css);
var page = "";
var bosses = new Array("","","","","","");
// Sewer data and initialization
var swr = new Array("made it through the sewer","defeated a sewer gator","defeated a C. H. U. M.","defeated a giant zombie goldfish","was defeated by","explored","sewer grate","gnawed through","empty cage","lowered the water level","rescued","");
var swr_chars = setupCharacters("Sewers:");
var swr_data = new Array();
var swr_total = zeroArray(swr.length+1);
var swr_char_total_name = new Array(); // What a freaking hack
var swr_char_total_num = new Array();
if (parseSection("Sewers:", swr, swr_data, swr_chars))
page += getSewer();
// Adventure totals per player. Sewer adventures not included.
var advArray = new Array();
for (var r=0; r < swr_chars.length; r++ )
{
advArray[r] = new Array(swr_chars[r],0,0,0,0,0,0,0,0);
}
// Town Square data and initialization
if (GM_getValue("option_richard","ON") == "ON")
{
var twn_headers = new Array("Normal Hobos","Defeats","Marketplace","Took the Stage","Passed the Hat","Mosh Pits","Ruined Show","Total");
var twn = new Array("defeated Normal hobo","was defeated by Normal","went shopping in the Marketplace","took the stage","passed","mosh","ruined","");
}
else
{
var twn_headers = new Array("Normal Hobos","Defeats","Marketplace","Made Bandages","Made Grenades","Made Shakes","Took the Stage","Passed the Hat","Mosh Pits","Ruined Show","Total");
var twn = new Array("defeated Normal hobo","was defeated by Normal","went shopping in the Marketplace","bandage","grenade","protein shake","took the stage","passed the hat","mosh","ruined","");
}
var twn_chars = setupCharacters("Town Square:");
var twn_data = new Array();
var twn_total = zeroArray(twn.length+1);
if (parseSection("Town Square:", twn, twn_data, twn_chars))
page += getSection("Town Square", twn_headers, "normal", twn_data, twn_total, twn,0);
// Burnbarrel Blvd. data and initialization
var brn_headers = new Array("Hot Hobos","Killed by Ol' Scratch","Defeats","Threw tire on fire","Tirevalanche","Diverted Steam","Opened Door","Burned by Door","Total");
var brn = new Array("defeated Hot hobo","defeated by Ol' Scratch","was defeated by Hot","on the fire","tirevalanche","diverted some steam away","clan coffer","hot door","");
var brn_chars = setupCharacters("Burnbarrel Blvd.:");
var brn_data = new Array();
var brn_total = zeroArray(brn.length+1);
if (parseSection("Burnbarrel Blvd.:", brn, brn_data, brn_chars))
page += getSection("Burnbarrel Blvd.", brn_headers, "burn", brn_data, brn_total, brn, 1);
// Exposure Esplanade data and initialization
var exp_headers = new Array("Cold Hobos","Killed by Frosty","Defeats","Freezers Raided","Fridges Raided","Broken Pipes","Diverted Water out of Esplanade","Diverted Water to Burnbarrel Blvd","Yodeled a little","Yodeled quite a bit","Yodeled like crazy","Total");
var exp = new Array("defeated Cold hobo","defeated by Frosty","was defeated by Cold","freezer","fridge","broke","diverted some cold water out of Exposure Esplanade","diverted some cold water to Burnbarrel Blvd","yodeled a little","yodeled quite a bit","yodeled like crazy","");
var exp_chars = setupCharacters("Exposure Esplanade:");
var exp_data = new Array();
var exp_total = zeroArray(exp.length+1);
if (parseSection("Exposure Esplanade:", exp, exp_data, exp_chars))
page += getSection("Exposure Esplanade", exp_headers, "exp", exp_data, exp_total, exp,2);
// Heap data and initialization
var heap_headers = new Array("Stench Hobos","Killed by Oscus","Defeats","Trashcanos","Buried Treasure","Sent compost to the Burial Ground","Total");
var heap = new Array("defeated Stench hobo","defeated by Oscus","was defeated by Stench","trashcano eruption","buried treasure","Burial Ground","");
var heap_chars = setupCharacters("The Heap:");
var heap_data = new Array();
var heap_total = zeroArray(heap.length+1);
if (parseSection("The Heap:", heap, heap_data, heap_chars))
page += getSection("The Heap", heap_headers, "heap", heap_data, heap_total, heap,3);
// The Ancient Hobo Burial Ground data and initialization
var burial_headers = new Array("Spooky Hobos","Killed by Zombo","Defeats","Sent Flowers to The Heap","Raided Tombs","Watched zombies dance","Failed to impress with dance","Busted moves","Total");
var burial = new Array("defeated Spooky hobo","defeated by Zombo","was defeated by Spooky","flower","raided","zombie hobos dance","failed to impress","busted","");
var burial_chars = setupCharacters("The Ancient Hobo Burial Ground:");
var burial_data = new Array();
var burial_total = zeroArray(burial.length+1);
if (parseSection("The Ancient Hobo Burial Ground:", burial, burial_data, burial_chars))
page += getSection("The Ancient Hobo Burial Ground", burial_headers, "burial", burial_data, burial_total, burial,4);
// The Purple Light District data and initialization
var purple_headers = new Array("Sleaze Hobos","Killed by Chester","Defeats","Raided Dumpsters","Sent Trash to The Heap","Bamboozeled","Flimflammed","Danced","Barfights","Total");
var purple = new Array("defeated Sleaze hobo","defeated by Chester","was defeated by Sleaze","dumpster","sent some trash","bamboozled","flimflammed","danced like a superstar","barfight","");
var purple_chars = setupCharacters("The Purple Light District:");
var purple_data = new Array();
var purple_total = zeroArray(purple.length+1);
if (parseSection("The Purple Light District:", purple, purple_data, purple_chars))
page += getSection("The Purple Light District", purple_headers, "purple", purple_data, purple_total, purple,5);
// Hodgman
var misc = new Array("defeated Hodgman","was defeated by","");
var misc_chars = setupCharacters("Miscellaneous");
var misc_data = new Array();
var misc_total = zeroArray(misc.length+1);
if (parseSection("Miscellaneous", misc, misc_data, misc_chars))
{
getSection("Miscellaneous", misc, "normal", misc_data, misc_total, misc,6);
}
// Bosses
var boss_table = '
' +
'
'+
'
' +
'
Richard
' +
"
Ol' Scratch
" +
'
Frosty
' +
'
Oscus
' +
'
Zombo
' +
'
Chester
' +
'
Hodgman
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
';
// Richard stuff here
getScarehobos();
boss_table += '
Loading hobo parts...
';
if (bosses[1] != "")
boss_table += '
Killed by: ' + playerLink(bosses[1]) + '
';
else
{
getZoneStatus(4);
boss_table += '
Loading status...
';
}
if (bosses[2] != "")
boss_table += '
Killed by: ' + playerLink(bosses[2]) + '
';
else
{
getZoneStatus(5);
boss_table += '
Loading status...
';
}
if (bosses[3] != "")
boss_table += '
Killed by: ' + playerLink(bosses[3]) + '
';
else
{
getZoneStatus(6);
boss_table += '
Loading status...
';
}
if (bosses[4] != "")
boss_table += '
Killed by: ' + playerLink(bosses[4]) + '
';
else
{
// Load zone status based off of image
getZoneStatus(7);
boss_table += '
" +
boss_table+
" " + getTotalAdventures() + page + document.body.innerHTML;
// Options
var option_sewer = "ON";
if (GM_getValue("option_sewer","ON") == "OFF")
option_sewer = "OFF";
var option_richard = "ON";
if (GM_getValue("option_richard","ON") == "OFF")
option_richard = "OFF";
var option_loot = "ON";
if (GM_getValue("option_loot","ON") == "OFF")
option_loot = "OFF";
// loot option log button
var lootPlayerButton = document.createElement("input");
with(lootPlayerButton)
{
type = "button";
value = option_loot;
style.cursor = "pointer";
className = "button_small";
lootPlayerButton.addEventListener('click',function(evt)
{
option_loot = "OFF";
if (GM_getValue("option_loot","ON") == "OFF")
option_loot = "ON";
GM_setValue("option_loot",option_loot);
value = option_loot;
},false);
}
document.getElementById("options_loot").appendChild(lootPlayerButton);
// Sewer option log button
var optionButton = document.createElement("input");
with(optionButton)
{
type = "button";
value = option_sewer;
style.cursor = "pointer";
className = "button_small";
optionButton.addEventListener('click',function(evt)
{
option_sewer = "OFF";
if (GM_getValue("option_sewer","ON") == "OFF")
option_sewer = "ON";
GM_setValue("option_sewer",option_sewer);
value = option_sewer;
},false);
}
document.getElementById("options_sewer").appendChild(optionButton);
// Richard option button
var richardButton = document.createElement("input");
with(richardButton)
{
type = "button";
value = option_richard;
style.cursor = "pointer";
className = "button_small";
richardButton.addEventListener('click',function(evt)
{
option_richard = "OFF";
if (GM_getValue("option_richard","ON") == "OFF")
option_richard = "ON";
GM_setValue("option_richard",option_richard);
value = option_richard;
},false);
}
document.getElementById("options_richard").appendChild(richardButton);
// Loot table div
var lootTable = document.createElement("div");
with(lootTable)
{
id = "lootTable";
align = "center";
}
// Loot log button
var lootButton = document.createElement("input");
with(lootButton)
{
type = "button";
value = "Load Loot Logs";
style.cursor = "pointer";
className = "button_normal";
lootButton.addEventListener('click',function(evt)
{
disabled = true;
value = "Loading...";
getLogIDs();
},false);
}
lootTable.appendChild(lootButton);
document.getElementById("bossTable").appendChild(lootTable);
}
function makeScarehobos()
{
var quantity = document.getElementById("qty").value;
GM_get("clan_hobopolis.php?preaction=simulacrum&place=3&qty=" + quantity,
function findStatus(response)
{
if (response.indexOf("BLAM!") >= 0)
window.location = "clan_raidlogs.php";
else if (response.indexOf("there aren't enough hobos left to scare") >= 0)
document.getElementById("scarehoboz").innerHTML = "No more hobos in town square.";
else
document.getElementById("scarehoboz").innerHTML = "Unable to create.";
});
}
function getSewerTableDef()
{
var sewerTable = '
' +
'
'+
'
' +
'
unfortunate dumplings
' +
"
bottle of Ooze-O
" +
'
sewer wad
' +
'
oil of oiliness
' +
'
gatorskin umbrella
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
';
return sewerTable;
}
function getSewerItems()
{
// Will get bottles of ooze-o and unfortunate dumplings
GM_get("inventory.php?which=1",
function findStatus(response)
{
var bottles = 0;
var dumplings = 0;
var pageText = response;
var startIndex = pageText.indexOf("bottle of Ooze-O"); // ooze-o
if (startIndex >= 0) // bottle found
{
var m = pageText.substring(startIndex,startIndex+35).match(/\(\d*\)/);
if (m != null)
{
var n = m[0].match(/\d{1,5}/);
bottles = parseInt(n[0]);
}
else
bottles = 1;
}
startIndex = pageText.indexOf("unfortunate dumplings"); // dumplings
if (startIndex >= 0) // bottle found
{
var m = pageText.substring(startIndex,startIndex+35).match(/\(\d*\)/);
if (m != null)
{
var n = m[0].match(/\d{1,5}/);
dumplings = parseInt(n[0]);
}
else
dumplings = 1;
}
// Apply returnVal to div layer to show results
document.getElementById("bottles").innerHTML = bottles;
document.getElementById("dumplings").innerHTML = dumplings;
});
// Will get sewer wads and oils of oiliness
GM_get("inventory.php?which=3",
function findStatus(response)
{
var oils = 0;
var wads = 0;
var pageText = response;
var startIndex = pageText.indexOf("oil of oiliness");
if (startIndex >= 0) // found
{
var m = pageText.substring(startIndex,startIndex+35).match(/\(\d*\)/);
if (m != null)
{
var n = m[0].match(/\d{1,5}/);
oils = parseInt(n[0]);
}
else
oils = 1;
}
startIndex = pageText.indexOf("sewer wad");
if (startIndex >= 0) // found
{
var m = pageText.substring(startIndex,startIndex+35).match(/\(\d*\)/);
if (m != null)
{
var n = m[0].match(/\d{1,5}/);
wads = parseInt(n[0]);
}
else
wads = 1;
}
// Apply returnVal to div layer to show results
document.getElementById("oils").innerHTML = oils;
document.getElementById("wads").innerHTML = wads;
});
// Will get gatorskin umbrellas, ellas, ay, ay...
GM_get("inventory.php?which=2",
function findStatus(response)
{
var ellas = 0;
var pageText = response;
var weaponText = pageText.substring(pageText.indexOf("Melee Weapons:"),pageText.length);
var startIndex = weaponText.indexOf("gatorskin umbrella");
if (startIndex >= 0) // found
{
var m = weaponText.substring(startIndex,startIndex+38).match(/\(\d*\)/);
if (m != null)
{
var n = m[0].match(/\d{1,5}/);
ellas = parseInt(n[0]);
}
else
ellas = 1;
}
else // Have to determine is there is only one and it is equipped
{
startIndex = pageText.indexOf("gatorskin umbrella");
if (startIndex >= 0) // found
{
ellas = 1;
}
}
// Determine if any are equipped
startIndex = pageText.indexOf("Weapon:");
var endIndex = pageText.indexOf("Pants:")
if (endIndex >= 0)
pageText = pageText.substring(startIndex,endIndex);
else
pageText = pageText.substring(startIndex,startIndex + 100);
if (pageText.indexOf("gatorskin umbrella") >= 0)
ellas += " (Equipped)";
else
{
if (ellas > 0)
{
// Add equip link for conveinence ""
var hashIndex = pageText.indexOf("inv_equip.php?pwd=");
var pwdhash = pageText.substring(hashIndex+18,hashIndex+50);
ellas += " (Not Equipped)";
}
else
ellas += " (Not Equipped)";
}
// Apply returnVal to div layer to show results
document.getElementById("ellas").innerHTML = ellas;
});
}
function getSewerTests()
{
// Yes I realize I should have done this more programatically, but this is faster. In future updates I will work towards
// a more programatic solution
var test1 = "Failed";
var test2 = "Failed";
var test3 = "Failed";
var test4 = "Failed";
var dumplings = "Failed";
var bottles = "Failed";
var wads = "Failed";
var oils = "Failed";
var ellas = "Failed";
var pageText = document.body.innerHTML;
if (pageText.indexOf("You head down the 'shortcut' tunnel.") >= 0)
test1 = "Passed";
if (pageText.indexOf("You continue down the tunnel, instead.") >= 0)
test2 = "Passed";
if (pageText.indexOf("You head toward the Egress.") >= 0)
test3 = "Passed";
if (pageText.indexOf("looks like somebody else opened this grate from the other side") >= 0)
test4 = "Passed";
if (pageText.indexOf("You leave the fish to his delicious meal and proceed further down the tunnel.") >= 0)
dumplings = "Passed";
if (pageText.indexOf("You step over his prone, odiferous form and proceed down the tunnel.") >= 0)
bottles = "Passed";
if (pageText.indexOf("He grabs the wad and runs away") >= 0)
wads = "Passed";
if (pageText.indexOf("you douse yourself with oil of oiliness") >= 0)
oils = "Passed";
if (pageText.indexOf("There's not much left of the umbrella") >= 0)
ellas = "Passed";
var test = "Failed";
var testName = "";
var testTable = '
'+
'
' +
'
Test
'+
'
Status
'+
'
'+
'
'+
'
Easy Hobo Code Test
'+
'
' + test1 + '
'+
'
';
var sectionText = pageText.substring(pageText.indexOf("sewertunnel.gif"),pageText.indexOf("sewerladder.gif"));
if (sectionText.indexOf("zomfish.gif")>=0)
{
test = dumplings;
testName = "Zombie Goldfish (unfortunate dumplings)";
}
else if (sectionText.indexOf("chum1.gif")>=0)
{
test = wads;
testName = "C.H.U.M. (sewer wad)";
}
else if (sectionText.indexOf("chum2.gif")>=0)
{
test = bottles;
testName = "Drunken C.H.U.M. (bottle of Ooze-O)";
}
else if (sectionText.indexOf("gate.gif")>=0)
{
test = oils;
testName = "Narrow Gate (3 oils of oiliness)";
}
else if (sectionText.indexOf("sewertunnel.gif")>=0)
{
test = ellas;
testName = "Flood of Sewage (gatorskin umbrella)";
}
testTable += '
'+
'
' + testName + '
'+
'
' + test + '
'+
'
'+
'
'+
'
Medium Hobo Code Test
'+
'
' + test2 + '
'+
'
';
var sectionText = pageText.substring(pageText.indexOf("sewerladder.gif"),pageText.indexOf("3ladders.gif"));
if (sectionText.indexOf("zomfish.gif")>=0)
{
test = dumplings;
testName = "Zombie Goldfish (unfortunate dumplings)";
}
else if (sectionText.indexOf("chum1.gif")>=0)
{
test = wads;
testName = "C.H.U.M. (sewer wad)";
}
else if (sectionText.indexOf("chum2.gif")>=0)
{
test = bottles;
testName = "Drunken C.H.U.M. (bottle of Ooze-O)";
}
else if (sectionText.indexOf("gate.gif")>=0)
{
test = oils;
testName = "Narrow Gate (3 oils of oiliness)";
}
else if (sectionText.indexOf("sewertunnel.gif")>=0)
{
test = ellas;
testName = "Flood of Sewage (gatorskin umbrella)";
}
testTable += '
'+
'
' + testName + '
'+
'
' + test + '
'+
'
'+
'
'+
'
Hard Hobo Code Test
'+
'
' + test3 + '
'+
'
'+
'
'+
'
Opened Grate Test
'+
'
' + test4 + '
'+
'
'+
'
';
return testTable;
}
// Function that resolves the listing of all distributed loot.
function getLoot(logArray)
{
var allLoot = new Array();
// FOR CURRENT RUN - Changed in 2.9 to hit clan_raidlogs.php
GM_get("clan_raidlogs.php",
function findStatus(response)
{
globalCount.fun += 1;
lootButton.value = "Loading... " + globalCount.fun + " of " + (logArray.length+1);
var pageText = response; // This is the only difference from the text below for past runs
var startIndex = pageText.indexOf("Loot Distribution:");
var endIndex = pageText.indexOf(" ", startIndex+37);
if ((startIndex >= 0) && (endIndex >= 0))
{
var data = pageText.substring(startIndex+37,endIndex);
var dataArray = data.split(" ");
for (var j=0; j < dataArray.length; j++ )
{
var line = dataArray[j];
var loot = line.substring(line.indexOf("")+3,line.indexOf(""));
var character = line.substring(line.indexOf(" to ")+8,line.indexOf(")",line.indexOf(" to ")+8)+1);
if (loot == "Wand of Oscus")
loot = "Oscus's Wand";
allLoot[allLoot.length] = character +"|"+loot;
}
}
if (globalCount.fun == (logArray.length+1)) // If all calls to previous logs are complete (man I hope this works)
createLootTable(allLoot.sort(sortfunction));
});
// END FOR CURRENT RUN
for (var i=0; i < logArray.length; i++ )
{
GM_get("clan_raidlogs.php?viewlog="+logArray[i],
function findStatus(response)
{
globalCount.fun += 1;
lootButton.value = "Loading... " + globalCount.fun + " of " + (logArray.length+1);
var pageText = stripCurrent(response);
var startIndex = pageText.indexOf("Loot Distribution:");
var endIndex = pageText.indexOf(" ", startIndex+37);
if ((startIndex >= 0) && (endIndex >= 0))
{
var data = pageText.substring(startIndex+37,endIndex);
var dataArray = data.split(" ");
for (var j=0; j < dataArray.length; j++ )
{
var line = dataArray[j];
var loot = line.substring(line.indexOf("")+3,line.indexOf(""));
var character = line.substring(line.indexOf(" to ")+8,line.indexOf(")",line.indexOf(" to ")+8)+1);
if (loot == "Wand of Oscus")
loot = "Oscus's Wand";
allLoot[allLoot.length] = character +"|"+loot;
}
}
if (globalCount.fun == (logArray.length+1)) // If all calls to previous logs are complete (man I hope this works)
createLootTable(allLoot.sort(sortfunction));
});
}
}
function stripCurrent(thePageText)
{
var index = thePageText.indexOf("Clan Dungeon Logs");
var data = thePageText.substring(0,index);
return data;
}
function getHeaders()
{
var dataTable = '
' +
'
Player
';
for (var i=0; i < lootSourceArray.length; i++ )
{
var splitLoot = lootSourceArray[i].split("|");
var loot = splitLoot[0];
var desc = splitLoot[1];
var image = splitLoot[2];
var css = getcss(i);
lootOnlySourceArray[i] = loot; //This allows later functions to reference the item name exactly.
loot = loot.replace("Ol' Scratch's ","");
loot = loot.replace("Frosty's ","");
loot = loot.replace("Oscus's ","");
loot = loot.replace("Zombo's ","");
loot = loot.replace("Chester's ","");
loot = loot.replace("Hodgman's ","");
dataTable += '
';
}
//dataTable += '
Tot
';
dataTable += '
';
return dataTable;
}
function createLootTable(lootArray)
{
// charArray = Array of unique and alphabetized characters
// dropArray = Array of arrays. Stored arrays contain an element for each possible boss drop, and a counter for each.
// dropArray[X] coorisponds to charArray[X]'s drops.
// lootArray = Array of character|loot retrieved from the logs
var option_loot = "ON";
if (GM_getValue("option_loot","ON") == "OFF")
{
option_loot = "OFF";
}
else
{
for (var i=0; i < swr_chars.length; i++ )
{
swr_chars[i] = swr_chars[i].toLowerCase();
}
}
// Create array of unique player names
var charArray = new Array();
for (var i=0; i < lootArray.length; i++ )
{
var splitLoot = lootArray[i].split("|");
var character = splitLoot[0].toLowerCase();
// NEW CURRENT PLAYERS ONLY LOOT OPTION
if ((option_loot == "OFF") || (swr_chars.indexOf(character) >= 0))
{
if (charArray.indexOf(character) < 0)
{
charArray[charArray.length] = character;
}
}
}
// Create new matrix of doom and hugeness. This will probably crash everyone's computer in KOL Addicts.
var dropArray = new Array(charArray.length);
for (var i=0; i < dropArray.length; i++ )
{
dropArray[i] = zeroArray(lootOnlySourceArray.length);
}
var dataTable = '
'+
'
' +
'
Lifetime Loot Table
' +
'
'+
'
'+
'
'+
'
'+
'
'+
'
' +
'
'+
'
Ol Scratch
'+
'
Frosty
'+
'
Oscus
'+
'
Zombo
'+
'
Chester
'+
'
Hodgman
'+
'
T o t
'+
'
';
dataTable += getHeaders();
var dropTotalsArray = zeroArray(lootSourceArray.length);
// Add loot to matrix
for (var i=0; i < lootArray.length; i++ )
{
var splitLoot = lootArray[i].split("|");
var character = splitLoot[0].toLowerCase();
var loot = splitLoot[1];
var charIndex = charArray.indexOf(character);
var lootIndex = lootOnlySourceArray.indexOf(loot);
if (charIndex >= 0)
{
dropArray[charIndex][lootIndex] += 1;
dropTotalsArray[lootIndex] += 1;
}
}
var counter = 0;
for (var i=0; i < charArray.length; i++ ) // Loops through characters
{
counter++;
if (counter == 16)
{
dataTable += getHeaders();
counter = 0;
}
var row_shaded = "";
var shaded = "";
var character = charArray[i].substring(0,charArray[i].indexOf(" (#"));
var characterLink = playerLink(charArray[i]);
if (isEven(i))
row_shaded = "";
else
row_shaded = "_shaded";
dataTable += '
';
var grandTotal = 0;
for (var i=0; i < dropTotalsArray.length; i++ )
{
var total = dropTotalsArray[i];
grandTotal+=total;
if (dropTotalsArray[i] == 0)
total = " ";
dataTable += '
' + total + '
';
}
dataTable += '
' + grandTotal + '
';
dataTable += '
';
dataTable += '
';
document.getElementById("lootTable").innerHTML = dataTable;
}
function displayArray(theArray)
{
var theText = "";
for (var j=0; j < theArray.length; j++ )
{
theText += theArray[j]+"\n";
}
alert(theText);
}
// Function that returns an array of previous run log IDs
function getLogIDs()
{
GM_get("clan_raidlogs.php",
function findStatus(response)
{
var logArray = new Array();
var parsedText = response;
var parseIndex = parsedText.indexOf("clan_raidlogs.php?");
var counter = 0;
var lastIndex = 0;
while (parseIndex >= 0)
{
var m = parsedText.substring(parseIndex,parsedText.length).match(/viewlog=(\w+(?:\.\w+)?)/);
logArray[counter] = m[1];
counter++;
parsedText = parsedText.substring(parseIndex+5,parsedText.length);
lastIndex = parseIndex;
parseIndex = parsedText.indexOf("clan_raidlogs.php?");
}
if (counter == 0 )
document.getElementById("lootTable").innerHTML = "No Previous Runs or you do not have access to the clan basement currently";
else
{
getLoot(logArray);
}
});
}
// Function that goes ut and retreives the image status for each section of hobopolis
// clan_hobopolis.php?place=
// 2 - Town Square
// 4 - Burnbarrel
// 5 - Esplanade
// 6 - The Heap
// 7 - Burial Grounds
// 8 - Puple Light District
function getZoneStatus(section)
{
// Have to put palceholders in arrays for place amounts that are not used
var imageArray = new Array("","","townsquare","","burnbarrel","exposureesplanade","theheap","burialground","purplelightdistrict");
var totalArray = new Array(0,0,25,0,10,10,10,10,10);
GM_get("clan_hobopolis.php?place="+section,
function findStatus(response)
{
var returnVal = 0;
var startIndex = response.indexOf(imageArray[section]);
if (startIndex >= 0)
{
var theString = response.substring(startIndex,response.length);
var m = response.match(/\d*\D?\.gif/); // This line thanks to punicron.
if (m != null)
{
var n = m[0].match(/\d{1,3}/);
var tent = m[0].match(/o\.gif/);
if (tent != null)
tent = "open";
else
tent = "closed";
var imageNumber = parseInt(n[0]);
returnVal = imageNumber;
if (imageNumber == 125) // Damn you Jick.
returnVal = 13;
}
var percentage = Math.round((returnVal/totalArray[section])*100,2);
if (percentage == 100)
document.getElementById(imageArray[section]+section).innerHTML = "Boss is ready for a fight!";
else
{
if (section == 2)
document.getElementById(imageArray[section]+section).innerHTML = percentage+"% Complete To Boss Fight (Image = " + imageNumber + ") Tent is " + tent;
else
document.getElementById(imageArray[section]+section).innerHTML = percentage+"% Complete To Boss Fight (Image = " + imageNumber + ")";
}
}
else
{
document.getElementById(imageArray[section]+section).innerHTML = "Boss is alive Area not open to you yet";
}
}
);
}
Array.prototype.min = function(){
return Math.min.apply( Math, this );
};
function getScarehobos()
{
GM_get("clan_hobopolis.php?place=3&action=talkrichard&whichtalk=3",
function findScarehobos(response)
{
var v_boots = 0;
var v_eyes = 0;
var v_guts = 0;
var v_skulls = 0;
var v_crotches = 0;
var v_skins = 0;
var m;
var n;
if ((response.indexOf("Richard") >= 0))
{
// Boots
m = response.match(/Richard has \\d*\<\/b\> pairs of charred hobo boots/);
if (m == null)
m = response.match(/Richard has \\d*\<\/b\> pair of charred hobo boots/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_boots = parseInt(n[0]);
}
// Eyes
m = response.match(/Richard has \\d*\<\/b\> pairs of frozen hobo eyes/);
if (m == null)
m = response.match(/Richard has \\d*\<\/b\> pair of frozen hobo eyes/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_eyes = parseInt(n[0]);
}
// Guts
m = response.match(/Richard has \\d*\<\/b\> pile/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_guts = parseInt(n[0]);
}
// Skulls
m = response.match(/Richard has \\d*\<\/b\> creepy hobo skull/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_skulls = parseInt(n[0]);
}
// Crotches
m = response.match(/Richard has \\d*\<\/b\> hobo crotch/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_crotches = parseInt(n[0]);
}
// Skins
m = response.match(/Richard has \\d*\<\/b\> hobo skin/);
if (m != null)
{
n = m[0].match(/\d{1,3}/);
v_skins = parseInt(n[0]);
}
document.getElementById("scarehobos").innerHTML = '
' + v_boots + ' boots
'+
'
' + v_eyes + ' eyes
'+
'
' + v_guts + ' guts
'+
'
' + v_skulls + ' skulls
'+
'
' + v_crotches + ' crotches
'+
'
' + v_skins + ' skins
'+
''+
''+
''+
''+
''+
'';
// Scarehobo button
var scarehoboButton = document.createElement("input");
with(scarehoboButton)
{
id = "scarehobobutton";
type = "button";
value = "Make Scarehobos";
style.cursor = "pointer";
className = "buttons";
scarehoboButton.addEventListener('click',function(evt)
{
var quantity = parseInt(document.getElementById("qty").value);
var parts = new Array(parseInt(document.getElementById("num_boots").value),
parseInt(document.getElementById("num_eyes").value),
parseInt(document.getElementById("num_guts").value),
parseInt(document.getElementById("num_skulls").value),
parseInt(document.getElementById("num_crotches").value),
parseInt(document.getElementById("num_skins").value));
var maxscarehobos = parts.min();
if ( maxscarehobos >= quantity)
{
disabled = true;
value = "Creating...";
makeScarehobos();
}
else
{
alert("Not enough parts, can only make " + maxscarehobos +"!");
}
},false);
}
// Scarehobo qty input
var scarehoboqty = document.createElement("input");
with(scarehoboqty)
{
id = "qty"
type = "text";
value = "1";
style.width = "25px";
className = "inputs";
}
document.getElementById("scarehoboz").appendChild(scarehoboqty);
document.getElementById("scarehoboz").appendChild(scarehoboButton);
}
else
{
document.getElementById("scarehobos").innerHTML = "Richard is unavailable";
}
}
);
}
function playerLink(character)
{
var index = character.indexOf("#");
var charName = character.substring(0,index-2).replace(/[" "]+/g, " ");
var charLink = character.substring(index+1,character.length-1);
return (' ' + charName + '');
}
function getTotalAdventures()
{
for (var i=0; i < swr_chars.length; i++ )
{
var total = advArray[i][1]+advArray[i][2]+advArray[i][3]+advArray[i][4]+advArray[i][5]+advArray[i][6]+advArray[i][7];
advArray[i][8] = total;
}
advArray = sortArray(8,advArray);
var totalArray = new Array(0,0,0,0,0,0,0,0,0);
var dataTable = '
' +
'
'+
'
' +
'
Non-sewer Adventure Totals (Total with sewer in parenthesis)
' +
'
'+
'
'+
'
'+
'
'+
'
'+
'
' +
'
Player
'+
'
Town Square
'+
'
Burnbarrel
'+
'
Esplanade
'+
'
The Heap
'+
'
Burial Ground
'+
'
Purple Light
'+
'
Misc
' +
'
Total
' +
'
';
var counter = 0;
for (var z=0; z < swr_chars.length; z++ ) // For each character
{
//if(advArray[z][8] > 0)
//{
var shaded = "";
if (isEven(counter))
shaded = "";
else
shaded = "_shaded";
counter++;
var swrIndex = swr_char_total_name.indexOf(advArray[z][0]);
dataTable += '
\n';
// Add player total to global adventure total array
if (swr_chars.indexOf(dataArray[z][0]) >= 0)
{
advArray[swr_chars.indexOf(dataArray[z][0])][bossNum+1] = dataArray[z][messageArray.length];
}
}
// Display totals
dataTable += '
\n';
dataTable += '
Total
\n';
for (var v=1; v < totalArray.length; v++ )
{
dataTable += '
' + totalArray[v] + '
\n';
}
dataTable += '
';
return dataTable;
}
function getSewer()
{
var sewerTable = '
' +
'
'+
'
' +
'
Sewer
' +
'
'+
'
'+
'
'+
'
'+
'
'+
'
' +
'
Player
'+
'
Sewer Gators
' +
'
C.H.U.M.s
' +
'
Zombie Goldfish
' +
'
Defeats
' +
'
Explored Tunnels
' +
'
Sewer Grates
' +
'
Gnawed Cage
' +
'
Stared at a Cage
' +
'
Lowered Water
' +
'
Rescues
' +
'
Total
' +
'
';
for (var z=0; z < swr_chars.length; z++ ) // For each character
{
var counter = 0;
if (isEven(z))
sewerTable += '
\n';
else
sewerTable += '
\n';
if (swr_data[z][1] > 0 )
{
sewerTable += '
' + playerLink(swr_data[z][0]) + ' (Clear)
\n';
counter++; // Add one to total for the clear adventure
}
else
sewerTable += '
' + playerLink(swr_data[z][0]) + '
\n';
for (var y=0; y < swr.length-2; y++ )
{
counter += swr_data[z][y+2];
sewerTable += '
' + swr_data[z][y+2] + '
\n';
swr_total[y+2] += swr_data[z][y+2];
}
swr_total[swr_total.length-1] += counter;
// Make global sewer total table to be used later for total table
swr_char_total_name[z] = swr_data[z][0];
swr_char_total_num[z] = counter;
sewerTable += '
' + counter + '
\n';
sewerTable += '
\n';
}
// Display totals
sewerTable += '
\n';
sewerTable += '
Total
\n';
for (var v=2; v < swr_total.length; v++ )
{
sewerTable += '
' + swr_total[v] + '
\n';
}
sewerTable += '
';
return sewerTable;
}
function parseSection(section, adv, adv_data, charArray)
{
// Initialize adv_data to a 2d array of zeros
for (var h=0; h < charArray.length; h++ ) // For each character in a section
{
adv_data[h] = new Array(); // Add a new blank array
adv_data[h][0] = charArray[h]; // Make the first element in the blank array the character
for (var g=1; g < adv.length+1; g++ ) // For each element in the array per character
{
adv_data[h][g] = 0; // Initialize the spot to zero
}
}
// Need to not parse current log only while in past runs
var pageData = document.body.innerHTML;
if (pageData.indexOf("Results:") >= 0)
{
pageData = stripCurrent(pageData);
}
var startIndex = pageData.indexOf("" + section + "");
if (startIndex < 0 )
return false;
var endIndex = pageData.indexOf("",startIndex);
var sectionData = pageData.substring(startIndex+19+section.length,endIndex);
var dataArray = sectionData.split(" ");
for (var j=0; j < dataArray.length; j++ ) // Loop through each line entry
{
var data = dataArray[j];
var character = getPlayer(data);
var index = charArray.indexOf(character);
if (index < 0)
break;
data = data.replace(character,""); // Prevents people with ambiguous names from messing up string parsing
var turns = getTurns(data);
for (var x=0; x < adv.length+1; x++ ) // Loop through all possible messages
{
// Boss save
if (data.indexOf("defeated Ol' Scratch") >= 0)
bosses[1] = character;
else if (data.indexOf("defeated Frosty") >= 0)
bosses[2] = character;
else if (data.indexOf("defeated Oscus") >= 0)
bosses[3] = character;
else if (data.indexOf("defeated Zombo") >= 0)
bosses[4] = character;
else if (data.indexOf("defeated Chester") >= 0)
bosses[5] = character;
else if (data.indexOf("defeated Hodgman") >= 0)
bosses[0] = character;
if (data.indexOf(adv[x]) >= 0) // If current message matches line currently being parsed
{
if ((GM_getValue("option_richard","ON") == "ON"))
{
if ((data.indexOf("bandage") < 0) && (data.indexOf("grenade") < 0) && (data.indexOf("protein shake") < 0))
adv_data[index][x+1] += turns; // Add current message turns to total in source array
}
else
adv_data[index][x+1] += turns; // Add current message turns to total in source array
}
}
}
adv_data = sortArray(adv.length,adv_data);
return true;
}
// This function returns the array of unique character names and IDs of those who have adventured in the dungeon section.
function setupCharacters(section)
{
var charArray = new Array();
var pageData = document.body.innerHTML;
var startIndex = pageData.indexOf("" + section + "");
if (startIndex >=0 )
{
var endIndex = pageData.indexOf("",startIndex);
var sectionData = pageData.substring(startIndex+19+section.length,endIndex);
var dataArray = sectionData.split(" ");
for (var j=0; j < dataArray.length; j++ ) // Cycle through each line entry
{
var character = getPlayer(dataArray[j]);
if (character != "" && charArray.indexOf(character) < 0)
charArray[charArray.length] = character;
}
}
return charArray;
}
// ----------------------------------------------------------------
// FUNCTION getPlayer - Parses theString and looks for text in the format of "Player (#Number)" and returns the text
// ----------------------------------------------------------------
function getPlayer(theString)
{
var player = theString.substring(0,theString.indexOf(") ")+1).replace("","").replace("","");
return player;
}
// ----------------------------------------------------------------
// FUNCTION getTurns - Parses theString and looks for text in the format of "(X turn" and returns X
// ----------------------------------------------------------------
function getTurns(theString)
{
var returnVal = 0;
if (theString != null)
{
var m = theString.match(/\(\d* turn/);
if (m != null)
{
var n = m[0].match(/\d{1,4}/);
returnVal = parseInt(n[0]);
}
}
return returnVal;
}
// ----------------------------------------------------------------
// FUNCTION isEven - Determines if num is even, returns true if it is
// ----------------------------------------------------------------
function isEven(num)
{
var dnum = (num / 2);
var inum = (Math.round(dnum));
if (inum == dnum)
return true;
return false;
}
// ----------------------------------------------------------------
// FUNCTION adScript - Adds scriptText to the current page's header
// ----------------------------------------------------------------
function addScript(scriptText){
var head = document.getElementsByTagName('head')[0];
if (!head) { return; }
var addScript = document.createElement("script");
addScript.innerHTML = scriptText;
head.appendChild(addScript);
}
function sortfunction(a, b)
{
a = a.toLowerCase();
b = b.toLowerCase();
if (a>b) return 1;
if (a