smithHelper

Помощь кузнецу

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           smithHelper
// @author         omne
// @namespace      omne
// @description    Помощь кузнецу
// @version        0.2
// @include        /^https{0,1}:\/\/((www|qrator|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/inventory.php/
// @license        GNU GPLv3
// ==/UserScript==

(function() {
    if (/inventory/.test(location.href)) {
        let transfers = document.querySelectorAll(".inv_request_info");
        for (let i = 0; i < transfers.length; i++) {
            if (transfers[i].innerHTML.indexOf("ремонт") > 0) {
                let art_id = transfers[i].innerHTML.match(/art_info.php.id=([^\"]+)/)[1];
                let gold = Number(transfers[i].querySelectorAll("b")[1].innerHTML.replace(",", ""));
                let perc = Number(transfers[i].innerHTML.match(/\(([0-9]+)%\)/)[1]);
                let repair_cost = Math.round(gold/perc*100);
                let repair_score = (repair_cost/4000).toFixed(2);
                let date = new Date(Date.now() + Math.round(repair_cost/4*60*60));
                let profit = gold - repair_cost;
                let divs = transfers[i].querySelectorAll("div");
                console.log(divs);
                for (let j = 0; j < divs.length; j++) {
                    if (divs[j].innerHTML.indexOf("Прочноcть:") >= 0) {
                        divs[j].innerHTML += "<BR>+<B>" + repair_score + "</b> ГК, до <b>" + date.getHours() + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes():date.getMinutes()) + "</b>, прибыль <b style = 'color:" + (profit >= 0 ? "green":"red") + "'>" + profit + "</b>";
                    }
                }
            }
        }
    }
})();