Enhanced_Steam
Enhanced_Steam copied to clipboard
Show item price in local currency
inventory_market_helper() shows USD prices for the items.
One could add country= and currency= parameters to the priceoverview call but I don't know how to determine the currency ID of the user.
Added the following to determine country (which works), any suggestions for the currency part?
diff --git a/enhancedsteam.js b/enhancedsteam.js
index 947e12b..96261b3 100644
--- a/enhancedsteam.js
+++ b/enhancedsteam.js
@@ -3525,7 +3525,21 @@ function inventory_market_helper(response) {
if (marketable == 0) { $('.es_item_action').remove(); return; }
$("#es_item" + item).html("<img src='http://cdn.steamcommunity.com/public/images/login/throbber.gif'><span>"+ localized_strings[language].loading+"</span>");
- var url = "http://steamcommunity.com/market/priceoverview/?country=DE¤cy=3&appid=" + global_id + "&market_hash_name=" + hash_name;
+ // Get country code from the Steam cookie
+ var cookies = document.cookie;
+ var matched = cookies.match(/fakeCC=([a-z]{2})/i);
+ var cc = "us";
+ if (matched != null && matched.length == 2) {
+ cc = matched[1];
+ } else {
+ matched = cookies.match(/steamCC(?:_\d+){4}=([a-z]{2})/i);
+ if (matched != null && matched.length == 2) {
+ cc = matched[1];
+ }
+ }
+ var currency = 3;
+
+ var url = "http://steamcommunity.com/market/priceoverview/?country=" + cc + "¤cy=" + currency + "&appid=" + global_id + "&market_hash_name=" + hash_name;
get_http(url, function (txt) {
data = JSON.parse(txt);
$("#es_item" + item).html("");