1
- import BypassDefinition from './BypassDefinition.js'
1
+ import BypassDefinition from './BypassDefinition.js' ;
2
2
3
3
export default class Linkvertise extends BypassDefinition {
4
- constructor ( ) {
5
- super ( )
6
- // custom bypass required bases can be set here
7
- }
8
-
9
- execute ( ) {
10
- if ( / [ \? & ] r = / . test ( window . location . href . toString ( ) ) ) {
11
- const urlParams = new URLSearchParams ( window . location . search )
12
- const r = urlParams . get ( 'r' )
13
- this . helpers . safelyNavigate ( atob ( decodeURIComponent ( r ) ) )
4
+ constructor ( ) {
5
+ super ( )
14
6
}
15
7
16
- 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 )
20
-
21
- if ( ! response . data . valid )
22
- return lvt_this . helpers . insertInfoBox (
23
- 'Please solve the captcha, afterwards we can immediately redirect you'
24
- )
25
-
26
- const target_token = response . data . tokens [ 'TARGET' ]
27
- const ut = localStorage . getItem ( 'X-LINKVERTISE-UT' )
28
- const linkvertise_link = location . pathname . replace ( / \/ [ 0 - 9 ] $ / , '' )
29
-
30
- let result = await fetch (
31
- `https://publisher.linkvertise.com/api/v1/redirect/link/static${ linkvertise_link } ?X-Linkvertise-UT=${ ut } `
32
- )
33
- let json = await result . json ( )
34
-
35
- if ( json ?. data . link . target_type !== 'URL' ) {
36
- return lvt_this . helpers . insertInfoBox (
37
- 'Due to copyright reasons we are not bypassing linkvertise stored content (paste, download etc)'
38
- )
8
+ execute ( ) {
9
+ if ( / [ ? & ] r = / . test ( window . location . href . toString ( ) ) ) {
10
+ const urlParams = new URLSearchParams ( window . location . search )
11
+ const r = urlParams . get ( 'r' )
12
+ this . helpers . safelyNavigate ( atob ( decodeURIComponent ( r ) ) )
39
13
}
40
14
41
- if ( ! json ?. data . link . id ) return
15
+ this . helpers . bypassRequests ( async data => {
16
+ if ( data . currentTarget ?. responseText ?. includes ( 'getDetailPageContent' ) ) {
17
+ const response = JSON . parse ( data . currentTarget . responseText )
18
+ const access_token = response . data . getDetailPageContent . access_token ;
19
+ const ut = localStorage . getItem ( 'X-LINKVERTISE-UT' )
20
+ const linkvertise_link = location . pathname . replace ( / \/ [ 0 - 9 ] $ / , '' )
21
+ const regexMatch = linkvertise_link . match ( / ^ \/ ( \d + ) \/ ( [ \w - ] + ) $ / ) ;
22
+ if ( ! regexMatch ) return ;
23
+ const user_id = regexMatch [ 1 ] ;
24
+ const link_vertise_url = regexMatch [ 2 ] ;
42
25
43
- const json_body = {
44
- serial : btoa (
45
- JSON . stringify ( {
46
- timestamp : new Date ( ) . getTime ( ) ,
47
- random : '6548307' ,
48
- link_id : json . data . link . id
49
- } )
50
- ) ,
51
- token : target_token
52
- }
26
+ const completeDetailRequest = await fetch (
27
+ `https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ ut } ` , {
28
+ method : 'POST' ,
29
+ headers : {
30
+ Accept : 'application/json' ,
31
+ 'Content-Type' : 'application/json'
32
+ } ,
33
+ body : JSON . stringify ( {
34
+ 'operationName' : 'completeDetailPageContent' ,
35
+ 'variables' : {
36
+ 'linkIdentificationInput' : {
37
+ 'userIdAndUrl' : {
38
+ 'user_id' : user_id ,
39
+ 'url' : link_vertise_url
40
+ }
41
+ } ,
42
+ 'completeDetailPageContentInput' : {
43
+ 'access_token' : access_token
44
+ }
45
+ } ,
46
+ 'query' : 'mutation completeDetailPageContent($linkIdentificationInput: PublicLinkIdentificationInput!, $completeDetailPageContentInput: CompleteDetailPageContentInput!) {\n completeDetailPageContent(\n linkIdentificationInput: $linkIdentificationInput\n completeDetailPageContentInput: $completeDetailPageContentInput\n ) {\n CUSTOM_AD_STEP\n TARGET\n additional_target_access_information {\n remaining_waiting_time\n can_not_access\n should_show_ads\n has_long_paywall_duration\n __typename\n }\n __typename\n }\n}'
47
+ } )
48
+ } ) ;
49
+ if ( completeDetailRequest . status !== 200 ) return ;
50
+ const completeDetailResponse = await completeDetailRequest . json ( ) ;
51
+ const TARGET = completeDetailResponse . data . completeDetailPageContent . TARGET ;
52
+ if ( ! TARGET ) return ;
53
53
54
- result = await fetch (
55
- `https://publisher.linkvertise.com/api/v1/redirect/link${ linkvertise_link } /target?X-Linkvertise-UT=${ ut } ` ,
56
- {
57
- method : 'POST' ,
58
- body : JSON . stringify ( json_body ) ,
59
- headers : {
60
- Accept : 'application/json' ,
61
- 'Content-Type' : 'application/json'
54
+ const getTargetPageRequest = await fetch (
55
+ `https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ ut } ` , {
56
+ method : 'POST' ,
57
+ headers : {
58
+ Accept : 'application/json' ,
59
+ 'Content-Type' : 'application/json'
60
+ } ,
61
+ body : JSON . stringify ( {
62
+ 'query' : 'mutation getDetailPageTarget($linkIdentificationInput: PublicLinkIdentificationInput!, $token: String!) {\n getDetailPageTarget(\n linkIdentificationInput: $linkIdentificationInput\n token: $token\n ) {\n type\n url\n paste\n short_link_title\n __typename\n }\n}' ,
63
+ 'variables' : {
64
+ 'linkIdentificationInput' : {
65
+ 'userIdAndUrl' : {
66
+ 'user_id' : user_id ,
67
+ 'url' : link_vertise_url
68
+ }
69
+ } ,
70
+ 'token' : TARGET
71
+ }
72
+ } )
73
+ }
74
+ )
75
+ if ( getTargetPageRequest . status !== 200 ) return ;
76
+ const targetPageResponse = await getTargetPageRequest . json ( ) ;
77
+ const targetPageURL = targetPageResponse [ 'data' ] [ 'getDetailPageTarget' ] [ 'url' ] ;
78
+ this . helpers . safelyNavigate ( targetPageURL ) ;
62
79
}
63
- }
64
- )
65
- json = await result . json ( )
66
-
67
- if ( json ?. data . target ) {
68
- lvt_this . helpers . safelyNavigate ( json . data . target )
69
- }
70
- }
71
- } )
72
- }
80
+ } )
81
+ }
73
82
}
74
83
75
- export const matches = [ 'linkvertise.com' , 'linkvertise.net' , 'link-to.net' ]
84
+ export const matches = [ 'linkvertise.com' , 'linkvertise.net' , 'link-to.net' ]
0 commit comments