naym_event_all_factions

ass

当前为 2024-09-27 提交的版本,查看 最新版本

// ==UserScript==
// @name         naym_event_all_factions
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  ass
// @author       Something begins
// @license      none
// @match        https://www.heroeswm.ru/map_hero_event*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
// @grant        none
// ==/UserScript==
const match = document.body.innerHTML.match(/sign=(.*?)\"/);
if (!match) throw new Error("sign not found");
const sign = match[1];
console.log(sign);
let send_get = function(url) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url, false);
    xhr.overrideMimeType('text/plain; charset=windows-1251');
    xhr.send(null);
    if (xhr.status == 200) return xhr.responseText;
    return null;
};
const factions = {
    "1": {"0": "Рыцарь", "1": "Рыцарь света"},
    "2": {"0": "Некромант", "1": "Некромант - повелитель смерти"},
    "3": {"0":"Маг", "1": "Маг - разрушитель"},
    "4":{"0": "Эльф", "1":  "Эльф - заклинатель"},
    "5": {"0":"Варвар", "1": "Варвар крови", "2": "Варвар - шаман"},
    "6": {"0": "Темный эльф", "1": "Темный эльф - укротитель"},
    "7": {"0": "Демон", "1": "Демон тьмы"},
    "8":{"0":  "Гном", "1":  "Гном огня"},
    "9": {"0": "Степной варвар", "1": "Степной варвар весельчак"},
    "10": {"0": "Фараон"}
}
const parser = new DOMParser();
function changeToDemon(){
    const alt = 1;
    const fr = 1;
    send_get(`/castle.php?change_clr_to=${alt}0${fr}&sign=${sign}`);
}
const aimCoefs = {};
const KBOCoefs = {};
document.body.insertAdjacentHTML("afterbegin", `<button id = "naym_event_all_factions" style = "position: fixed; top: 30px">Посмотреть все фракции</button>`);
function processedDict(myDict){
    const sortedEntries = Object.entries(myDict).sort((a, b) => a[1] - b[1]);

    // Step 2: Convert the sorted entries back into an object
    const sortedDict = Object.fromEntries(sortedEntries);

    // Step 3: Convert the sorted object to a text string
    let sortedText = "";
    for (let [key, value] of Object.entries(sortedDict)) {
        sortedText += `${key}: ${value}\n`;
    }

    return sortedText;
}
document.querySelector("#naym_event_all_factions").addEventListener("click", event => {
    event.preventDefault();
    for (const fr of Object.keys(factions)){
        for (const alt of Object.keys(factions[fr])){
            const name = factions[fr][alt];
            console.log(name);
            //document.querySelector("#naym_event_all_factions").innerText = `Идет обработка: ${name}`;
            send_get(`/castle.php?change_clr_to=${alt}0${fr}&sign=${sign}`);
            const htmlText = send_get("/map_hero_event.php");
            const doc = parser.parseFromString(htmlText, "text/html");
            const first = doc.querySelector("#set_mobile_max_width > div.new_event_map > div.event_result_attack > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1)");
            const second = doc.querySelector("#set_mobile_max_width > div.new_event_map > div.event_result_attack > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > div:nth-child(2) > div:nth-child(4) > div:nth-child(1)");
            const firstCount = first.querySelector("#add_now_count").textContent;
            const secondCount = second.querySelector("#add_now_count").textContent;
            aimCoefs[name] = parseInt(firstCount);
            KBOCoefs[name] = parseInt(secondCount);
        }
    }
    const firstText = document.querySelector("#set_mobile_max_width > div.new_event_map > div.event_result_attack > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > div:nth-child(2) > div:nth-child(1)");
    const secondText = document.querySelector("#set_mobile_max_width > div.new_event_map > div.event_result_attack > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > div:nth-child(2) > div:nth-child(3)");


    firstText.insertAdjacentHTML("afterEnd", `<div>${processedDict(aimCoefs)}</div>`);
    secondText.insertAdjacentHTML("afterEnd", `<div>${processedDict(KBOCoefs)}</div>`);

})

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址