Skip to content

Commit 38d6bdd

Browse files
committed
add the bypass request, also use it in linkvertise, better readable
1 parent 8d589cc commit 38d6bdd

File tree

3 files changed

+55
-42
lines changed

3 files changed

+55
-42
lines changed

src/bypasses/linkvertise.js

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/helpers/dom.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,26 @@ export function isGoodLink(link) {
9191
return true
9292
}
9393

94+
export async function bypassRequests(execution_method) {
95+
const rawOpen = XMLHttpRequest.prototype.open;
96+
XMLHttpRequest.prototype.open = function () {
97+
this.addEventListener('load', execution_method);
98+
rawOpen.apply(this, arguments);
99+
};
100+
101+
const rawFetch = window.fetch;
102+
window.fetch = async (requestInfo, init) =>{
103+
const result = await rawFetch(requestInfo, init);
104+
execution_method(result);
105+
return Promise.resolve(result);
106+
};
107+
}
108+
94109
export default {
95110
insertInfoBox,
96111
safelyNavigate,
97112
unsafelyNavigate,
98113
parseTarget,
99-
isGoodLink
114+
isGoodLink,
115+
bypassRequests,
100116
}

src/js/injection_script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ if (bypasses.hasOwnProperty(location.host)) {
2727
}
2828
});
2929
});
30-
}
30+
}

0 commit comments

Comments
 (0)