HWM_Resources_Cost

Отображает на странице персонажа общую стоимость ресурсов (дерево, руда, ртуть и т.п.) по цене 170/350 и общую стоимость элементов немного ниже рыночной

当前为 2015-05-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.3
// ==/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 elCell = getElementByXpath("html/body/center/table[2]/tbody/tr/td/table[4]/tbody/tr[2]/td[1]");

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>&nbsp;&nbsp;&nbsp;&nbsp;Стоимость элементов: '+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;}