window.setInterval(addDataAboutItemPriceMinusSteamCommissionOnPageOfItemWhichIsSoldViaMonopolySystem, 200);
function roundToTwo(num)
{
return +(Math.round(num + "e+2") + "e-2");
}
function getStringWithOneCharChanged(str, index, chr)
{
if (index > str.length - 1)
{
return str;
}
return str.substr(0, index) + chr + str.substr(index + 1);
}
function addInfoAboutMoneyWithSteamCommissionIntoCellWithItemPrice(tableTdElemWithPriceValue)
{
if (tableTdElemWithPriceValue == null)
{
return;
}
if
(
(tableTdElemWithPriceValue.innerHTML.indexOf('
= 1)
{
strPriceWithoutCurrencySymbols = matches[0];
strPrefixBeforeSubstringWithPriceInInitialTdValue = strPrice.substring(0, strPrice.indexOf(strPriceWithoutCurrencySymbols));
strSuffixAfterSubstringWithPriceInInitialTdValue = strPrice.substring(strPrice.indexOf(strPriceWithoutCurrencySymbols) + strPriceWithoutCurrencySymbols.length, strPrice.length);
if (strPriceWithoutCurrencySymbols[strPriceWithoutCurrencySymbols.length - 1] == ' ')
{
strSuffixAfterSubstringWithPriceInInitialTdValue = ' ' + strSuffixAfterSubstringWithPriceInInitialTdValue;
}
}
else
{
return;
}
var positionOfLastCommaOrPointInStringWithPrice = -1;
for (var i = 0; i < strPriceWithoutCurrencySymbols.length; i++)
{
if
(
(strPriceWithoutCurrencySymbols[i] == '.') ||
(strPriceWithoutCurrencySymbols[i] == ',')
)
{
positionOfLastCommaOrPointInStringWithPrice = i;
}
}
if (positionOfLastCommaOrPointInStringWithPrice >= 0)
{
for (var i = 0; i < strPriceWithoutCurrencySymbols.length; i++)
{
if
(
(i != positionOfLastCommaOrPointInStringWithPrice) &&
(
(strPriceWithoutCurrencySymbols[i] == ',') ||
(strPriceWithoutCurrencySymbols[i] == '.')
)
)
{
strPriceWithoutCurrencySymbols = getStringWithOneCharChanged(strPriceWithoutCurrencySymbols, i, ' ');
}
}
}
strPriceWithoutCurrencySymbols = strPriceWithoutCurrencySymbols.replace(' ', '');
var strPriceWithoutCurrencySymbolsAndWithDecimalPointNotComma = strPriceWithoutCurrencySymbols.replace(',', '.');
var priceMinusSteamCommission = parseFloat(strPriceWithoutCurrencySymbolsAndWithDecimalPointNotComma) * 0.87;
priceMinusSteamCommission = roundToTwo(priceMinusSteamCommission);
var strPriceMinusSteamCommission = priceMinusSteamCommission.toLocaleString();
var positionOfDecimalPointOrComma = Math.max(strPriceMinusSteamCommission.indexOf('.'), strPriceMinusSteamCommission.indexOf(','));
if (positionOfDecimalPointOrComma > 0)
{
if (positionOfDecimalPointOrComma == strPriceMinusSteamCommission.length - 2)
{
strPriceMinusSteamCommission = strPriceMinusSteamCommission + '0';
}
}
else
{
strPriceMinusSteamCommission = strPriceMinusSteamCommission + ".00";
}
strPriceMinusSteamCommission = strPrefixBeforeSubstringWithPriceInInitialTdValue + strPriceMinusSteamCommission + strSuffixAfterSubstringWithPriceInInitialTdValue;
strPriceMinusSteamCommission = strPriceMinusSteamCommission.trim();
tableTdElemWithPriceValue.innerHTML = tableTdElemWithPriceValue.innerHTML + ' | ' + strPriceMinusSteamCommission + ' ';
}
}
function addDataAboutItemPriceMinusSteamCommissionOnPageOfItemWhichIsSoldViaMonopolySystem()
{
var xPathRes = document.evaluate("//div[@id='market_commodity_forsale_table']//table[contains(@class, 'market_commodity_orders_table')]//tr[position()>1]/td[1]", document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var arrayOfActualTdElements = [];
var actualTdElem = xPathRes.iterateNext();
var counter = 0;
while (actualTdElem)
{
arrayOfActualTdElements[counter++] = actualTdElem;
actualTdElem = xPathRes.iterateNext();
}
for (var i = 0; i < arrayOfActualTdElements.length - 1; i++)
{
addInfoAboutMoneyWithSteamCommissionIntoCellWithItemPrice(arrayOfActualTdElements[i]);
}
}