// ==UserScript== // @name JHunz's KOL Insult tracker // @namespace hunsley@gmail.com // @version 1 // @description Tracks which insults have been received for Insult Beer Pong in KOL kingdom of loathing kingdomofloathing // @include *kingdomofloathing.com/fight.php* // @include http://127.0.0.1:60*/fight.php* // @include *kingdomofloathing.com/cove.php* // @include http://127.0.0.1:60*/cove.php* // @include *kingdomofloathing.com/charpane.php* // @include http://127.0.0.1:60*/charpane.php* // @include *kingdomofloathing.com/beerpong.php* // @include http://127.0.0.1:60*/beerpong.php* // @include *kingdomofloathing.com/choice.php* // @include http://127.0.0.1:60*/choice.php* // @include *kingdomofloathing.com/valhalla.php* // @include http://127.0.0.1:60*/valhalla.php* // @downloadURL https://update.greasyfork.icu/scripts/4090/JHunz%27s%20KOL%20Insult%20tracker.user.js // @updateURL https://update.greasyfork.icu/scripts/4090/JHunz%27s%20KOL%20Insult%20tracker.meta.js // ==/UserScript== // // Version 1.0 02/02/2008 First release. Features: Tracks which, and how many, insults you have received. Displays this on the cove, when you get an insult, and on the Beer Pong Step up button. Also automatically selects the correct retort if you have it. // Version 1.1 02/25/2008 Updated to reset tracking upon ascension instead of the previous inferior trigger. // const VERSION=11; //auto-update checking code var lastUpdateCheck = GM_getValue('lastUpdateCheck','NEVER'); var curTime = new Date().getTime(); if ((lastUpdateCheck == 'NEVER') || (parseInt(lastUpdateCheck) < (curTime - 86400000))) { GM_setValue('lastUpdateCheck',''+curTime); GM_xmlhttpRequest({method: 'GET',url: 'http://userscripts.org/scripts/source/22178.user.js', onload: function(responseDetails) { var bodyText = responseDetails.responseText; var curVersionNum = parseInt((bodyText.split("const VERSION="))[1].split(";")[0]); if (curVersionNum > VERSION) { GM_setValue('outOfDate','true'); } else { GM_setValue('outOfDate','false'); } } }); } var curVersion = GM_getValue('curVersion','0'); if (parseInt(curVersion) != VERSION) { GM_setValue('curVersion',VERSION); GM_setValue('outOfDate','false'); } //Nag user with update link if the script is out of date var outOfDate = GM_getValue('outOfDate'); if((outOfDate == 'true') && (window.location.pathname != "/charpane.php")) { var newElement = document.createElement('tr'); newElement.innerHTML = '
A new version of the Insult Tracker is available! Update
'; //insert the counter at the top of the page var element = document.getElementsByTagName("tr")[0]; element.parentNode.insertBefore(newElement,element); } if (window.location.pathname == "/charpane.php") { // Get the current name var charName = document.getElementsByTagName("b")[0].textContent; GM_setValue('curCharName',charName); } else { var charName = GM_getValue('curCharName','UNDEFINED'); } if (charName == 'UNDEFINED') { return false; } //Initialization insultsList=GM_getValue(charName + '.insults','UNDEFINED'); if(insultsList == 'UNDEFINED') { insultsList = '0;0;0;0;0;0;0;0'; GM_setValue(charName + '.insults',insultsList); } insultsArray = insultsList.split(";"); var numInsults = 0; for (var i=0;i'; //Insert it at the top of the page var element = document.getElementsByTagName("tr")[0]; element.parentNode.insertBefore(newElement,element); } //Valhalla resets the insult counter if (window.location.pathname == "/valhalla.php") { insultsList = '0;0;0;0;0;0;0;0'; GM_setValue(charName + '.insults',insultsList); } //Fight page processing if (window.location.pathname == "/fight.php") { monname = document.evaluate("//SPAN[@id='monname']//text()",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.data; if (monname.match("pirate") || monname.match("Pirate")) { var whichItem = document.evaluate('//select[@name="whichitem"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; var bigBookNode = document.evaluate('//select[@name="whichitem"]//option[@value="2947"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; if (bigBookNode) { bigBookNode.textContent = 'The Big Book of Pirate Insults (' + numInsults + '\/8)'; } var thatHurtsNode; //Catch the insults textnodes = document.evaluate("//text()",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null); for (var i=0;i