Skip to content

Commit

Permalink
Replace getPriceFromMarketListing
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Jul 15, 2024
1 parent fcb9d44 commit bb4c7b0
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions code.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit bb4c7b0

Please sign in to comment.