@@ -5,14 +5,12 @@ import {CustomElement, InjectAppend, InjectionMode} from '../injectors';
55import { FloatElement } from '../custom' ;
66import { fetchListingTime } from './helpers' ;
77import '../common/ui/steam-button' ;
8- import { ProveTradesToken } from '../../bridge/handlers/prove_trades_token' ;
9- import { ClientSend } from '../../bridge/client' ;
108
119@CustomElement ( )
1210@InjectAppend ( '.tradehistoryrow .tradehistory_content' , InjectionMode . CONTINUOUS )
1311export class TradeProof extends FloatElement {
1412 @state ( )
15- private message : string | undefined ;
13+ private proofNumber : number | undefined ;
1614
1715 @state ( )
1816 private isProcessing = false ;
@@ -22,12 +20,12 @@ export class TradeProof extends FloatElement {
2220 }
2321
2422 render ( ) {
25- return this . message
26- ? html ` < span > ${ this . message } </ span > `
23+ return this . proofNumber
24+ ? html ` < span > Proof: ${ this . proofNumber } </ span > `
2725 : html `
2826 < csfloat-steam-button
2927 @click ="${ this . onClick } "
30- .text ="${ this . isProcessing ? 'Proving ...' : 'Prove Trade on CSFloat' } "
28+ .text ="${ this . isProcessing ? 'Computing Proof ...' : 'CSFloat Proof ' } "
3129 >
3230 </ csfloat-steam-button >
3331 ` ;
@@ -36,17 +34,14 @@ export class TradeProof extends FloatElement {
3634 private async onClick ( ) {
3735 this . isProcessing = true ;
3836
39- const token = document
40- . getElementById ( 'application_config' )
41- ?. getAttribute ( 'data-loyalty_webapi_token' )
42- ?. replace ( '"' , '' )
43- . replace ( '"' , '' ) ;
44-
37+ const index = $J ( '.tradehistoryrow' ) . index ( $J ( this ) . parent ( ) . parent ( ) ) ;
4538 try {
46- const resp = await ClientSend ( ProveTradesToken , { token} ) ;
47- this . message = resp . message ;
48- } catch ( e : any ) {
49- alert ( e . toString ( ) ) ;
39+ this . proofNumber = await fetchListingTime ( index ) ;
40+ } catch ( e ) {
41+ alert (
42+ "Failed to parse time, make sure you're on an english version of the page by appending ?l=english to the url"
43+ ) ;
5044 }
45+ this . isProcessing = false ;
5146 }
5247}
0 commit comments