HWM_replace_links_to_current_mirror

Все ссылки на другие зеркала игры HWM заменяет на ссылки текущего сайта-зеркала игры

Stan na 13-04-2022. Zobacz najnowsza wersja.

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

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

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         HWM_replace_links_to_current_mirror
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Все ссылки на другие зеркала игры HWM заменяет на ссылки текущего сайта-зеркала игры
// @author       Zeleax
// @include      /https:\/\/(www.heroeswm.ru|www.lordswm.com|my.lordswm.com)\/.*/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    var cur_hostname= location.hostname;
    var arr_hosts=['www.heroeswm.ru','my.lordswm.com','www.lordswm.com'].filter(function(o){ // сайты в ссылках для замены на текущее зеркало
        return o !== cur_hostname
    });
    var i, list;

    list = getL('//a[contains(@href,"//") and not(contains(@href,"'+cur_hostname+'"))]');

    for (i=0; i<list.snapshotLength; i++){
        for(var j=0; j<arr_hosts.length; j++){
            list.snapshotItem(i).href= list.snapshotItem(i).href.replace(arr_hosts[j], cur_hostname);
        }
    }

    // заменяем картинки
    if(/lordswm/.test(location.hostname)){
        list = getL('//img[contains(@src,"dcdn.heroeswm.ru")]');
        for(i=0; i<list.snapshotLength; i++){
            list.snapshotItem(i).src=list.snapshotItem(i).src.replace('dcdn.heroeswm.ru','cfcdn.lordswm.com');
        }
    }
})();

function getL(xpath,el,docObj){return (docObj?docObj:document).evaluate(xpath,(el?el:(docObj?docObj.body:document.body)),null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);}