smithHelper

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

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

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

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           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>";
                    }
                }
            }
        }
    }
})();