smithHelper

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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