DeepWiki

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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');