Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Improbable Truancy Meter
// ==UserScript==
// @name Improbable Truancy Meter
// @namespace http://www.shadedraco.com/improbabletruancy
// @include http://improbableisland.com/*
// @include http://www.improbableisland.com/*
// ==/UserScript==
var CharInfo = document.evaluate("//table[@class='charinfo']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (CharInfo) {
var LevelRow = document.evaluate("//td[@class='charinfo']/b/span[@class='colLtWhite'][text()='Level']/../../..", CharInfo, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (LevelRow) {
var Level = new Number(LevelRow.cells[1].childNodes[0].childNodes[0].textContent);
var ExperienceRow = LevelRow.parentNode.rows[LevelRow.rowIndex+1];
var ExperienceMatch = ExperienceRow.cells[1].childNodes[0].childNodes[0].textContent.match(/^([\d,]+)\/([\d,]+)$/);
var Experience = new Number(ExperienceMatch[1].replace(/,/g,''));
var ExperienceNextLevel = new Number(ExperienceMatch[2].replace(/,/g,''));
var ExperienceTable = {
1 : 0,
2 : 100,
3 : 400,
4 : 1002,
5 : 1912,
6 : 3140,
7 : 4707,
8 : 6641,
9 : 8985,
10 : 11795,
11 : 15143,
12 : 19121,
13 : 23840,
14 : 29437,
15 : 36071,
16 : 43930,
17 : 43930, // Doesn't actually exist, but I needed to put something here
};
var DKs = (ExperienceNextLevel - ExperienceTable[Level+1]) / Level / 25;
var ExperienceThisLevel = ExperienceTable[Level] + ((Level-1) * DKs * 25);
var ExperienceTruancy = ExperienceTable[Level+2] + ((Level+1) * DKs * 25);
var TruancyBarWidth = ((Experience - ExperienceNextLevel) / (ExperienceTruancy - ExperienceNextLevel)) * 100;
if (TruancyBarWidth < 0) TruancyBarWidth = 0;
if (TruancyBarWidth > 100) TruancyBarWidth = 100;
var RemainderWidth = 100 - TruancyBarWidth;
ExperienceRow.cells[1].innerHTML +=
"<span class='colLtYellow'>" +
"<table style='border: solid 1px #000000;' bgcolor='red' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+TruancyBarWidth+"%' bgcolor='"+(Experience>=ExperienceTruancy?'blue':'white')+"'></td><td width='"+RemainderWidth+"%'></td></tr></table>" +
"</span>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment