add local bypass for linkvertise

now local bypass instead of using bypass.city

Fix implemented by harryitz and adapted into a userscript

source:
31bd3b0193 (diff-4b960ee94677b8b7a092fdc10412fcf4df7c1eeea35347ce95b8540f1b9eda60)
This commit is contained in:
Amm0ni4 2024-07-15 17:27:13 +02:00
parent 9bd717fc62
commit eb4324fe3e
5 changed files with 224 additions and 6 deletions

View file

@ -4,7 +4,7 @@
// @run-at document-start
// @author Amm0ni4
// @noframes
// @version 92.3.13
// @version 92.3.14
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
@ -778,6 +778,7 @@
// @include /animesgd.net/
// @include /tucinehd.com\/links/
// @include /filecrypt.(cc|co)/
// @include /^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/
// @include /(loot-link.com|loot-links.com|lootlink.org|lootlinks.co|lootdest.(info|org|com)|links-loot.com|linksloot.net)\/s\?.*$/
// @include /(mega-enlace|acortados).com/
// @include /(work.ink|workink.click)\/.*$/

View file

@ -4,7 +4,7 @@
// @run-at document-start
// @author Amm0ni4
// @noframes
// @version 92.3.13
// @version 92.3.14
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
@ -778,6 +778,7 @@
// @include /animesgd.net/
// @include /tucinehd.com\/links/
// @include /filecrypt.(cc|co)/
// @include /^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/
// @include /(loot-link.com|loot-links.com|lootlink.org|lootlinks.co|lootdest.(info|org|com)|links-loot.com|linksloot.net)\/s\?.*$/
// @include /(mega-enlace|acortados).com/
// @include /(work.ink|workink.click)\/.*$/
@ -2042,7 +2043,7 @@
// Linkvertise
const solveThroughBypassCity = (linkShortenerUrl) => {if (!/(bypass.city|adbypass.org)/.test(linkShortenerUrl)) {redirect('https://adbypass.org/bypass?bypass=' + encodeURIComponent(linkShortenerUrl))}};
if (/linkvertise.com|(linkvertise|link-to).net/.test(url)) {
/* if (/linkvertise.com|(linkvertise|link-to).net/.test(url)) {
//solve easy case locally
let rParam = new URLSearchParams(window.location.search).get('r');
if (rParam) {
@ -2051,7 +2052,7 @@
} else {
solveThroughBypassCity(url);
}
}
} */
// bstlar.com - not supported by bypass.city anymore
// // @include /^(https?:\/\/)(?!(bypass.city|adbypass.org))(bstlar.com)/
@ -2599,6 +2600,110 @@
// ----- ----- -----
// ----- Bypass Linkvertise ------
(function() {
'use strict';
if (/^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/.test(window.location.href)) {
//easy case
let rParam = new URLSearchParams(window.location.search).get('r');
if (rParam) {
window.location.assign(atob(rParam));
// hard case
// (based on fix by harryitz: https://github.com/FastForwardTeam/FastForward/commit/31bd3b0193e06b73d8c777d640b0970175bac816#diff-4b960ee94677b8b7a092fdc10412fcf4df7c1eeea35347ce95b8540f1b9eda60)
} else {
// Function to handle the redirect logic
async function handleRedirect(data) {
if (data.currentTarget?.responseText?.includes('getDetailPageContent')) {
const response = JSON.parse(data.currentTarget.responseText);
const access_token = response.data.getDetailPageContent.access_token;
const ut = localStorage.getItem('X-LINKVERTISE-UT');
const linkvertise_link = location.pathname.replace(/\/[0-9]$/, '');
const regexMatch = linkvertise_link.match(/^\/(\d+)\/([\w-]+)$/);
if (!regexMatch) return;
const user_id = regexMatch[1];
const link_vertise_url = regexMatch[2];
const completeDetailRequest = await fetch(
`https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ut}`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'operationName': 'completeDetailPageContent',
'variables': {
'linkIdentificationInput': {
'userIdAndUrl': {
'user_id': user_id,
'url': link_vertise_url
}
},
'completeDetailPageContentInput': {
'access_token': access_token
}
},
'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}'
})
});
if (completeDetailRequest.status !== 200) return;
const completeDetailResponse = await completeDetailRequest.json();
const TARGET = completeDetailResponse.data.completeDetailPageContent.TARGET;
if (!TARGET) return;
const getTargetPageRequest = await fetch(
`https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ut}`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'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}',
'variables': {
'linkIdentificationInput': {
'userIdAndUrl': {
'user_id': user_id,
'url': link_vertise_url
}
},
'token': TARGET
}
})
}
);
if (getTargetPageRequest.status !== 200) return;
const targetPageResponse = await getTargetPageRequest.json();
const targetPageURL = targetPageResponse['data']['getDetailPageTarget']['url'];
window.location.href = targetPageURL;
}
}
// Function to intercept XHR requests
function interceptXHR() {
const open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener("load", function(data) {
handleRedirect(data);
});
open.apply(this, arguments);
};
}
// Run the XHR interceptor
interceptXHR();
}
}
})();
// ----- ------ ----------
// ----- Bypass look-link ( based on https://greasyfork.org/scripts/483207, https://codeberg.org/Amm0ni4/bypass-all-shortlinks-debloated/issues/3) -----
(function() {
'use strict';

View file

@ -424,7 +424,7 @@
// Linkvertise
const solveThroughBypassCity = (linkShortenerUrl) => {if (!/(bypass.city|adbypass.org)/.test(linkShortenerUrl)) {redirect('https://adbypass.org/bypass?bypass=' + encodeURIComponent(linkShortenerUrl))}};
if (/linkvertise.com|(linkvertise|link-to).net/.test(url)) {
/* if (/linkvertise.com|(linkvertise|link-to).net/.test(url)) {
//solve easy case locally
let rParam = new URLSearchParams(window.location.search).get('r');
if (rParam) {
@ -433,7 +433,7 @@
} else {
solveThroughBypassCity(url);
}
}
} */
// bstlar.com - not supported by bypass.city anymore
// // @include /^(https?:\/\/)(?!(bypass.city|adbypass.org))(bstlar.com)/

View file

@ -0,0 +1,111 @@
// ==UserScript==
// @name Linkvertise Bypass
// @author harryitz
// @description https://github.com/FastForwardTeam/FastForward/commit/31bd3b0193e06b73d8c777d640b0970175bac816#diff-4b960ee94677b8b7a092fdc10412fcf4df7c1eeea35347ce95b8540f1b9eda60
// @include /^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/
// @run-at document-start
// ==/UserScript==
// ----- Bypass Linkvertise ------
(function() {
'use strict';
if (/^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/.test(window.location.href)) {
//easy case
let rParam = new URLSearchParams(window.location.search).get('r');
if (rParam) {
window.location.assign(atob(rParam));
// hard case
// (based on fix by harryitz: https://github.com/FastForwardTeam/FastForward/commit/31bd3b0193e06b73d8c777d640b0970175bac816#diff-4b960ee94677b8b7a092fdc10412fcf4df7c1eeea35347ce95b8540f1b9eda60)
} else {
// Function to handle the redirect logic
async function handleRedirect(data) {
if (data.currentTarget?.responseText?.includes('getDetailPageContent')) {
const response = JSON.parse(data.currentTarget.responseText);
const access_token = response.data.getDetailPageContent.access_token;
const ut = localStorage.getItem('X-LINKVERTISE-UT');
const linkvertise_link = location.pathname.replace(/\/[0-9]$/, '');
const regexMatch = linkvertise_link.match(/^\/(\d+)\/([\w-]+)$/);
if (!regexMatch) return;
const user_id = regexMatch[1];
const link_vertise_url = regexMatch[2];
const completeDetailRequest = await fetch(
`https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ut}`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'operationName': 'completeDetailPageContent',
'variables': {
'linkIdentificationInput': {
'userIdAndUrl': {
'user_id': user_id,
'url': link_vertise_url
}
},
'completeDetailPageContentInput': {
'access_token': access_token
}
},
'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}'
})
});
if (completeDetailRequest.status !== 200) return;
const completeDetailResponse = await completeDetailRequest.json();
const TARGET = completeDetailResponse.data.completeDetailPageContent.TARGET;
if (!TARGET) return;
const getTargetPageRequest = await fetch(
`https://publisher.linkvertise.com/graphql?X-Linkvertise-UT=${ut}`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'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}',
'variables': {
'linkIdentificationInput': {
'userIdAndUrl': {
'user_id': user_id,
'url': link_vertise_url
}
},
'token': TARGET
}
})
}
);
if (getTargetPageRequest.status !== 200) return;
const targetPageResponse = await getTargetPageRequest.json();
const targetPageURL = targetPageResponse['data']['getDetailPageTarget']['url'];
window.location.href = targetPageURL;
}
}
// Function to intercept XHR requests
function interceptXHR() {
const open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener("load", function(data) {
handleRedirect(data);
});
open.apply(this, arguments);
};
}
// Run the XHR interceptor
interceptXHR();
}
}
})();
// ----- ------ ----------

View file

@ -758,6 +758,7 @@ https://paster.so/*
/animesgd.net/
/tucinehd.com\/links/
/filecrypt.(cc|co)/
/^(https?:\/\/)(?!(bypass.city|adbypass.org))(linkvertise.com|(linkvertise|link-to).net)/
/(loot-link.com|loot-links.com|lootlink.org|lootlinks.co|lootdest.(info|org|com)|links-loot.com|linksloot.net)\/s\?.*$/
/(mega-enlace|acortados).com/
/(work.ink|workink.click)\/.*$/