mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-06-27 18:40:31 +02:00
Add functions to bypass websites that are redirected to (looking at you voe)
This commit is contained in:
16
src/background.ts
Normal file
16
src/background.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {getMatch} from "./match/match";
|
||||
import {storageGet, storageSet} from "./store/store";
|
||||
import {Match} from "./match/matches";
|
||||
|
||||
chrome.webRequest.onBeforeRedirect.addListener(async details => {
|
||||
// check if redirects origins from a previous redirect
|
||||
if (await storageGet('redirect') === undefined) {
|
||||
let match: Match
|
||||
if ((match = await getMatch(new URL(details.url).host)) !== undefined) {
|
||||
await storageSet('redirect', match.id)
|
||||
}
|
||||
}
|
||||
}, {
|
||||
urls: ['<all_urls>'],
|
||||
types: ['main_frame', 'sub_frame']
|
||||
})
|
34
src/index.ts
34
src/index.ts
@ -1,24 +1,26 @@
|
||||
import {matches} from "./match/match";
|
||||
import {getAllDisabled, getDisabled} from "./store/store";
|
||||
import {getMatch} from "./match/match";
|
||||
import {storageDelete, storageGet} from "./store/store";
|
||||
import {Match, matches} from "./match/matches";
|
||||
|
||||
async function main() {
|
||||
if (await getAllDisabled()) {
|
||||
let match: Match;
|
||||
if ((match = await getMatch(window.location.host)) === undefined) {
|
||||
let id: string
|
||||
if ((id = await storageGet('redirect')) !== undefined) {
|
||||
match = matches.find(m => m.id === id)
|
||||
await storageDelete('redirect')
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const re = document.body.innerHTML.match(match.regex)
|
||||
if (re === null) {
|
||||
return
|
||||
}
|
||||
|
||||
for (const match of matches) {
|
||||
if (!match.domains.some((v) => window.location.host.indexOf(v) !== -1) || ((await getDisabled()).some((v) => v === match))) {
|
||||
continue
|
||||
}
|
||||
|
||||
const re = document.body.innerHTML.match(match.regex)
|
||||
if (re === null) {
|
||||
continue
|
||||
}
|
||||
|
||||
const url = await match.match(re)
|
||||
location.assign(chrome.runtime.getURL(`ui/player/player.html?id=${match.id}&url=${encodeURIComponent(url)}`))
|
||||
}
|
||||
const url = await match.match(re)
|
||||
location.assign(chrome.runtime.getURL(`ui/player/player.html?id=${match.id}&url=${encodeURIComponent(url)}`))
|
||||
}
|
||||
|
||||
main()
|
||||
|
@ -14,21 +14,7 @@
|
||||
{
|
||||
"all_frames": true,
|
||||
"matches": [
|
||||
"*://*.evoload.io/*",
|
||||
"*://*.mixdrop.co/*",
|
||||
"*://*.newgrounds.com/*",
|
||||
"*://*.streamtape.com/*",
|
||||
"*://*.streamzz.to/*",
|
||||
"*://*.streamz.ws/*",
|
||||
"*://*.upstream.to/*",
|
||||
"*://*.vidlox.me/*",
|
||||
"*://*.vidoza.net/*",
|
||||
"*://*.vivo.sx/*",
|
||||
"*://*.voe.sx/*",
|
||||
"*://*.voeunblk.com/*",
|
||||
"*://*.voeun-block.net/*",
|
||||
"*://*.un-block-voe.net/*",
|
||||
"*://*.vupload.com/*"
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"index.js"
|
||||
@ -36,8 +22,15 @@
|
||||
"run_at": "document_end"
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
"scripts": [
|
||||
"background.js"
|
||||
]
|
||||
},
|
||||
"permissions": [
|
||||
"storage"
|
||||
"storage",
|
||||
"webRequest",
|
||||
"<all_urls>"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
|
14
src/match/match.ts
Normal file
14
src/match/match.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {Match, matches} from "./matches";
|
||||
import {getAllDisabled, getDisabled} from "../store/store";
|
||||
|
||||
export async function getMatch(host: string): Promise<Match | undefined> {
|
||||
if (await getAllDisabled()) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
for (const match of matches) {
|
||||
if (match.domains.some(v => host.indexOf(v) !== -1) && !((await getDisabled()).some(v => v === match))) {
|
||||
return match
|
||||
}
|
||||
}
|
||||
}
|
@ -192,10 +192,7 @@ class Voe implements Match {
|
||||
id = 'voe'
|
||||
reliability = Reliability.HIGH
|
||||
domains = [
|
||||
'voe.sx',
|
||||
'voeunblk.com',
|
||||
'voeun-block.net',
|
||||
'un-block-voe.net'
|
||||
'voe.sx'
|
||||
]
|
||||
regex = new RegExp(/https?:\/\/\S*m3u8(?=")/gm)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Match, matches} from "../match/match";
|
||||
import {Match, matches} from "../match/matches";
|
||||
|
||||
async function storageGet(key: string): Promise<any> {
|
||||
export async function storageGet(key: string): Promise<any> {
|
||||
return new Promise((resolve) => {
|
||||
chrome.storage.local.get(key, (value) => {
|
||||
resolve(value[key])
|
||||
@ -8,12 +8,16 @@ async function storageGet(key: string): Promise<any> {
|
||||
})
|
||||
}
|
||||
|
||||
async function storageSet(key: string, value: any) {
|
||||
export async function storageSet(key: string, value: any) {
|
||||
const obj = {}
|
||||
obj[key] = value
|
||||
await chrome.storage.local.set(obj)
|
||||
}
|
||||
|
||||
export async function storageDelete(key: string) {
|
||||
await chrome.storage.local.remove(key)
|
||||
}
|
||||
|
||||
export async function getDisabled(): Promise<Match[]> {
|
||||
const localMatches = []
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Match, matches, Reliability} from "../../match/match";
|
||||
import {Match, matches, Reliability} from "../../match/matches";
|
||||
// @ts-ignore
|
||||
import Hls from "hls.js";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {getDisabled, disable, enable, getAllDisabled, enableAll, disableAll} from "../../store/store";
|
||||
import {matches, Reliability} from "../../match/match";
|
||||
import {matches, Reliability} from "../../match/matches";
|
||||
|
||||
async function main() {
|
||||
const disabled = await getDisabled()
|
||||
|
Reference in New Issue
Block a user