battleHelper

Помощь

当前为 2023-01-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           battleHelper
// @author         omne
// @namespace      omne
// @description    Помощь
// @version        0.32
// @include        /^https{0,1}:\/\/((www|qrator|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(war|warlog|leader_guild|leader_army).php/
// @grant          GM_xmlhttpRequest
// @license        GNU GPLv3
// ==/UserScript==

(function() {
    let e = document.createElement('script');
    e.src = "https://daily." + location.host.substring(location.host.indexOf(".")+ 1) + "/i/js/dailyJS.js?v=" + Date.now();
    document.head.appendChild(e);
    
    if ((location.pathname.indexOf("war.php") >= 0)||(location.pathname.indexOf("warlog.php") >= 0)) {
        var warid = location.search.match(/warid=([0-9]+)/)[1];
        var key = "";
        if (location.search.match(/show_for_all=([0-9a-zA-Z]+)/)) {
            key = location.search.match(/show_for_all=([0-9a-zA-Z]+)/)[1];
        };
        var att = 0;
        var unit = ["", "", "", "", "", "", "", ""];
        getAtb(0);
        document.getElementById("confirm_ins").addEventListener("click", function () {setTimeout (getAtb(1), 4000);}, false);
        function getAtb(r) {
            GM_xmlhttpRequest({
                method: "GET",
                url: "/battle.php?lastturn=-3&warid=" + warid + "&show_for_all=" + key,
                onload: function(res) {
                    let info = "<style>.cont{position:relative;display:inline-block}.count {position: absolute;right: 0;bottom: 0;color: #f5c140;text-shadow: 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000;font-size: 1rem;font-weight: bold;}</style>";
                    info += "<b>Стартовый бонус АТБ</b><BR>";
                    if (res.responseText == "t=950turns=") {
                        if (r == 1) {
                            info += "Ошибка загрузки, начните бой и обновите страницу!";
                        } else {
                            return false;
                        }
                    }
                    let data = res.responseText.substring(res.responseText.indexOf(";/") + 2).split(";");
                    for (let i = 0; i < data.length - 1; i++) {
                        if (data[i].indexOf("|rock|") != -1) {
                            continue;
                        }
                        let unitNum = Number(data[i].substring(1, 3));
                        let armyNum = Number(data[i].substring(5 + 0*6, 5 + 1*6)) - 1;
                        let count = Number(data[i].substring(5 + 12*6, 5 + 13*6));
                        let startAtb = 100 - Number(data[i].substring(5 + 9*6, 5 + 10*6));
                        let img;
                        if (data[i].indexOf("|hero|") == -1) {
                            img = data[i].substring(5 + 24*6, data[i].indexOf("|"));
                        } else {
                            img = data[i].split("|")[8].substring(1);
                        }
                        img = img.substring(0, img.length - 3);
                        unit[armyNum] += "<div class = 'cont'><img width = '40px' src='/i/portraits/" + img + "anip40.png'><div class = 'count'>" + startAtb + "</div></div>";
                    }
                    for (let i = 0; i < unit.length; i++) {
                        if (unit[i] != "") {
                            info += "Команда №" + (i + 1) + "<BR>" + unit[i] + "<BR>";
                        }
                    }
                    let elem = [];
                    elem[0] = document.querySelector("#chat_format");
                    elem[1] = document.querySelector("#chat_format_classic");
                    elem[0].innerHTML = info + elem[0].innerHTML;
                    elem[1].innerHTML = info + elem[1].innerHTML;
                }
            });
        }
    }
})();