@@ -14,53 +14,50 @@ export default class Linkvertise extends BypassDefinition {
1414 }
1515
1616 const lvt_this = this ;
17+ this . helpers . bypassRequests ( async data => {
18+ if ( data . currentTarget ?. responseText ?. includes ( 'tokens' ) ) {
19+ const response = JSON . parse ( data . currentTarget . responseText ) ;
1720
18- const rawOpen = window . XMLHttpRequest . prototype . open ;
21+ if ( ! response . data . valid )
22+ return lvt_this . helpers . insertInfoBox ( 'Please solve the captcha, afterwards we can immediately redirect you' ) ;
1923
20- window . XMLHttpRequest . prototype . open = function ( ) {
21- this . addEventListener ( 'load' , data => {
22- if ( data . currentTarget ?. responseText ?. includes ( 'tokens' ) ) {
23- const response = JSON . parse ( data . currentTarget . responseText ) ;
24+ const target_token = response . data . tokens [ 'TARGET' ] ;
25+ const ut = localStorage . getItem ( "X-LINKVERTISE-UT" ) ;
26+ const linkvertise_link = location . pathname . replace ( / \/ [ 0 - 9 ] $ / , "" ) ;
2427
25- if ( ! response . data . valid )
26- return lvt_this . helpers . insertInfoBox ( 'Please solve the captcha, afterwards we can immediately redirect you' ) ;
28+ let result = await fetch ( `https://publisher.linkvertise.com/api/v1/redirect/link/static ${ linkvertise_link } ?X-Linkvertise-UT= ${ ut } ` ) ;
29+ let json = await result . json ( ) ;
2730
28- const target_token = response . data . tokens [ 'TARGET' ] ;
29- const ut = localStorage . getItem ( "X-LINKVERTISE-UT" ) ;
30- const linkvertise_link = location . pathname . replace ( / \/ [ 0 - 9 ] $ / , "" ) ;
31+ if ( json ?. data . link . target_type !== 'URL' ) {
32+ return lvt_this . helpers . insertInfoBox ( 'Due to copyright reasons we are not bypassing linkvertise stored content (paste, download etc)' ) ;
33+ }
34+
35+ if ( ! json ?. data . link . id ) return ;
3136
37+ const json_body = {
38+ serial : btoa ( JSON . stringify ( {
39+ timestamp : new Date ( ) . getTime ( ) ,
40+ random : "6548307" ,
41+ link_id : json . data . link . id
42+ } ) ) ,
43+ token : target_token
44+ } ;
3245
33- fetch ( `https://publisher.linkvertise.com/api/v1/redirect/link/static${ linkvertise_link } ?X-Linkvertise-UT=${ ut } ` ) . then ( r => r . json ( ) ) . then ( json => {
34- if ( json ?. data . link . target_type !== 'URL' ) {
35- return insertInfoBox ( 'Due to copyright reasons we are not bypassing linkvertise stored content (paste, download etc)' ) ;
36- }
37- if ( json ?. data . link . id ) {
38- const json_body = {
39- serial : btoa ( JSON . stringify ( {
40- timestamp : new Date ( ) . getTime ( ) ,
41- random : "6548307" ,
42- link_id : json . data . link . id
43- } ) ) ,
44- token : target_token
45- }
46- fetch ( `https://publisher.linkvertise.com/api/v1/redirect/link${ linkvertise_link } /target?X-Linkvertise-UT=${ ut } ` , {
47- method : "POST" ,
48- body : JSON . stringify ( json_body ) ,
49- headers : {
50- "Accept" : 'application/json' ,
51- "Content-Type" : 'application/json'
52- }
53- } ) . then ( r => r . json ( ) ) . then ( json => {
54- if ( json ?. data . target ) {
55- lvt_this . helpers . safelyNavigate ( json . data . target )
56- }
57- } )
58- }
59- } )
46+ result = await fetch ( `https://publisher.linkvertise.com/api/v1/redirect/link${ linkvertise_link } /target?X-Linkvertise-UT=${ ut } ` , {
47+ method : "POST" ,
48+ body : JSON . stringify ( json_body ) ,
49+ headers : {
50+ "Accept" : 'application/json' ,
51+ "Content-Type" : 'application/json'
52+ }
53+ } ) ;
54+ json = await result . json ( ) ;
55+
56+ if ( json ?. data . target ) {
57+ lvt_this . helpers . safelyNavigate ( json . data . target )
6058 }
61- } ) ;
62- rawOpen . apply ( this , arguments ) ;
63- }
59+ }
60+ } ) ;
6461 }
6562}
6663
0 commit comments