Vittonomica:Auction

Показ стоимости ресурсов шахт, выставленных на аукцион

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Vittonomica:Auction
// @namespace   virtonomica
// @description Показ стоимости ресурсов шахт, выставленных на аукцион
// @include     http://virtonomica.ru/*/main/auction/list/unit/open
// @version     0.01
// @grant       none
// ==/UserScript==
var run = function()
{
var win = (typeof(unsafeWindow) != 'undefined' ? unsafeWindow : top.window);

function numberFormat (number) {
        number += '';
        var parts = number.split('.');
        var int = parts[0];
        var dec = parts.length > 1 ? '.' + parts[1] : '';
        var regexp = /(\d+)(\d{3}(\s|$))/;
        while (regexp.test(int)) {
            int = int.replace(regexp, '$1 $2');
        }
        return int + dec;
}

var table = $("table.unit-list-2014");
var tr = $("tr.wborder", table);
for(var i=0; i<tr.length; i++){
   //console.log( tr.eq(i).html() );
   var el = $("div:contains('Запасы месторождения:')", tr.eq(i) );
   if ( el.length == 0) continue;
   //console.log( el.text() );
   var pos = el.text().indexOf(':');
   var amount = parseInt( el.text().substr(pos+1).replace(/\s/g, '') );
   //console.log( amount );

   var money = parseInt( el.prev().prev().text().replace('$','').replace(/\s/g, '') );
   //console.log( money );

   el.after( '<div class=amount>$' + numberFormat(Math.round( money/amount) ) +'</div>' );
}

$(".amount").css('color', 'blue');

console.log("end");
}

if(window.top == window) {
    var script = document.createElement("script");
    script.textContent = '(' + run.toString() + ')();';
    document.documentElement.appendChild(script);
}