hwm_gi_battles_loader

Загрузка боёв ГИ

目前為 2021-07-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           hwm_gi_battles_loader
// @author         omne
// @namespace      omne
// @connect daily.heroeswm.ru
// @description    Загрузка боёв ГИ
// @version        0.2
// @encoding 	   utf-8
// @include        /^https{0,1}:\/\/((www|qrator|)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(pl_warlog|war).php/
// @grant    GM_xmlhttpRequest
// ==/UserScript==

(function() {

if (/pl_warlog/.test(location.href)) {
    let pers_id = document.documentElement.innerHTML.match(/pl_hunter_stat\.php\?id=([0-9]+)/)[1];
    let data = '';
    let ch = 0;
    let all_ch = 0;
    let elem = document.getElementsByClassName('sh_ResourcesItem_icon')[0];

    if (elem === undefined) {
        elem = document.getElementsByClassName('rs')[0];
    }

    elem.addEventListener("click", get_data, false);

    function get_data() {
        let elem = document.getElementsByClassName('global_container_block_header global_a_hover')[0].nextElementSibling;
        elem.insertAdjacentHTML("afterbegin", "<center><span id = 'loader'>Загрузка боёв ГИ:</span></center><BR>");
        let last_page = get_last_page();
        get_page('/pl_warlog.php?id=' + pers_id + '&page=', 0, last_page);
    }

    function get_last_page() {
        let result = get_hwm('/pl_warlog.php?id=' + pers_id + '&page=9999999');
        return result.match(/<a class=\"active\".+?([0-9]+)/)[1];
    }

    function get_page(url, page, count) {
        GM_xmlhttpRequest({
            method: "GET",
            url: url + page,
            onload: function(response) {
                let battles = response.responseText.match(/&nbsp;&nbsp;.+?<!--110--><BR>/g);
                if (battles !== null) {
                    for (let j = 0; j < battles.length; j++) {
                        data = data + battles[j].match(/warid=([0-9]+)/)[1] + "|" + battles[j].match(/show_for_all=([0-9a-zA-Z]+)/)[1] + ";";
                        ch++;
                        all_ch++;
                    }
                }
                if (ch > 100) {
                    get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
                    data = '';
                    ch = 0;
                }

                page++;
                if (page <= count) {
                    document.getElementById('loader').innerHTML = 'Загрузка боёв ГИ: ' + page + '/' + count + '. Боёв найдено: ' + all_ch;
                    get_page('/pl_warlog.php?id=' + pers_id + '&page=', page, count);
                }

                else {
                    get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
                }

            }
        });
    }
}

if (/war\.php/.test(location.href)) {
    let btype = document.documentElement.innerHTML.match(/btypeo\|([0-9]+)/)[1];
    if (btype == 110) {
        get_daily('https://daily.heroeswm.ru/services/help/gi.php' + location.search);
    }
}
function get_daily(url) {
    GM_xmlhttpRequest({
        method: "GET",
        url: url
    });
}

function get_hwm(url) {
    let xhr = new XMLHttpRequest();
    xhr.open('GET', url, false);
    xhr.send();
    return xhr.responseText;
}
})();