mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-05-11 13:15:13 +02:00
Fix voe.sx
This commit is contained in:
parent
2f186bda07
commit
94eee79218
@ -1,7 +1,7 @@
|
|||||||
import './shared';
|
import './shared';
|
||||||
|
|
||||||
import type { Match } from '~/lib/match';
|
import type { Match } from '~/lib/match';
|
||||||
import { storageDelete, storageGet, storageSet } from '~/lib/settings';
|
import { Redirect, storageDelete, storageGet, storageSet } from '~/lib/settings';
|
||||||
import { getMatch } from '~/lib/match';
|
import { getMatch } from '~/lib/match';
|
||||||
|
|
||||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||||
@ -27,13 +27,13 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
|
|||||||
chrome.webRequest.onBeforeRedirect.addListener(
|
chrome.webRequest.onBeforeRedirect.addListener(
|
||||||
async (details) => {
|
async (details) => {
|
||||||
// check if redirects origins from a previous redirect
|
// check if redirects origins from a previous redirect
|
||||||
if ((await storageGet('redirect')) === undefined) {
|
if ((await Redirect.get()) == null) {
|
||||||
let match: Match | null;
|
let match: Match | null;
|
||||||
if ((match = await getMatch(new URL(details.url).hostname)) !== null) {
|
if ((match = await getMatch(new URL(details.url).hostname)) !== null) {
|
||||||
await storageSet('redirect', match.id);
|
await Redirect.set(match);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await storageDelete('redirect');
|
await Redirect.delete();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ urls: ['<all_urls>'], types: ['main_frame', 'sub_frame'] }
|
{ urls: ['<all_urls>'], types: ['main_frame', 'sub_frame'] }
|
||||||
|
@ -12,6 +12,14 @@ async function main() {
|
|||||||
redirect = true;
|
redirect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// some sites have a javascript based redirect, e.g. example.com redirects to example.org by changing
|
||||||
|
// window.location.href instead of a 3XX http redirect. an empty body is a sign that such a javascript redirect
|
||||||
|
// occurred
|
||||||
|
if (document.body == null) {
|
||||||
|
await Redirect.set(match);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const re = document.body.innerHTML.match(match.regex);
|
const re = document.body.innerHTML.match(match.regex);
|
||||||
if (re === null) {
|
if (re === null) {
|
||||||
return;
|
return;
|
||||||
@ -20,7 +28,7 @@ async function main() {
|
|||||||
await Redirect.delete();
|
await Redirect.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
let url: string;
|
let url: string | null;
|
||||||
try {
|
try {
|
||||||
url = await match.match(re);
|
url = await match.match(re);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user