// ==UserScript== // @name Trophy Counter // @namespace kol.interface.unfinished // @description Counts trophies and shows missing trophies in Kingdom of Loathing. // @include https://*kingdomofloathing.com/showplayer.php* // @include http://kol.coldfront.net/thekolwiki/index.php/Trophy* // @version 1.13 // @grant GM_getValue // @grant GM_setValue // @downloadURL https://update.greasyfork.icu/scripts/4202/Trophy%20Counter.user.js // @updateURL https://update.greasyfork.icu/scripts/4202/Trophy%20Counter.meta.js // ==/UserScript== //Version 1.13 // - fix it so it works again given minor wiki changes to table sorting, and switch to https //Version 1.12 // - add @grant //Version 1.1 // - make impossible trophies dimmer //Version 1.0 function doPage() { // find table root of area interested in var yourTrophies = {}; var count = 0; var c = document.evaluate('//center[text()="Trophies:"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null); if (c.singleNodeValue) { var ts = document.evaluate('.//img',c.singleNodeValue.nextSibling,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); for (var i=0;i=0;i--) { var x = xx[i]; x.parentNode.removeChild(x); } } fixupButton(v); } function bHandler(e) { var b = GM_getValue('showmissing',''); GM_setValue('showmissing', (b ? '' : 'true')); showMissing(); } // locate all missing recipes function missing() { if (!GM_getValue('knowntrophycount')) return; var c = document.evaluate('//center[text()="Trophies:"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null); if (c.singleNodeValue && c.singleNodeValue.nextSibling) { var t = c.singleNodeValue.nextSibling; var r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); var ctr = document.createElement('center'); ctr.appendChild(document.createTextNode('Missing Trophies')); r.insertCell(-1).appendChild(ctr); r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); td = r.insertCell(-1); td.setAttribute('align','center'); var lastrc = 0; var alltrophies = JSON.parse(GM_getValue('knowntrophies','[]')); var yourtrophies = JSON.parse(GM_getValue('yourtrophies','{}')); var parity = 1; for (var i=0;i]*>/g,''); } // gather data from a kol wiki page function gather() { var trophies = []; var count=0; var ts = document.evaluate('//table[@class="sortable"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null); var t = ts.singleNodeValue; if (t) { for (var i=1;i0) { GM_setValue('knowntrophycount',count); GM_setValue('knowntrophies',JSON.stringify(trophies)); } else { console.log('t is '+((t==null) ? "null" : "ok")); } } if (window.location.href.indexOf('http://kol.coldfront.net/thekolwiki/index.php/')>=0) { gather(); } else { doPage(); }