Отображает на странице персонажа общую стоимость ресурсов (дерево, руда, ртуть и т.п.) по цене 170/350 и общую стоимость элементов немного ниже рыночной
目前為
// ==UserScript==
// @name HWM_Resources_Cost
// @description Отображает на странице персонажа общую стоимость ресурсов (дерево, руда, ртуть и т.п.) по цене 170/350 и общую стоимость элементов немного ниже рыночной
// @namespace Zeleax
// @author Zeleax
// @include http://www.heroeswm.ru/pl_info.php*
// @include http://178.248.235.15/pl_info.php*
// @include http://www.lordswm.com/pl_info.php*
// @grant none
// @version 1.4
// ==/UserScript==
// Цены
var resPrices = {"wood": 170, "ore": 170, "mercury": 350, "sulfur": 350, "crystal": 350, "gem": 350} // ресурсы
var elPrices = {"абразив":250, "змеиный яд":100, "клык тигра":1800, "ледяной кристалл":3500, "лунный камень":9950, "огненный кристалл":2400, "осколок метеорита":1800, " цветок ведьм":80, "цветок ветров":3500, "цветок папоротника":150, "ядовитый гриб":350}; // элементы
// Ресурсы
var resRow = getElementByXpath("/html/body/center/table/tbody/tr/td/table[1]/tbody/tr[1]/td[2]/table/tbody/tr");
var resArr = resRow.getElementsByTagName('img');
var resSum = 0;
for(var i=0, el; el=resArr[i]; i++)
if((imgname = el.getAttribute('src')) && (res = /([a-z]{1,}).gif/.exec(imgname)) && (res[1]) && (rPrice = resPrices[res[1]]) )
resSum += parseInt(el.parentNode.nextSibling.firstChild.innerHTML.replace(',',''), 10) * rPrice;
createCell(resRow.insertCell(-1), " = "+resSum, 'resRow');
// Элементы
var tbl = getElementByXpath("/html/body/center/table[2]");
var t = document.getElementsByTagName("td");
var res = null;
for(i=0;el=t[i];i++) if(el.innerHTML == '<b>Ресурсы</b>') {res=el; break;};
if(res) elCell = res.parentNode.nextSibling.firstChild;
var elSum = 0;
var myRe = /<b>(\D+)<\D+: (\d+)/g;
while (res = myRe.exec(elCell.innerHTML))
if(ePrice= elPrices[res[1]]) elSum += parseInt(res[2])*ePrice;
if(elSum>0) elCell.innerHTML += '<br> стоимость элементов: '+elSum;
// create DIV element and append to the table cell
function createCell(cell, text, style) {
var div = document.createElement('div'), // create DIV element
txt = document.createTextNode(text); // create text node
div.appendChild(txt); // append text node to the DIV
div.setAttribute('class', style); // set DIV class attribute
div.setAttribute('className', style); // set DIV class attribute for IE (?!)
cell.appendChild(div); // append DIV to the table cell
}
function getElementByXpath (path) {return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;}