diff --git a/code.user.js b/code.user.js index 1b46977..b8bb3ac 100644 --- a/code.user.js +++ b/code.user.js @@ -2392,22 +2392,6 @@ }); }, 1); - // Gets the price, in cents, from a market listing. - function getPriceFromMarketListing(listing) { - var priceLabel = listing.trim().replace('--', '00'); - - // Fixes RUB, which has a dot at the end. - if (priceLabel[priceLabel.length - 1] === '.' || priceLabel[priceLabel.length - 1] === ",") - priceLabel = priceLabel.slice(0, -1); - - // For round numbers (e.g., 100 EUR). - if (priceLabel.indexOf('.') === -1 && priceLabel.indexOf(',') === -1) { - priceLabel = priceLabel + ',00'; - } - - return parseInt(replaceNonNumbers(priceLabel)); - } - function marketListingsQueueWorker(listing, ignoreErrors, callback) { var asset = unsafeWindow.g_rgAssets[listing.appid][listing.contextid][listing.assetid]; @@ -2457,7 +2441,7 @@ var listingUI = $(getListingFromLists(listing.listingid).elm); var game_name = asset.type; - var price = getPriceFromMarketListing($('.market_listing_price > span:nth-child(1) > span:nth-child(1)', listingUI).text()); + var price = unsafeWindow.GetPriceValueAsInt($('.market_listing_price > span:nth-child(1) > span:nth-child(1)', listingUI).text()); if (price <= getSettingWithDefault(SETTING_PRICE_MIN_CHECK_PRICE) * 100) { $('.market_listing_my_price', listingUI).last().css('background', COLOR_PRICE_NOT_CHECKED); @@ -2857,8 +2841,8 @@ if (actionButton == null || actionButton.toLowerCase().includes('cancelmarketbuyorder')) return {}; - var priceBuyer = getPriceFromMarketListing($('.market_listing_price > span:nth-child(1) > span:nth-child(1)', listing.elm).text()); - var priceSeller = getPriceFromMarketListing($('.market_listing_price > span:nth-child(1) > span:nth-child(3)', listing.elm).text()); + var priceBuyer = unsafeWindow.GetPriceValueAsInt($('.market_listing_price > span:nth-child(1) > span:nth-child(1)', listing.elm).text()); + var priceSeller = unsafeWindow.GetPriceValueAsInt($('.market_listing_price > span:nth-child(1) > span:nth-child(3)', listing.elm).text()); var itemIds = actionButton.split(','); var appid = replaceNonNumbers(itemIds[2]); var contextid = replaceNonNumbers(itemIds[3]);