// ==UserScript== // @name Tattoo Counter // @namespace kol.interface.unfinished // @description Counts tattoos and shows missing tattoos in Kingdom of Loathing. // @include http://*kingdomofloathing.com/account_tattoos.php* // @include http://127.0.0.1:*/account_tattoos.php* // @include http://kol.coldfront.net/thekolwiki/index.php/Tattoo // @include http://kol.coldfront.net/thekolwiki/index.php/Tattoos // @version 1.2.2 // @grant GM_getValue // @grant GM_setValue // @downloadURL none // ==/UserScript== //Version 1.2.2 // - add @grant //Version 1.2.1 // - fix for minor format editing of wiki page //Version 1.2 // - update for latest sspd tattoo //Version 1.1 // - fixed to handle changed html presentation from wiki update //Version 1.0 function doPage() { // find table root of area interested in var yourTattoos = {}; var count = 0; var c = document.evaluate('//b[text()="Change Your Tattoo:"]',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null); if (c.singleNodeValue) { var ts = document.evaluate('//form[@action="account_tattoos.php"]//img',document,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(); } // show all missing tattoos function missing() { if (!GM_getValue('knowntattoocount')) return; var tbl = document.evaluate('//form[@action="account_tattoos.php"]//center/table',document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null); if (tbl.singleNodeValue) { var t = tbl.singleNodeValue; var r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); var c = r.insertCell(-1); c.setAttribute('colspan','12'); c.setAttribute('align','center'); c.appendChild(document.createTextNode('Missing Tattoos')); r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); c = r.insertCell(-1); c.setAttribute('align','center'); var lastrc = 0; var alltattoos = JSON.parse(GM_getValue('knowntattoos','[]')); var eventtattoos = JSON.parse(GM_getValue('knowneventtattoos','[]')); var yourtattoos = JSON.parse(GM_getValue('yourtattoos','{}')); var parity = 1; for (var sigil in alltattoos) { if (!yourtattoos[sigil]) { if (lastrc==0) { r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); } r.insertCell(-1); c = r.insertCell(-1); c.setAttribute('valign','center'); lastrc = (lastrc+1) % 6; var img = document.createElement('img'); img.setAttribute('src','http://images.kingdomofloathing.com/otherimages/sigils/'+sigil); img.setAttribute('width','50'); img.setAttribute('height','50'); img.setAttribute('title','Missing tattoo: '+sigil.replace(/\.gif$/,'')); var lnk = alltattoos[sigil]; if (lnk!='#') { var a = document.createElement('a'); img.setAttribute('border','0'); a.setAttribute('href','http://kol.coldfront.net'+lnk); a.setAttribute('target','_blank'); a.appendChild(img); img = a; } c.appendChild(img); } } for (var e in eventtattoos) { var found = false; var lastSigil; var yourSigil; for (var sigil in eventtattoos[e]) { lastSigil = eventtattoos[e][sigil]; if (yourtattoos[eventtattoos[e][sigil]]) { yourSigil = eventtattoos[e][sigil]; found = true; } } if (!found || lastSigil!=yourSigil) { if (lastrc==0) { r = t.insertRow(-1); r.setAttribute('class','showmissingaddition'); } r.insertCell(-1); c = r.insertCell(-1); c.setAttribute('valign','center'); lastrc = (lastrc+1) % 6; var img = document.createElement('img'); img.setAttribute('src','http://images.kingdomofloathing.com/otherimages/sigils/'+lastSigil); img.setAttribute('width','50'); img.setAttribute('height','50'); if (!found) img.setAttribute('title','Missing tattoo: '+lastSigil.replace(/\.gif$/,'')); else img.setAttribute('title','You have tattoo version '+yourSigil.replace(/\.gif$/,'')+', but are still missing tattoo '+lastSigil.replace(/\.gif$/,'')); c.appendChild(img); } } } return true; } // gather a section of tattoos function gatherTattoos(a,tattoos) { var count=0; var t = a.nextSibling; while (t && t.tagName!='TABLE') { if (t.tagName=='H2') return; t = t.nextSibling; } if (t) { var ts = document.evaluate('.//img',t,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null); for (var i=0;i0) { GM_setValue('knowntattoocount',count); GM_setValue('knowntattoos',JSON.stringify(tattoos)); GM_setValue('knowneventtattoos',JSON.stringify(eventTattoos)); } } if (window.location.href.indexOf('http://kol.coldfront.net/thekolwiki/index.php/')>=0) { gather(); } else { doPage(); }