diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..de1f522 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/code.user.js b/code.user.js index b8ba39b..077562e 100644 --- a/code.user.js +++ b/code.user.js @@ -115,7 +115,7 @@ return unsafeWindow.g_strInventoryLoadURL; } - let profileUrl = window.location.origin + '/my/'; + let profileUrl = `${window.location.origin}/my/`; if (unsafeWindow.g_strProfileURL) { profileUrl = unsafeWindow.g_strProfileURL; @@ -127,7 +127,7 @@ } } - return profileUrl.replace(/\/$/, '') + '/inventory/json/'; + return `${profileUrl.replace(/\/$/, '')}/inventory/json/`; } //#region Settings @@ -200,14 +200,14 @@ setSetting(SETTING_LAST_CACHE, lastCache + 1); storageSession = localforage.createInstance({ - name: 'see_session_' + lastCache + name: `see_session_${lastCache}` }); storageSession.clear(); // Clear any previous data. setSessionStorageItem('SESSION', lastCache); } else { storageSession = localforage.createInstance({ - name: 'see_session_' + getSessionStorageItem('SESSION') + name: `see_session_${getSessionStorageItem('SESSION')}` }); } @@ -215,7 +215,7 @@ try { return localStorage.getItem(name); } catch (e) { - logConsole('Failed to get local storage item ' + name + ', ' + e + '.'); + logConsole(`Failed to get local storage item ${name}, ${e}.`); return null; } } @@ -225,7 +225,7 @@ localStorage.setItem(name, value); return true; } catch (e) { - logConsole('Failed to set local storage item ' + name + ', ' + e + '.'); + logConsole(`Failed to set local storage item ${name}, ${e}.`); return false; } } @@ -234,7 +234,7 @@ try { return sessionStorage.getItem(name); } catch (e) { - logConsole('Failed to get session storage item ' + name + ', ' + e + '.'); + logConsole(`Failed to get session storage item ${name}, ${e}.`); return null; } } @@ -244,7 +244,7 @@ sessionStorage.setItem(name, value); return true; } catch (e) { - logConsole('Failed to set session storage item ' + name + ', ' + e + '.'); + logConsole(`Failed to set session storage item ${name}, ${e}.`); return false; } } @@ -429,7 +429,7 @@ function padLeftZero(str, max) { str = str.toString(); - return str.length < max ? padLeftZero('0' + str, max) : str; + return str.length < max ? padLeftZero(`0${str}`, max) : str; } function replaceNonNumbers(str) { @@ -446,7 +446,7 @@ const itemId = item.assetid || item.id; $.ajax({ type: 'POST', - url: window.location.origin + '/market/sellitem/', + url: `${window.location.origin}/market/sellitem/`, data: { sessionid: sessionId, appid: item.appid, @@ -477,7 +477,7 @@ if (isBuyOrder) { $.ajax({ type: 'POST', - url: window.location.origin + '/market/cancelbuyorder/', + url: `${window.location.origin}/market/cancelbuyorder/`, data: { sessionid: sessionId, buy_orderid: item @@ -495,7 +495,7 @@ $.ajax({ type: 'POST', - url: window.location.origin + '/market/removelisting/' + item, + url: `${window.location.origin}/market/removelisting/${item}`, data: { sessionid: sessionId }, @@ -526,7 +526,7 @@ const appid = item.appid; if (cache) { - const storage_hash = 'pricehistory_' + appid + '+' + market_name; + const storage_hash = `pricehistory_${appid}+${market_name}`; storageSession.getItem(storage_hash). then((value) => { @@ -569,7 +569,7 @@ const sessionId = readCookie('sessionid'); $.ajax({ type: 'GET', - url: this.inventoryUrlBase + 'ajaxgetgoovalue/', + url: `${this.inventoryUrlBase}ajaxgetgoovalue/`, data: { sessionid: sessionId, appid: appid, @@ -603,7 +603,7 @@ const sessionId = readCookie('sessionid'); $.ajax({ type: 'POST', - url: this.inventoryUrlBase + 'ajaxgrindintogoo/', + url: `${this.inventoryUrlBase}ajaxgrindintogoo/`, data: { sessionid: sessionId, appid: item.market_fee_app, @@ -638,7 +638,7 @@ const sessionId = readCookie('sessionid'); $.ajax({ type: 'POST', - url: this.inventoryUrlBase + 'ajaxunpackbooster/', + url: `${this.inventoryUrlBase}ajaxunpackbooster/`, data: { sessionid: sessionId, appid: item.market_fee_app, @@ -664,11 +664,7 @@ // Get the current price history for an item. SteamMarket.prototype.getCurrentPriceHistory = function(appid, market_name, callback) { - const url = window.location.origin + - '/market/pricehistory/?appid=' + - appid + - '&market_hash_name=' + - market_name; + const url = `${window.location.origin}/market/pricehistory/?appid=${appid}&market_hash_name=${market_name}`; $.get( url, @@ -685,7 +681,7 @@ } // Store the price history in the session storage. - const storage_hash = 'pricehistory_' + appid + '+' + market_name; + const storage_hash = `pricehistory_${appid}+${market_name}`; storageSession.setItem(storage_hash, data.prices); callback(ERROR_SUCCESS, data.prices, false); @@ -716,7 +712,7 @@ } const appid = item.appid; - const storage_hash = 'itemnameid_' + appid + '+' + market_name; + const storage_hash = `itemnameid_${appid}+${market_name}`; storagePersistent.getItem(storage_hash). then((value) => { @@ -736,7 +732,7 @@ // Get the item name id from a market item. SteamMarket.prototype.getCurrentMarketItemNameId = function(appid, market_name, callback) { - const url = window.location.origin + '/market/listings/' + appid + '/' + market_name; + const url = `${window.location.origin}/market/listings/${appid}/${market_name}`; $.get( url, (page) => { @@ -749,7 +745,7 @@ const item_nameid = matches[1]; // Store the item name id in the persistent storage. - const storage_hash = 'itemnameid_' + appid + '+' + market_name; + const storage_hash = `itemnameid_${appid}+${market_name}`; storagePersistent.setItem(storage_hash, item_nameid); callback(ERROR_SUCCESS, item_nameid); @@ -789,7 +785,7 @@ const appid = item.appid; if (cache) { - const storage_hash = 'itemordershistogram_' + appid + '+' + market_name; + const storage_hash = `itemordershistogram_${appid}+${market_name}`; storageSession.getItem(storage_hash). then((value) => { if (value != null) { @@ -823,20 +819,13 @@ } return; } - const url = window.location.origin + - '/market/itemordershistogram?country=' + - country + - '&language=english¤cy=' + - currencyId + - '&item_nameid=' + - item_nameid + - '&two_factor=0'; + const url = `${window.location.origin}/market/itemordershistogram?country=${country}&language=english¤cy=${currencyId}&item_nameid=${item_nameid}&two_factor=0`; $.get( url, (histogram) => { // Store the histogram in the session storage. - const storage_hash = 'itemordershistogram_' + item.appid + '+' + market_name; + const storage_hash = `itemordershistogram_${item.appid}+${market_name}`; storageSession.setItem(storage_hash, histogram); callback(ERROR_SUCCESS, histogram, false); @@ -1143,7 +1132,7 @@ } function readCookie(name) { - const nameEQ = name + '='; + const nameEQ = `${name}=`; const ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i]; @@ -1181,7 +1170,7 @@ } function logDOM(text) { - logger.innerHTML += text + '
'; + logger.innerHTML += `${text}
`; updateScroll(); } @@ -1211,14 +1200,10 @@ totals.innerHTML = ''; if (totalPriceWithFeesOnMarket > 0) { - totals.innerHTML += '
Total listed for ' + - formatPrice(totalPriceWithFeesOnMarket) + - ', you will receive ' + - formatPrice(totalPriceWithoutFeesOnMarket) + - '.
'; + totals.innerHTML += `
Total listed for ${formatPrice(totalPriceWithFeesOnMarket)}, you will receive ${formatPrice(totalPriceWithoutFeesOnMarket)}.
`; } if (totalScrap > 0) { - totals.innerHTML += '
Total scrap ' + totalScrap + '.
'; + totals.innerHTML += `
Total scrap ${totalScrap}.
`; } } @@ -1233,31 +1218,19 @@ const digits = getNumberOfDigits(totalNumberOfQueuedItems); const itemId = task.item.assetid || task.item.id; const itemName = task.item.name || task.item.description.name; - const padLeft = padLeftZero('' + totalNumberOfProcessedQueueItems, digits) + ' / ' + totalNumberOfQueuedItems; + const padLeft = `${padLeftZero(`${totalNumberOfProcessedQueueItems}`, digits)} / ${totalNumberOfQueuedItems}`; if (!err) { - logDOM(padLeft + - ' - ' + - itemName + - ' listed for ' + - formatPrice(market.getPriceIncludingFees(task.sellPrice)) + - ', you will receive ' + - formatPrice(task.sellPrice) + - '.'); - - $('#' + task.item.appid + '_' + task.item.contextid + '_' + itemId). + logDOM(`${padLeft} - ${itemName} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice))}, you will receive ${formatPrice(task.sellPrice)}.`); + + $(`#${task.item.appid}_${task.item.contextid}_${itemId}`). css('background', COLOR_SUCCESS); totalPriceWithoutFeesOnMarket += task.sellPrice; totalPriceWithFeesOnMarket += market.getPriceIncludingFees(task.sellPrice); updateTotals(); } else if (data != null && isRetryMessage(data.message)) { - logDOM(padLeft + - ' - ' + - itemName + - ' retrying listing because ' + - data.message[0].toLowerCase() + - data.message.slice(1)); + logDOM(`${padLeft} - ${itemName} retrying listing because ${data.message[0].toLowerCase()}${data.message.slice(1)}`); totalNumberOfProcessedQueueItems--; sellQueue.unshift(task); @@ -1268,17 +1241,12 @@ }, getRandomInt(30000, 45000)); } else { if (data != null && data.responseJSON != null && data.responseJSON.message != null) { - logDOM(padLeft + - ' - ' + - itemName + - ' not added to market because ' + - data.responseJSON.message[0].toLowerCase() + - data.responseJSON.message.slice(1)); + logDOM(`${padLeft} - ${itemName} not added to market because ${data.responseJSON.message[0].toLowerCase()}${data.responseJSON.message.slice(1)}`); } else { - logDOM(padLeft + ' - ' + itemName + ' not added to market.'); + logDOM(`${padLeft} - ${itemName} not added to market.`); } - $('#' + task.item.appid + '_' + task.item.contextid + '_' + itemId). + $(`#${task.item.appid}_${task.item.contextid}_${itemId}`). css('background', COLOR_ERROR); } @@ -1378,9 +1346,9 @@ totalNumberOfQueuedItems += numberOfQueuedItems; $('#inventory_items_spinner').remove(); - $('#inventory_sell_buttons').append('
' + - spinnerBlock + - '
Processing ' + numberOfQueuedItems + ' items
' + + $('#inventory_sell_buttons').append(`
${ + spinnerBlock + }
Processing ${numberOfQueuedItems} items
` + '
'); } }, @@ -1468,13 +1436,13 @@ totalNumberOfProcessedQueueItems++; const digits = getNumberOfDigits(totalNumberOfQueuedItems); - const padLeft = padLeftZero('' + totalNumberOfProcessedQueueItems, digits) + ' / ' + totalNumberOfQueuedItems; + const padLeft = `${padLeftZero(`${totalNumberOfProcessedQueueItems}`, digits)} / ${totalNumberOfQueuedItems}`; if (err != ERROR_SUCCESS) { - logConsole('Failed to get gems value for ' + itemName); - logDOM(padLeft + ' - ' + itemName + ' not turned into gems due to missing gems value.'); + logConsole(`Failed to get gems value for ${itemName}`); + logDOM(`${padLeft} - ${itemName} not turned into gems due to missing gems value.`); - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_ERROR); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_ERROR); return callback(false); } @@ -1484,18 +1452,18 @@ item, (err) => { if (err != ERROR_SUCCESS) { - logConsole('Failed to turn item into gems for ' + itemName); - logDOM(padLeft + ' - ' + itemName + ' not turned into gems due to unknown error.'); + logConsole(`Failed to turn item into gems for ${itemName}`); + logDOM(`${padLeft} - ${itemName} not turned into gems due to unknown error.`); - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_ERROR); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_ERROR); return callback(false); } logConsole('============================'); logConsole(itemName); - logConsole('Turned into ' + goo.goo_value + ' gems'); - logDOM(padLeft + ' - ' + itemName + ' turned into ' + item.goo_value_expected + ' gems.'); - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_SUCCESS); + logConsole(`Turned into ${goo.goo_value} gems`); + logDOM(`${padLeft} - ${itemName} turned into ${item.goo_value_expected} gems.`); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_SUCCESS); totalScrap += item.goo_value_expected; updateTotals(); @@ -1543,18 +1511,18 @@ totalNumberOfProcessedQueueItems++; const digits = getNumberOfDigits(totalNumberOfQueuedItems); - const padLeft = padLeftZero('' + totalNumberOfProcessedQueueItems, digits) + ' / ' + totalNumberOfQueuedItems; + const padLeft = `${padLeftZero(`${totalNumberOfProcessedQueueItems}`, digits)} / ${totalNumberOfQueuedItems}`; if (err != ERROR_SUCCESS) { - logConsole('Failed to unpack booster pack ' + itemName); - logDOM(padLeft + ' - ' + itemName + ' not unpacked.'); + logConsole(`Failed to unpack booster pack ${itemName}`); + logDOM(`${padLeft} - ${itemName} not unpacked.`); - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_ERROR); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_ERROR); return callback(false); } - logDOM(padLeft + ' - ' + itemName + ' unpacked.'); - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_SUCCESS); + logDOM(`${padLeft} - ${itemName} unpacked.`); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_SUCCESS); callback(true); } @@ -1603,9 +1571,9 @@ totalNumberOfQueuedItems += numberOfQueuedItems; $('#inventory_items_spinner').remove(); - $('#inventory_sell_buttons').append('
' + - spinnerBlock + - '
Processing ' + numberOfQueuedItems + ' items
' + + $('#inventory_sell_buttons').append(`
${ + spinnerBlock + }
Processing ${numberOfQueuedItems} items
` + '
'); } }, () => { @@ -1654,9 +1622,9 @@ totalNumberOfQueuedItems += numberOfQueuedItems; $('#inventory_items_spinner').remove(); - $('#inventory_sell_buttons').append('
' + - spinnerBlock + - '
Processing ' + numberOfQueuedItems + ' items
' + + $('#inventory_sell_buttons').append(`
${ + spinnerBlock + }
Processing ${numberOfQueuedItems} items
` + '
'); } }, () => { @@ -1701,17 +1669,17 @@ let itemsString = ''; for (const itemName in itemsWithQty) { - itemsString += '&items[]=' + encodeURIComponent(itemName) + '&qty[]=' + itemsWithQty[itemName]; + itemsString += `&items[]=${encodeURIComponent(itemName)}&qty[]=${itemsWithQty[itemName]}`; } - const baseUrl = window.location.origin + '/market/multisell'; - const redirectUrl = baseUrl + '?appid=' + appid + '&contextid=' + contextid + itemsString; + const baseUrl = `${window.location.origin}/market/multisell`; + const redirectUrl = `${baseUrl}?appid=${appid}&contextid=${contextid}${itemsString}`; - const dialog = unsafeWindow.ShowDialog('Steam Economy Enhancer', ''); + const dialog = unsafeWindow.ShowDialog('Steam Economy Enhancer', ``); dialog.OnDismiss(() => { items.forEach((item) => { const itemId = item.assetid || item.id; - $('#' + item.appid + '_' + item.contextid + '_' + itemId).css('background', COLOR_PENDING); + $(`#${item.appid}_${item.contextid}_${itemId}`).css('background', COLOR_PENDING); }); }); }); @@ -1742,9 +1710,9 @@ totalNumberOfQueuedItems += numberOfQueuedItems; $('#inventory_items_spinner').remove(); - $('#inventory_sell_buttons').append('
' + - spinnerBlock + - '
Processing ' + numberOfQueuedItems + ' items
' + + $('#inventory_sell_buttons').append(`
${ + spinnerBlock + }
Processing ${numberOfQueuedItems} items
` + '
'); } } @@ -1797,7 +1765,7 @@ true, (err, history, cachedHistory) => { if (err) { - logConsole('Failed to get price history for ' + itemName); + logConsole(`Failed to get price history for ${itemName}`); if (err == ERROR_FAILED) { failed += 1; @@ -1809,7 +1777,7 @@ true, (err, histogram, cachedListings) => { if (err) { - logConsole('Failed to get orders histogram for ' + itemName); + logConsole(`Failed to get orders histogram for ${itemName}`); if (err == ERROR_FAILED) { failed += 1; @@ -1832,11 +1800,7 @@ ); - logConsole('Sell price: ' + - sellPrice / 100.0 + - ' (' + - market.getPriceIncludingFees(sellPrice) / 100.0 + - ')'); + logConsole(`Sell price: ${sellPrice / 100.0} (${market.getPriceIncludingFees(sellPrice) / 100.0})`); sellQueue.push({ item: item, @@ -1851,7 +1815,7 @@ } // Initialize the inventory UI. - function initializeInventoryUI() { + function initializeInventoryUI() { const isOwnInventory = unsafeWindow.g_ActiveUser.strSteamId == unsafeWindow.g_steamID; let previousSelection = -1; // To store the index of the previous selection. updateInventoryUI(isOwnInventory); @@ -2031,11 +1995,11 @@ $('.sell_selected').show(); if (canSellSelectedItemsManually(items)) { $('.sell_manual').show(); - $('.sell_manual > span').text('Sell ' + selectedItems + (selectedItems == 1 ? ' Item Manual' : ' Items Manual')); + $('.sell_manual > span').text(`Sell ${selectedItems}${selectedItems == 1 ? ' Item Manual' : ' Items Manual'}`); } else { $('.sell_manual').hide(); } - $('.sell_selected > span').text('Sell ' + selectedItems + (selectedItems == 1 ? ' Item' : ' Items')); + $('.sell_selected > span').text(`Sell ${selectedItems}${selectedItems == 1 ? ' Item' : ' Items'}`); } }); } @@ -2049,7 +2013,7 @@ } else { $('.turn_into_gems').show(); $('.turn_into_gems > span'). - text('Turn ' + selectedItems + (selectedItems == 1 ? ' Item Into Gems' : ' Items Into Gems')); + text(`Turn ${selectedItems}${selectedItems == 1 ? ' Item Into Gems' : ' Items Into Gems'}`); } }); } @@ -2063,7 +2027,7 @@ } else { $('.unpack_booster_packs').show(); $('.unpack_booster_packs > span'). - text('Unpack ' + selectedItems + (selectedItems == 1 ? ' Booster Pack' : ' Booster Packs')); + text(`Unpack ${selectedItems}${selectedItems == 1 ? ' Booster Pack' : ' Booster Packs'}`); } }); } @@ -2075,7 +2039,7 @@ } function updateInventorySelection(selectedItem) { - const item_info = $('#iteminfo' + unsafeWindow.iActiveSelectView); + const item_info = $(`#iteminfo${unsafeWindow.iActiveSelectView}`); if (!item_info.length) { return; @@ -2089,7 +2053,7 @@ const item_info_id = item_info.attr('id'); // Move scrap to bottom, this is of little interest. - const scrap = $('#' + item_info_id + '_scrap_content'); + const scrap = $(`#${item_info_id}_scrap_content`); scrap.next().insertBefore(scrap); // Skip unmarketable items @@ -2114,19 +2078,19 @@ } }; - const ownerActions = $('#' + item_info_id + '_item_owner_actions'); + const ownerActions = $(`#${item_info_id}_item_owner_actions`); // Move market link to a button - ownerActions.append('View in Community Market'); - $('#' + item_info_id + '_item_market_actions > div:nth-child(1) > div:nth-child(1)').hide(); + ownerActions.append(`View in Community Market`); + $(`#${item_info_id}_item_market_actions > div:nth-child(1) > div:nth-child(1)`).hide(); // ownerActions is hidden on other games' inventories, we need to show it to have a "Market" button visible ownerActions.show(); const isBoosterPack = selectedItem.name.toLowerCase().endsWith('booster pack'); if (isBoosterPack) { - const tradingCardsUrl = '/market/search?q=&category_753_Game%5B%5D=tag_app_' + selectedItem.market_fee_app + '&category_753_item_class%5B%5D=tag_item_class_2&appid=753'; - ownerActions.append('
View trading cards in Community Market'); + const tradingCardsUrl = `/market/search?q=&category_753_Game%5B%5D=tag_app_${selectedItem.market_fee_app}&category_753_item_class%5B%5D=tag_item_class_2&appid=753`; + ownerActions.append(`
View trading cards in Community Market`); } if (getSettingWithDefault(SETTING_QUICK_SELL_BUTTONS) != 1) { @@ -2143,7 +2107,7 @@ false, (err, histogram) => { if (err) { - logConsole('Failed to get orders histogram for ' + (selectedItem.name || selectedItem.description.name)); + logConsole(`Failed to get orders histogram for ${selectedItem.name || selectedItem.description.name}`); return; } @@ -2152,16 +2116,18 @@ return; } - const groupMain = $('
' + - '
Sell
' + - histogram.sell_order_table + - '
' + - '
Buy
' + - histogram.buy_order_table + - '
' + - '
'); + const groupMain = $(`
+
+
Sell
+ ${histogram.sell_order_table} +
+
+
Buy
+ ${histogram.buy_order_table} +
+
`); - $('#' + item_info_id + '_item_market_actions > div').after(groupMain); + $(`#${item_info_id}_item_market_actions > div`).after(groupMain); // Generate quick sell buttons. let prices = []; @@ -2182,30 +2148,25 @@ let buttons = ' '; prices.forEach((e) => { - buttons += - '' + - '' + - '' + - formatPrice(e) + - '' + - '' + - '' + - ''; + buttons += ` + + ${formatPrice(e)} + + + `; }); - $('#' + item_info_id + '_item_market_actions', item_info).append(buttons); + $(`#${item_info_id}_item_market_actions`, item_info).append(buttons); - $('#' + item_info_id + '_item_market_actions', item_info).append('
' + - '' + - ' ' + - '' + - '➜ Sell' + - '' + - '' + - '' + - '
'); + $(`#${item_info_id}_item_market_actions`, item_info).append(`
+   + + + ➜ Sell + + + +
`); $('.quick_sell').on( 'click', @@ -2225,7 +2186,7 @@ $('.quick_sell_custom').on( 'click', () => { - let price = $('#quick_sell_input', $('#' + item_info_id + '_item_market_actions', item_info)).val() * 100; + let price = $('#quick_sell_input', $(`#${item_info_id}_item_market_actions`, item_info)).val() * 100; price = market.getPriceBeforeFees(price); totalNumberOfQueuedItems++; @@ -2244,7 +2205,7 @@ function updateInventoryUI(isOwnInventory) { // Remove previous containers (e.g., when a user changes inventory). $('#inventory_sell_buttons').remove(); - $('#price_options').remove(); + $('#see_settings_modal').remove(); $('#inventory_reload_button').remove(); $('#see_settings').remove(); @@ -2256,21 +2217,27 @@ const showMiscOptions = appId == 753; const TF2 = appId == 440; - const sellButtons = $(''); + let buttonsHtml = ` + Sell All Items + Sell All Duplicate Items + + + `; + + if (showMiscOptions) { + buttonsHtml += ` + Sell All Cards + + `; + } else if (TF2) { + buttonsHtml += 'Sell All Crates'; + } + + const sellButtons = $(`
${buttonsHtml}
`); const reloadButton = $('Reload Inventory'); @@ -2416,12 +2383,12 @@ if (currentPage == PAGE_INVENTORY || currentPage == PAGE_TRADEOFFER) { // Gets the active inventory. - function getActiveInventory() { + function getActiveInventory() { return unsafeWindow.g_ActiveInventory; } // Sets the prices for the items. - function setInventoryPrices(items) { + function setInventoryPrices(items) { inventoryPriceQueue.kill(); items.forEach((item) => { @@ -2486,7 +2453,7 @@ true, (err, histogram, cachedListings) => { if (err) { - logConsole('Failed to get orders histogram for ' + itemName); + logConsole(`Failed to get orders histogram for ${itemName}`); if (err == ERROR_FAILED) { failed += 1; @@ -2503,16 +2470,11 @@ ? '∞' : formatPrice(market.getPriceIncludingFees(sellPrice)); - const elementName = (currentPage == PAGE_TRADEOFFER ? '#item' : '#') + - item.appid + - '_' + - item.contextid + - '_' + - item.id; + const elementName = `${(currentPage == PAGE_TRADEOFFER ? '#item' : '#')}${item.appid}_${item.contextid}_${item.id}`; const element = $(elementName); $('.inventory_item_price', element).remove(); - element.append('' + itemPrice + ''); + element.append(`${itemPrice}`); return callback(true, cachedListings); } @@ -2653,7 +2615,7 @@ true, (errorPriceHistory, history, cachedHistory) => { if (errorPriceHistory) { - logConsole('Failed to get price history for ' + game_name); + logConsole(`Failed to get price history for ${game_name}`); if (errorPriceHistory == ERROR_FAILED) { failed += 1; @@ -2665,7 +2627,7 @@ true, (errorHistogram, histogram, cachedListings) => { if (errorHistogram) { - logConsole('Failed to get orders histogram for ' + game_name); + logConsole(`Failed to get orders histogram for ${game_name}`); if (errorHistogram == ERROR_FAILED) { failed += 1; @@ -2684,14 +2646,14 @@ $( '.market_table_value > span:nth-child(1) > span:nth-child(1) > span:nth-child(1)', listingUI - ).append(' ➤ ' + - highestBuyOrderPrice + - ''); + ).append(` ➤ ${ + highestBuyOrderPrice + }`); logConsole('============================'); logConsole(JSON.stringify(listing)); - logConsole(game_name + ': ' + asset.name); - logConsole('Current price: ' + price / 100.0); + logConsole(`${game_name}: ${asset.name}`); + logConsole(`Current price: ${price / 100.0}`); // Calculate two prices here, one without the offset and one with the offset. // The price without the offset is required to not relist the item constantly when you have the lowest price (i.e., with a negative offset). @@ -2714,17 +2676,13 @@ const sellPriceWithoutOffsetWithFees = market.getPriceIncludingFees(sellPriceWithoutOffset); - logConsole('Calculated price: ' + - sellPriceWithoutOffsetWithFees / 100.0 + - ' (' + - sellPriceWithoutOffset / 100.0 + - ')'); + logConsole(`Calculated price: ${sellPriceWithoutOffsetWithFees / 100.0} (${sellPriceWithoutOffset / 100.0})`); - listingUI.addClass('price_' + sellPriceWithOffset); + listingUI.addClass(`price_${sellPriceWithOffset}`); $('.market_listing_my_price', listingUI).last().prop( 'title', - 'The best price is ' + formatPrice(sellPriceWithoutOffsetWithFees) + '.' + `The best price is ${formatPrice(sellPriceWithoutOffsetWithFees)}.` ); if (sellPriceWithoutOffsetWithFees < price) { @@ -2807,7 +2765,7 @@ const decodedMarketHashName = decodeURIComponent(itemName.substring(marketHashNameIndex)); let newAssetId = -1; - unsafeWindow.RequestFullInventory(market.inventoryUrl + item.appid + '/' + item.contextid + '/', {}, null, null, (transport) => { + unsafeWindow.RequestFullInventory(`${market.inventoryUrl + item.appid}/${item.contextid}/`, {}, null, null, (transport) => { if (transport.responseJSON && transport.responseJSON.success) { const inventory = transport.responseJSON.rgInventory; @@ -2957,7 +2915,7 @@ const marketListingsItemsQueue = async.queue( (listing, next) => { $.get( - window.location.origin + '/market/mylistings?count=100&start=' + listing, + `${window.location.origin}/market/mylistings?count=100&start=${listing}`, (data) => { if (!data || !data.success) { increaseMarketProgress(); @@ -3036,10 +2994,10 @@ // Buy orders and listings confirmations are not grouped like the sell listings, add this so pagination works there as well. if (!$(this).attr('id')) { - $(this).attr('id', 'market-listing-' + e); + $(this).attr('id', `market-listing-${e}`); - $(this).append('
'); - $('.market_listing_row', $(this)).appendTo($('#market-listing-container-' + e)); + $(this).append(`
`); + $('.market_listing_row', $(this)).appendTo($(`#market-listing-container-${e}`)); } else { $(this).children().last().addClass('market_listing_see'); } @@ -3073,7 +3031,7 @@ } } - $('#my_market_selllistings_number').append(', ' + formatPrice(totalPriceBuyer) + ' ➤ ' + formatPrice(totalPriceSeller) + ''); + $('#my_market_selllistings_number').append(`, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}`); } @@ -3206,9 +3164,9 @@ $('.market_pagesize_options').hide(); // Show the spinner so the user knows that something is going on. - $('.my_market_header').eq(0).append('
' + - spinnerBlock + - '
Loading market listings
' + + $('.my_market_header').eq(0).append(`
${ + spinnerBlock + }
Loading market listings
` + '
'); while (currentCount < totalCount) { @@ -3294,7 +3252,7 @@ asc = false; } - $(this).text($(this).text().replace(' ' + arrow_down, '').replace(' ' + arrow_up, '')); + $(this).text($(this).text().replace(` ${arrow_down}`, '').replace(` ${arrow_up}`, '')); }); let market_listing_selector; @@ -3305,7 +3263,7 @@ } else if (isName) { market_listing_selector = $('.market_listing_table_header', elem).children().eq(3); } - market_listing_selector.text(market_listing_selector.text() + ' ' + (asc ? arrow_up : arrow_down)); + market_listing_selector.text(`${market_listing_selector.text()} ${asc ? arrow_up : arrow_down}`); if (list.sort == null) { return; @@ -3384,12 +3342,12 @@ function getListingFromLists(listingid) { // Sometimes listing ids are contained in multiple lists (?), use the last one available as this is the one we're most likely interested in. for (let i = marketLists.length - 1; i >= 0; i--) { - let values = marketLists[i].get('market_listing_item_name', 'mylisting_' + listingid + '_name'); + let values = marketLists[i].get('market_listing_item_name', `mylisting_${listingid}_name`); if (values != null && values.length > 0) { return values[0]; } - values = marketLists[i].get('market_listing_item_name', 'mbuyorder_' + listingid + '_name'); + values = marketLists[i].get('market_listing_item_name', `mbuyorder_${listingid}_name`); if (values != null && values.length > 0) { return values[0]; } @@ -3400,63 +3358,50 @@ function removeListingFromLists(listingid) { for (let i = 0; i < marketLists.length; i++) { - marketLists[i].remove('market_listing_item_name', 'mylisting_' + listingid + '_name'); - marketLists[i].remove('market_listing_item_name', 'mbuyorder_' + listingid + '_name'); + marketLists[i].remove('market_listing_item_name', `mylisting_${listingid}_name`); + marketLists[i].remove('market_listing_item_name', `mbuyorder_${listingid}_name`); } } // Initialize the market UI. - function initializeMarketUI() { + function initializeMarketUI() { $('.market_header_text').append('