Skip to content

Commit

Permalink
Removed mapping classid's in trade offer pages
Browse files Browse the repository at this point in the history
  • Loading branch information
juliarose committed May 26, 2024
1 parent 1c61f63 commit f6ddc04
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 71 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,8 @@
## [2.2.0] - 2023-12-25
### Added
- Halloween 2023 effects.
- Smissmas 2023 effects.
- Smissmas 2023 effects.

## [2.2.1] - 2024-05-26
### Fixed
- A potential issue where items display the wrong item.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steam-trade-offer-enhancer",
"version": "2.2.0",
"version": "2.2.1",
"description": "Fork of [Steam Trade Offer Enhancer by scholtzm](https://github.com/scholtzm/steam-trade-offer-enhancer) with extra features and performance enhancements. This userscript has many features useful for Team Fortress 2 trading.",
"main": "steam.trade.offer.enhancer.user.js",
"dependencies": {
Expand Down
13 changes: 1 addition & 12 deletions src/js/steamcommunity.com.profiles.tradeoffers.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,7 @@ function({ $, VERSION, WINDOW, addAttributesToHoverItems }) {
Array.from(itemsList).forEach((itemsEl) => {
const itemsArr = Array.from(itemsEl.getElementsByClassName('trade_item'));
const getClassInfo = (itemEl) => {
const classinfo = itemEl.getAttribute('data-economy-item');
// I believe item classes always remain static
const translateClass = {
'classinfo/440/339892/11040578': 'classinfo/440/101785959/11040578',
'classinfo/440/339892/11040559': 'classinfo/440/101785959/11040578',
'classinfo/440/107348667/11040578': 'classinfo/440/101785959/11040578'
};

return (
translateClass[classinfo] ||
classinfo
);
return itemEl.getAttribute('data-economy-item');
};
// has multiples of the same item
const hasMultipleSameItems = Boolean(function() {
Expand Down
2 changes: 1 addition & 1 deletion src/meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Steam Trade Offer Enhancer
// @description Browser script to enhance Steam trade offers.
// @version 2.2.0
// @version 2.2.1
// @author Julia
// @namespace http://steamcommunity.com/profiles/76561198080179568/
// @updateURL https://github.com/juliarose/steam-trade-offer-enhancer/raw/master/steam.trade.offer.enhancer.meta.js
Expand Down
2 changes: 1 addition & 1 deletion steam.trade.offer.enhancer.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Steam Trade Offer Enhancer
// @description Browser script to enhance Steam trade offers.
// @version 2.2.0
// @version 2.2.1
// @author Julia
// @namespace http://steamcommunity.com/profiles/76561198080179568/
// @updateURL https://github.com/juliarose/steam-trade-offer-enhancer/raw/master/steam.trade.offer.enhancer.meta.js
Expand Down
65 changes: 10 additions & 55 deletions steam.trade.offer.enhancer.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Steam Trade Offer Enhancer
// @description Browser script to enhance Steam trade offers.
// @version 2.2.0
// @version 2.2.1
// @author Julia
// @namespace http://steamcommunity.com/profiles/76561198080179568/
// @updateURL https://github.com/juliarose/steam-trade-offer-enhancer/raw/master/steam.trade.offer.enhancer.meta.js
Expand Down Expand Up @@ -1075,18 +1075,7 @@
Array.from(itemsList).forEach((itemsEl) => {
const itemsArr = Array.from(itemsEl.getElementsByClassName('trade_item'));
const getClassInfo = (itemEl) => {
const classinfo = itemEl.getAttribute('data-economy-item');
// I believe item classes always remain static
const translateClass = {
'classinfo/440/339892/11040578': 'classinfo/440/101785959/11040578',
'classinfo/440/339892/11040559': 'classinfo/440/101785959/11040578',
'classinfo/440/107348667/11040578': 'classinfo/440/101785959/11040578'
};

return (
translateClass[classinfo] ||
classinfo
);
return itemEl.getAttribute('data-economy-item');
};
// has multiples of the same item
const hasMultipleSameItems = Boolean(function() {
Expand Down Expand Up @@ -2447,7 +2436,12 @@
// perform actions
// add elements to page
(function() {
const controlsHTML = `
const $tradeBox = page.$tradeBoxContents;
// clearfix to add after inventories to fix height bug in firefox
const $clear = $('<div style="clear: both"/>');

// add summary and control HTML to the trade box
$tradeBox.append(`
<div id="controls">
<div class="trade_rule selectableNone"/>
<div class="selectableNone">Add multiple items:</div>
Expand Down Expand Up @@ -2497,23 +2491,11 @@
</div>
</div>
</div>
`;
const itemSummaryHTML = `
<div id="tradeoffer_items_summary">
<div class="items_summary" id="your_summary"></div>
<div class="items_summary" id="their_summary"></div>
</div>
`;
const $tradeBox = page.$tradeBoxContents;
// clearfix to add after inventories to fix height bug in firefox
const $clear = $('<div style="clear: both"/>');
const html = [
controlsHTML,
itemSummaryHTML
].join('').replace(/\s{2,}/g, ' ');

// add it
$tradeBox.append(html);
`);

// add the clear after inventories
$clear.insertAfter(page.$inventories);
Expand Down Expand Up @@ -3096,7 +3078,7 @@
(function() {
const DEPS = (function() {
// current version number of script
const VERSION = '2.2.0';
const VERSION = '2.2.1';
// our window object for accessing globals
const WINDOW = unsafeWindow;
// dependencies to provide to each page script
Expand Down Expand Up @@ -3136,33 +3118,6 @@

return result;
},
/**
* Get difference between two arrays
* @param {Array} arr1 - First array
* @param {Array} arr2 - Second array
* @returns {Array} Array with values removed
*/
difference: function(arr1, arr2) {
return arr1.filter((a) => {
return arr2.indexOf(a) === -1;
});
},
/**
* Check if a variable is undefined, null, or an empty string ('')
* @param {*} value - Value to check
* @returns {Boolean} Is empty?
*/
isEmpty: function(value) {
return value === undefined || value === null || value === '';
},
/**
* Get unique values from array
* @param {Array} arr - Array of basic items (strings, numbers)
* @returns {Array} Array with unique values
*/
uniq: function(arr) {
return [...new Set(arr)];
},
/**
* Get a list of IDs from a comma-seperated string
* @param {String} str - Comma-seperated string
Expand Down

0 comments on commit f6ddc04

Please sign in to comment.