File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
packages/steam-multisell/src/market Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' steam-multisell ' : patch
3+ ---
4+
5+ feat: 增加延迟,避免限流
Original file line number Diff line number Diff line change @@ -37,11 +37,18 @@ function createMultiCancelButton() {
3737 const sessionid = window . g_sessionID
3838
3939 const cancel = async ( id : string ) => {
40- const res = await fetch (
41- `https://steamcommunity.com/market/removelisting/${ id } ` ,
42- { body : new URLSearchParams ( { sessionid } ) , method : 'POST' }
43- )
44- await sleep ( 200 )
40+ await fetch ( `https://steamcommunity.com/market/removelisting/${ id } ` , {
41+ body : new URLSearchParams ( { sessionid } ) ,
42+ method : 'POST' ,
43+ } )
44+
45+ document . getElementById ( `mylisting_${ id } ` ) ?. remove ( )
46+
47+ const countEl = document . getElementById ( 'my_market_selllistings_number' )
48+ if ( countEl ) {
49+ const count = parseInt ( countEl . textContent || '0' , 10 ) - 1
50+ countEl . textContent = count . toString ( )
51+ }
4552 }
4653
4754 document
@@ -82,8 +89,16 @@ function createMultiCancelButton() {
8289 )
8390 } )
8491
92+ let lock = false
8593 button . addEventListener ( 'click' , async ( ) => {
86- await Promise . all ( ids . map ( cancel ) )
94+ if ( lock ) return
95+ lock = true
96+
97+ for ( let i = 0 , size = 3 ; i < ids . length ; i += size ) {
98+ const chunk = ids . slice ( i , i + size )
99+ await Promise . all ( chunk . map ( cancel ) )
100+ await sleep ( 200 )
101+ }
87102 window . location . reload ( )
88103 } )
89104
You can’t perform that action at this time.
0 commit comments