OpenCaching.pl -> GC Linkifier

Zamienia numer GC na OC.pl w link

As of 29.12.2020. See ბოლო ვერსია.

// ==UserScript==
// @name           OpenCaching.pl -> GC Linkifier
// @version        1.2
// @description    Zamienia numer GC na OC.pl w link
// @description:en Turns the GC number on OC.pl into a link
// @author         Jendrej
// @match          https://opencaching.pl/viewcache.php*
// @grant          none
// @namespace https://greasyfork.org/users/26725
// ==/UserScript==

(function() {
    var divNr = 11, spanNr = 2;
    while (document.querySelector("#viewcache-baseinfo > div.list-of-details > div:nth-child(" + divNr +")").innerHTML.search("Zar") == -1) divNr++;
    while (document.querySelector("#viewcache-baseinfo > div.list-of-details > div:nth-child(" + divNr + ") > span:nth-child(" + spanNr + ")").innerHTML.search("Geocaching") == -1) spanNr++;
    var tekst = document.querySelector("#viewcache-baseinfo > div.list-of-details > div:nth-child(" + divNr + ") > span:nth-child(" + spanNr + ")").innerHTML;
    var geoCode = "GC", i = 46;
    while (tekst.charAt(i) != ')') { geoCode+= tekst.charAt(i); i++; }
    document.querySelector("#viewcache-baseinfo > div.list-of-details > div:nth-child(" + divNr + ") > span:nth-child(" + spanNr + ")").innerHTML = "<a href=\"https://www.geocaching.com/geocache/" + geoCode + "\" target=\"_blank\">" + tekst + "</a>";
})();