From eb4324fe3e13adea97efe9fe8534ce0352a74285 Mon Sep 17 00:00:00 2001 From: Amm0ni4 Date: Mon, 15 Jul 2024 17:27:13 +0200 Subject: [PATCH] add local bypass for linkvertise now local bypass instead of using bypass.city Fix implemented by harryitz and adapted into a userscript source: https://github.com/FastForwardTeam/FastForward/commit/31bd3b0193e06b73d8c777d640b0970175bac816#diff-4b960ee94677b8b7a092fdc10412fcf4df7c1eeea35347ce95b8540f1b9eda60 --- Bypass_All_Shortlinks.meta.js | 3 +- Bypass_All_Shortlinks.user.js | 111 +++++++++++++++++++++++++- extra_bypasses/extra_bypasses.user.js | 4 +- extra_bypasses/linkvertise.user.js | 111 ++++++++++++++++++++++++++ supported_sites.txt | 1 + 5 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 extra_bypasses/linkvertise.user.js diff --git a/Bypass_All_Shortlinks.meta.js b/Bypass_All_Shortlinks.meta.js index 908e11d..f5d0a08 100644 --- a/Bypass_All_Shortlinks.meta.js +++ b/Bypass_All_Shortlinks.meta.js @@ -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)\/.*$/ diff --git a/Bypass_All_Shortlinks.user.js b/Bypass_All_Shortlinks.user.js index bead5bf..f9cc50c 100644 --- a/Bypass_All_Shortlinks.user.js +++ b/Bypass_All_Shortlinks.user.js @@ -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'; diff --git a/extra_bypasses/extra_bypasses.user.js b/extra_bypasses/extra_bypasses.user.js index 3b3713e..d8077fb 100644 --- a/extra_bypasses/extra_bypasses.user.js +++ b/extra_bypasses/extra_bypasses.user.js @@ -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)/ diff --git a/extra_bypasses/linkvertise.user.js b/extra_bypasses/linkvertise.user.js new file mode 100644 index 0000000..6819493 --- /dev/null +++ b/extra_bypasses/linkvertise.user.js @@ -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(); + } + } + +})(); +// ----- ------ ---------- + diff --git a/supported_sites.txt b/supported_sites.txt index f7223fb..f09602f 100644 --- a/supported_sites.txt +++ b/supported_sites.txt @@ -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)\/.*$/