DeepWiki

Adds an inline display of actual effects to acquired effects in potion and item descriptions on KoL wiki pages.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           DeepWiki
// @namespace      kol.interface.unfinished
// @description    Adds an inline display of actual effects to acquired effects in potion and item descriptions on KoL wiki pages.
// @include        http://kol.coldfront.net/thekolwiki*
// @version        1.21
// @grant          GM_xmlhttpRequest
// ==/UserScript==

// Version 1.21
// - add @grant
// Version 1.2
//  - even better matching code
// Version 1.1
// - wiki changes broke matching; changed method
// Version 1.0.2
//  - better matching code
// Version 1.0.1
//  - trivial change to better match malformed effect text on the wiki

function findEffect(acq) {
    var ps = document.evaluate('//td[text()="You '+acq+' an effect: "]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
    for (var i=ps.snapshotLength-1;i>=0;i--) {
        var p = ps.snapshotItem(i);
        var pps = document.evaluate('b/a[@title]',p,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
        for (var j=pps.snapshotLength-1;j>=0;j--) {
            var pp = pps.snapshotItem(j);
            var u = 'http://kol.coldfront.net'+pp.getAttribute('href');
            getUrl(u,p.parentNode);
        }
    }
}

function getUrl(u,p) {
    GM_xmlhttpRequest({
        method: "GET",
        url: u,
        headers: {
            "User-Agent": "Mozilla/5.0",
            "Accept": "text/xml"
        },
        onload: function(response) {
            var m = response.responseText.match(/\<(p|span)\s*style=\"[^\"\>]*color:blue;\s*font-weight:bold;\s*\"\>.*/i);
            if (m) {
                var t = m[1];
                m = m[0];
                var r = new RegExp('\<(/?'+t+')( |\>)','ig');
                var mm = r.exec(m);
                var count = 0;
                var last = 0;
                while (mm) {
                    if (mm[1]==t) count++;
                    else {
                        count--;
                        if (count==0) {
                            last = r.lastIndex;
                            break;
                        }
                    }
                    mm = r.exec(m);
                }
                var eff = m.substring(0,last);
                var f = document.createElement('font');
                f.setAttribute('size','1');
                f.innerHTML='<p style="text-align:center;line-height:12px;">'+eff+'</p>'; 
                var tr = document.createElement('tr');
                var td = tr.insertCell(-1);
                td.setAttribute('colspan','2');
                td.appendChild(f);
                if (p.nextSibling)
                    p.parentNode.insertBefore(tr,p.nextSibling);
                else
                    p.parentNode.appendChild(tr);
            }
        }
    });
}

findEffect('acquire');
findEffect('lose');