Skip to content

Commit b3d920b

Browse files
authored
feature: enable multi sell shortcut on inventory (#264)
* feature: enable multi sell shortcut on inventory * fix: use URLSearchParams for link construction
1 parent 8a71162 commit b3d920b

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@
305305
}
306306
}
307307
},
308+
"inventory_sell_multiple": {
309+
"message": "Sell multiple items"
310+
},
308311
"inventory_badge_level": {
309312
"message": "Your badge level: $level$",
310313
"placeholders": {

scripts/community/inventory.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
return;
234234
}
235235

236-
LoadQuickSellInformation( element, commodityID, abortController.signal );
236+
LoadQuickSellInformation( element, commodityID, description, asset,abortController.signal );
237237
} );
238238
}
239239

@@ -246,9 +246,11 @@
246246
/**
247247
* @param {HTMLElement} element
248248
* @param {string} commodityID
249+
* @param {any} description
250+
* @param {any} asset
249251
* @param {AbortSignal} signal
250252
*/
251-
function LoadQuickSellInformation( element, commodityID, signal )
253+
function LoadQuickSellInformation( element, commodityID, description, asset, signal )
252254
{
253255
const histogramParams = new URLSearchParams();
254256
histogramParams.set( 'country', window.g_rgWalletInfo.wallet_country );
@@ -432,6 +434,20 @@
432434
rows[ 0 ].after( row );
433435
}
434436
}
437+
438+
if( description.commodity )
439+
{
440+
const params = new URLSearchParams();
441+
params.set( 'appid', asset.appid );
442+
params.set( 'contextid', asset.contextid );
443+
params.set( 'items[]', window.GetMarketHashName( description ) );
444+
445+
const multiSellBtn = document.createElement( 'a' );
446+
multiSellBtn.className = 'steamdb_multi_sell';
447+
multiSellBtn.href = `https://steamcommunity.com/market/multisell?${params.toString()}`;
448+
multiSellBtn.textContent = i18n.inventory_sell_multiple;
449+
element.append( multiSellBtn );
450+
}
435451
}
436452

437453
element.classList.add( 'steamdb_quicksell_visible' );

scripts/community/profile_inventory.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ if( document.getElementById( 'inventory_link_753' ) )
3939
inventory_sell_at: _t( 'inventory_sell_at' ),
4040
inventory_list_at_title: _t( 'inventory_list_at_title' ),
4141
inventory_sell_at_title: _t( 'inventory_sell_at_title' ),
42+
inventory_sell_multiple: _t( 'inventory_sell_multiple' ),
4243
inventory_badge_level: _t( 'inventory_badge_level' ),
4344
inventory_badge_foil_level: _t( 'inventory_badge_foil_level' ),
4445
inventory_badge_none: _t( 'inventory_badge_none' ),

styles/inventory.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,32 @@ steamdb-iteminfo-footer {
169169
padding: 0 4px;
170170
}
171171
}
172+
173+
.steamdb_multi_sell {
174+
height: 24px;
175+
padding-left: 12px;
176+
padding-right: 12px;
177+
margin-top: 12px;
178+
border-radius: 2px;
179+
font-size: 12px;
180+
line-height: 16px;
181+
letter-spacing: 0;
182+
min-width: 100%;
183+
box-sizing: border-box;
184+
display: inline-flex;
185+
justify-content: center;
186+
align-items: center;
187+
cursor: pointer;
188+
background: #3d4450;
189+
color: white;
190+
transition-property: opacity, background, color, box-shadow;
191+
transition-duration: 0.2s;
192+
transition-timing-function: ease-out;
193+
194+
&:hover {
195+
background: #67707b;
196+
}
197+
}
172198
}
173199

174200
.steamdb_badge_info + .steamdb_quicksell {

0 commit comments

Comments
 (0)