Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use window.location.origin everywhere for consistency #205

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions code.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
? unsafeWindow.g_strInventoryLoadURL
: typeof unsafeWindow.g_strProfileURL !== 'undefined' && unsafeWindow.g_strProfileURL != null
? unsafeWindow.g_strProfileURL + '/inventory/json/'
: 'https://steamcommunity.com/my/inventory/json/',
: window.location.origin + '/my/inventory/json/',
isLoggedIn ? unsafeWindow.g_rgWalletInfo : undefined);

var currencyId =
Expand Down Expand Up @@ -415,7 +415,7 @@
var itemId = item.assetid || item.id;
$.ajax({
type: "POST",
url: 'https://steamcommunity.com/market/sellitem/',
url: window.location.origin + '/market/sellitem/',
data: {
sessionid: sessionId,
appid: item.appid,
Expand All @@ -434,10 +434,6 @@
error: function(data) {
return callback(ERROR_FAILED, data);
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
dataType: 'json'
});
};
Expand Down Expand Up @@ -536,10 +532,6 @@
error: function(data) {
return callback(ERROR_FAILED, data);
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
dataType: 'json'
});
} catch (e) {
Expand Down Expand Up @@ -575,10 +567,6 @@
error: function(data) {
return callback(ERROR_FAILED, data);
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
dataType: 'json'
});
} catch (e) {
Expand Down Expand Up @@ -612,10 +600,6 @@
error: function(data) {
return callback(ERROR_FAILED, data);
},
crossDomain: true,
xhrFields: {
withCredentials: true
},
dataType: 'json'
});
} catch (e) {
Expand All @@ -630,8 +614,8 @@

// Get the current price history for an item.
SteamMarket.prototype.getCurrentPriceHistory = function(appid, market_name, callback) {
var url = window.location.protocol +
'//steamcommunity.com/market/pricehistory/?appid=' +
var url = window.location.origin +
'/market/pricehistory/?appid=' +
appid +
'&market_hash_name=' +
market_name;
Expand Down Expand Up @@ -699,7 +683,7 @@

// Get the item name id from a market item.
SteamMarket.prototype.getCurrentMarketItemNameId = function(appid, market_name, callback) {
var url = window.location.protocol + '//steamcommunity.com/market/listings/' + appid + '/' + market_name;
var url = window.location.origin + '/market/listings/' + appid + '/' + market_name;
$.get(url,
function(page) {
var matches = /Market_LoadOrderSpread\( (\d+) \);/.exec(page);
Expand Down Expand Up @@ -782,8 +766,8 @@
callback(ERROR_FAILED);
return;
}
var url = window.location.protocol +
'//steamcommunity.com/market/itemordershistogram?country=' +
var url = window.location.origin +
'/market/itemordershistogram?country=' +
country +
'&language=english&currency=' +
currencyId +
Expand Down Expand Up @@ -1611,7 +1595,7 @@
itemsString += '&items[]=' + encodeURIComponent(itemName) + '&qty[]=' + itemsWithQty[itemName];
}

var baseUrl = 'https://steamcommunity.com/market/multisell';
var baseUrl = window.location.origin + '/market/multisell';
var redirectUrl = baseUrl + '?appid=' + appid + '&contextid=' + contextid + itemsString;

var dialog = unsafeWindow.ShowDialog('Steam Economy Enhancer', '<iframe frameBorder="0" height="650" width="900" src="' + redirectUrl + '"></iframe>');
Expand Down Expand Up @@ -2753,7 +2737,7 @@
}

var marketListingsItemsQueue = async.queue(function(listing, next) {
$.get(window.location.protocol + '//steamcommunity.com/market/mylistings?count=100&start=' + listing,
$.get(window.location.origin + '/market/mylistings?count=100&start=' + listing,
function(data) {
if (!data || !data.success) {
next();
Expand Down