Zeptor / l2dbMarketCryCost

// ==UserScript==
// @name         l2dbMarketCryCost
// @version      1.0
// @description  Adds info about crystal cost if buy in Giran
// @author       Zeptor
// @include      http://l2db.ru/items/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    var priceTr = $("table:[class='esTable']>tbody>tr>td:contains('цена')").parent();
    var cryTr = $("table:[class='esTable']>tbody>tr>td:contains('Класс')").parent();
    if (priceTr.length == 1 && cryTr.length == 1) {
        var price = $(priceTr.children("td")[1]).text();
        var cryRaw = $(cryTr.children("td")[1]).text();
        var match = cryRaw.match(/[^()]+(?=\))/g);
        if (match) {
            var cryNum = match[0];
            console.log(cryNum);
            var cryCost = price * 1.1 / cryNum;
            console.log(cryCost);
            $(cryTr.children("td")[1]).text(cryRaw + " / (" + cryCost.toFixed(2) + ")");
        }
    }
})();