11 Commits

Author SHA1 Message Date
696ec22471 Update dependencies and version 2024-07-28 23:43:56 +02:00
e379113aa4 Add firefox android support 2024-07-28 23:33:54 +02:00
84605ceb30 Make nativeMessaging an optional permission 2024-07-28 23:31:25 +02:00
67c492db47 Update popup UI 2024-07-28 23:04:04 +02:00
ae2f196b06 Lint 2024-07-28 18:08:05 +02:00
298e9308ce Add streama2z.com (#19) 2024-07-28 17:54:41 +02:00
3cd4c6b6b7 Fix doodstream.com 2024-07-28 17:54:02 +02:00
6286acf85c Make video replace strategy more aggressive 2024-07-28 17:33:54 +02:00
94eee79218 Fix voe.sx 2024-07-28 16:35:58 +02:00
2f186bda07 Add d000d.com (#18) 2024-07-28 14:46:36 +02:00
1c9f95cebc Fix linting errors 2024-07-14 21:08:47 +02:00
15 changed files with 1334 additions and 1472 deletions

View File

@ -28,6 +28,7 @@ module.exports = {
} }
], ],
rules: { rules: {
'@typescript-eslint/no-explicit-any': 'off' '@typescript-eslint/no-explicit-any': 'off',
'no-undef': 'off'
} }
}; };

View File

@ -3,19 +3,19 @@
A multi-browser addon / extension for multiple streaming providers which redirects directly to the source video. A multi-browser addon / extension for multiple streaming providers which redirects directly to the source video.
<p align="center"> <p align="center">
<a href="https://github.com/ByteDream/stream-bypass/releases/latest"> <a href="https://github.com/bytedream/stream-bypass/releases/latest">
<img src="https://img.shields.io/github/v/release/ByteDream/stream-bypass?label=Version&style=flat-square" alt="Version"> <img src="https://img.shields.io/github/v/release/ByteDream/stream-bypass?label=Version&style=flat-square" alt="Version">
</a> </a>
<a href="https://addons.mozilla.org/de/firefox/addon/stream-bypass/"> <a href="https://addons.mozilla.org/de/firefox/addon/stream-bypass/">
<img src="https://img.shields.io/amo/users/stream-bypass?label=Firefox%20Store%20Downloads&style=flat-square" alt="Firefox Addon Store"> <img src="https://img.shields.io/amo/users/stream-bypass?label=Firefox%20Users&style=flat-square" alt="Firefox Addon Store">
</a>
<a href="https://chromewebstore.google.com/detail/ddfpfjomnakfckhmilacnbokdaknamdb">
<img src="https://img.shields.io/chrome-web-store/users/ddfpfjomnakfckhmilacnbokdaknamdb?style=flat-square&label=Chrome%20Users" alt="Chrome Store">
</a> </a>
<a href="https://addons.mozilla.org/de/firefox/addon/stream-bypass/"> <a href="https://addons.mozilla.org/de/firefox/addon/stream-bypass/">
<img src="https://img.shields.io/amo/stars/stream-bypass?label=Firefox%20Store%20Stars&style=flat-square" alt="Firefox Addon Stars"> <img src="https://img.shields.io/amo/stars/stream-bypass?label=Firefox%20Store%20Stars&style=flat-square" alt="Firefox Addon Stars">
</a> </a>
<a href="https://chromewebstore.google.com/detail/ddfpfjomnakfckhmilacnbokdaknamdb"> <a href="https://github.com/bytedream/stream-bypass/releases/latest">
<img src="https://img.shields.io/chrome-web-store/users/ddfpfjomnakfckhmilacnbokdaknamdb?style=flat-square&label=Chrome%20Users" alt="Chrome Users">
</a>
<a href="https://github.com/ByteDream/stream-bypass/releases/latest">
<img src="https://img.shields.io/github/downloads/ByteDream/stream-bypass/total?label=GitHub%20Downloads&style=flat-square" alt="GitHub Downloads"> <img src="https://img.shields.io/github/downloads/ByteDream/stream-bypass/total?label=GitHub%20Downloads&style=flat-square" alt="GitHub Downloads">
</a> </a>
</p> </p>
@ -71,14 +71,18 @@ The best way to install the extension are the official browser extension stores:
| Site | Supported | Note | | Site | Supported | Note |
| --------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------ | | --------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------ |
| [dropload.io](https://dropload.io) | ✔ | |
| [doodstream.com](doodstream.com) / [dood.pm](https://dood.pm) | ✔️ | | | [doodstream.com](doodstream.com) / [dood.pm](https://dood.pm) | ✔️ | |
| [filemoon.sx](https://filemoon.sx) | ✔ | | | [filemoon.sx](https://filemoon.sx) | ✔ | |
| [goodstream.uno](https://goodstream.uno) | ✔ | |
| [mcloud.to](https://mcloud.to/) | ❌ | Reverse engineering the site costs too much time ([#5](https://github.com/ByteDream/stream-bypass/issues/5)) | | [mcloud.to](https://mcloud.to/) | ❌ | Reverse engineering the site costs too much time ([#5](https://github.com/ByteDream/stream-bypass/issues/5)) |
| [mixdrop.co](https://mixdrop.co) | ✔ | | | [mixdrop.co](https://mixdrop.co) | ✔ | |
| [mp4upload.com](https://mp4upload.com) | ✔ | | | [mp4upload.com](https://mp4upload.com) | ✔ | |
| [newgrounds.com](https://newgrounds.com) | ✔ | | | [newgrounds.com](https://newgrounds.com) | ✔ | |
| [streama2s.com](https://streama2z.com) | ✔ |
| [streamtape.com](https://streamtape.com) | ✔ | | | [streamtape.com](https://streamtape.com) | ✔ | |
| [streamzz.to](https://streamzz.to) / [streamz.ws](https://streamz.ws) | ✔ | | | [streamzz.to](https://streamzz.to) / [streamz.ws](https://streamz.ws) | ✔ | |
| [supervideo.tv](https://supervideo.tv) | ✔ | |
| [upstream.to](https://upstream.to) | ✔ | | | [upstream.to](https://upstream.to) | ✔ | |
| [videovard.sx](https://videovard.sx) | ❌ | Reverse engineering the site costs too much time | | [videovard.sx](https://videovard.sx) | ❌ | Reverse engineering the site costs too much time |
| [vidmoly.me](https://vidmoly.me) | ✔ | | | [vidmoly.me](https://vidmoly.me) | ✔ | |
@ -87,9 +91,6 @@ The best way to install the extension are the official browser extension stores:
| [voe.sx](https://voe.sx) | ✔ | | | [voe.sx](https://voe.sx) | ✔ | |
| [vupload.com](https://vupload.com) | ✔ | | | [vupload.com](https://vupload.com) | ✔ | |
| [kwik.cx](https://kwik.cx) | ✔ | | | [kwik.cx](https://kwik.cx) | ✔ | |
| [dropload.io](https://dropload.io) | ✔ | |
| [supervideo.tv](https://supervideo.tv) | ✔ | |
| [goodstream.uno](https://goodstream.uno) | ✔ | |
- ✔️: Everything ok. - ✔️: Everything ok.
- ⚠: Included in the addon but will probably not work. See `Note` in this case, an explanation why will stand there in the most cases. - ⚠: Included in the addon but will probably not work. See `Note` in this case, an explanation why will stand there in the most cases.

2303
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
{ {
"name": "stream-bypass", "name": "stream-bypass",
"version": "3.0.1", "version": "3.1.0",
"displayName": "Stream Bypass", "displayName": "Stream Bypass",
"author": "ByteDream", "author": "bytedream",
"description": "Multi-browser addon for multiple streaming providers which redirects directly to the source video", "description": "Multi-browser addon for multiple streaming providers which redirects directly to the source video",
"scripts": { "scripts": {
"build": "vite build", "build": "vite build",
@ -19,32 +19,33 @@
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/ByteDream/stream-bypass.git" "url": "git+https://github.com/bytedream/stream-bypass.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/ByteDream/stream-bypass/issues" "url": "https://github.com/bytedream/stream-bypass/issues"
}, },
"devDependencies": { "devDependencies": {
"@samrum/vite-plugin-web-extension": "^5.1.0", "@samrum/vite-plugin-web-extension": "^5.1.0",
"@sveltejs/vite-plugin-svelte": "^2.5.3", "@sveltejs/vite-plugin-svelte": "^2.5.3",
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"@types/chrome": "^0.0.268", "@types/chrome": "^0.0.269",
"@typescript-eslint/eslint-plugin": "^7.9.0", "@types/firefox-webext-browser": "^120.0.4",
"@typescript-eslint/parser": "^7.9.0", "@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.39.0", "eslint-plugin-svelte": "^2.43.0",
"hls.js": "^1.5.8", "hls.js": "^1.5.13",
"prettier": "^3.2.5", "prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.3", "prettier-plugin-svelte": "^3.2.6",
"sass": "^1.77.2", "sass": "^1.77.8",
"svelte": "^4.2.17", "svelte": "^4.2.18",
"svelte-check": "^3.7.1", "svelte-check": "^3.8.4",
"svelte-preprocess": "^5.1.4", "svelte-preprocess": "^6.0.2",
"tslib": "^2.6.2", "tslib": "^2.6.3",
"typescript": "^5.4.5", "typescript": "^5.5.4",
"vite": "^4.5.3", "vite": "^4.5.3",
"web-ext": "^7.11.0" "web-ext": "^8.2.0"
}, },
"type": "module" "type": "module"
} }

View File

@ -1,15 +1,17 @@
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 } from '~/lib/settings';
import { getMatch } from '~/lib/match'; import { getMatch } from '~/lib/match';
chrome.webRequest.onBeforeSendHeaders.addListener( chrome.webRequest.onBeforeSendHeaders.addListener(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async (details) => { async (details) => {
const referer: { domain: string } | undefined = await storageGet('referer'); const referer: { domain: string } | undefined = await storageGet('referer');
if (referer === undefined) return; if (referer === undefined) return;
details.requestHeaders.push({ details.requestHeaders!.push({
name: 'Referer', name: 'Referer',
value: `https://${referer.domain}/` value: `https://${referer.domain}/`
}); });
@ -25,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; let match: Match | null;
if ((match = await getMatch(new URL(details.url).hostname)) !== undefined) { 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'] }

View File

@ -3,7 +3,7 @@ import { getMatch } from '~/lib/match';
import { Other, Redirect } from '~/lib/settings'; import { Other, Redirect } from '~/lib/settings';
async function main() { async function main() {
let match: Match; let match: Match | null;
let redirect = false; let redirect = false;
if ((match = await getMatch(window.location.host)) === null) { if ((match = await getMatch(window.location.host)) === null) {
if ((match = await Redirect.get()) === null) { if ((match = await Redirect.get()) === null) {
@ -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,16 @@ async function main() {
await Redirect.delete(); await Redirect.delete();
} }
const url = await match.match(re); let url: string | null;
try {
url = await match.match(re);
} catch (e) {
return;
}
if (!url) {
return;
}
// send the url to the ff2mpv (https://github.com/woodruffw/ff2mpv) application // send the url to the ff2mpv (https://github.com/woodruffw/ff2mpv) application
if (await Other.getFf2mpv()) { if (await Other.getFf2mpv()) {
@ -28,13 +45,28 @@ async function main() {
} }
if (match.replace && !url.includes('.m3u8')) { if (match.replace && !url.includes('.m3u8')) {
// this destroys all intervals that may spawn popups or events
let intervalId = window.setInterval(() => {}, 0);
while (intervalId--) {
clearInterval(intervalId);
}
let timeoutId = window.setTimeout(() => {}, 0);
while (timeoutId--) {
clearTimeout(timeoutId);
}
// clear completed document
document.documentElement.innerHTML = '';
// video player
const player = document.createElement('video'); const player = document.createElement('video');
player.style.width = '100%'; player.style.width = '100%';
player.style.height = '100%'; player.style.height = '100%';
player.controls = true; player.controls = true;
player.src = url; player.src = url;
document.body.innerHTML = ''; // add video player to document body
document.body.style.margin = '0';
document.body.append(player); document.body.append(player);
} else { } else {
window.location.assign( window.location.assign(

View File

@ -22,9 +22,9 @@ async function playHls(url: string, videoElem: HTMLVideoElement) {
export async function play(videoElem: HTMLVideoElement) { export async function play(videoElem: HTMLVideoElement) {
const urlQuery = new URLSearchParams(window.location.search); const urlQuery = new URLSearchParams(window.location.search);
const id = urlQuery.get('id'); const id = urlQuery.get('id') as string;
const url = decodeURIComponent(urlQuery.get('url')); const url = decodeURIComponent(urlQuery.get('url') as string);
const domain = urlQuery.get('domain'); const domain = urlQuery.get('domain') as string;
const match = matches[id]; const match = matches[id];
if (match === undefined) { if (match === undefined) {

View File

@ -1,117 +1,97 @@
<script lang="ts"> <script lang="ts">
import { matches } from '~/lib/match'; import { type Match, matches } from '~/lib/match';
import { Hosters, Other } from '~/lib/settings'; import { Hosters, Other } from '~/lib/settings';
import Toggle from './toggle.svelte';
let hostersEnabled: boolean; let hostersEnabled: boolean;
let hosters = []; let hosters: (Match & { active: boolean; disabled: boolean })[] = [];
(async () => { (async () => {
hostersEnabled = !(await Hosters.getAllDisabled()); hostersEnabled = !(await Hosters.getAllDisabled());
const disabled = await Hosters.getDisabled(); const disabled = await Hosters.getDisabled();
hosters = Object.values(matches).map((m) => { hosters = Object.values(matches).map((m: any) => {
m['active'] = disabled.findIndex((p) => p.id == m.id) == -1; m['active'] = disabled.findIndex((p) => p.id == m.id) == -1;
m['disabled'] = !hostersEnabled;
return m; return m;
}); }) as typeof hosters;
})();
let isMobile: boolean;
(async () => {
isMobile = (await browser.runtime.getPlatformInfo()).os === 'android';
})(); })();
let ff2mpvEnabled: boolean; let ff2mpvEnabled: boolean;
(async () => { (async () => {
ff2mpvEnabled = await Other.getFf2mpv(); ff2mpvEnabled = (await Other.getFf2mpv()) as boolean;
})(); })();
</script> </script>
<main> <main
<div> style={isMobile
<h3 class="header">Hosters</h3> ? 'height: 100vh; display: flex; flex-direction: column; align-items: center'
<div class="buttons super-buttons"> : 'height: 500px'}
<button >
class:active={hostersEnabled} <fieldset>
on:click={async () => { <legend>Hoster</legend>
await Hosters.enableAll(); <div class="setting-container" style={isMobile ? 'grid-column-gap: 5rem' : ''}>
hostersEnabled = true; <label for="hosters-enabled">Enabled</label>
hosters = hosters.map((m) => { <div>
m['disabled'] = false; <Toggle
return m; bind:checked={hostersEnabled}
}); id="hosters-enabled"
}}>On</button on:change={() => Hosters.setAll(hostersEnabled)}
> />
<button </div>
class:active={!hostersEnabled} <hr />
on:click={async () => { {#each hosters as hoster, i}
await Hosters.disableAll(); <label for="hoster-{i}" style="cursor: {hostersEnabled ? 'pointer' : 'default'}"
hostersEnabled = false; >{hoster.name}</label
hosters = hosters.map((m) => { >
m['disabled'] = true; <div>
return m; <Toggle
}); bind:checked={hoster.active}
}}>Off</button disabled={!hostersEnabled}
> id="hoster-{i}"
</div> on:change={async () => {
<table class="setting-table"> if (hoster.active) {
{#each hosters as hoster}
<tr>
<td class="setting-name">
<p>{hoster.name}</p>
</td>
<td class="buttons">
<button
class:disabled={hoster.disabled}
class:active={hoster.active}
on:click={async () => {
if (hoster.disabled) return;
await Hosters.enable(hoster); await Hosters.enable(hoster);
hoster.active = true; } else {
}}>On</button
>
<button
class:disabled={hoster.disabled}
class:active={!hoster.active}
on:click={async () => {
if (hoster.disabled) return;
await Hosters.disable(hoster); await Hosters.disable(hoster);
hoster.active = false; }
}}>Off</button }}
> ></Toggle>
</td> </div>
</tr>
{/each} {/each}
</table> </div>
</div> </fieldset>
<hr /> {#if !isMobile}
<div> <fieldset>
<h3 class="header">Other</h3> <legend>Other</legend>
<table> <div class="setting-container">
<tr> <label for="ff2mpv">ff2mpv</label>
<td class="setting-name"> <div>
<p>ff2mpv</p> <Toggle
</td> bind:checked={ff2mpvEnabled}
<td class="buttons"> id="ff2mpv"
<button on:change={async () => {
class:active={ff2mpvEnabled} ff2mpvEnabled = !ff2mpvEnabled;
on:click={async () => { if (await browser.permissions.request({ permissions: ['nativeMessaging'] })) {
await Other.setFf2mpv(true); await Other.setFf2mpv(ff2mpvEnabled);
ff2mpvEnabled = true; ff2mpvEnabled = !ff2mpvEnabled;
}}>On</button }
> }}
<button ></Toggle>
class:active={!ff2mpvEnabled}
on:click={async () => {
await Other.setFf2mpv(false);
ff2mpvEnabled = false;
}}>Off</button
>
<a <a
class="info-questionmark"
href="https://github.com/ByteDream/stream-bypass/tree/master#ff2mpv-use-mpv-to-directly-play-streams" href="https://github.com/ByteDream/stream-bypass/tree/master#ff2mpv-use-mpv-to-directly-play-streams"
>🛈</a >?</a
> >
</td> </div>
</tr> </div>
</table> </fieldset>
</div> {/if}
<hr /> <a id="report-notice" href="https://github.com/ByteDream/stream-bypass/issues"
<a id="bug-notice" href="https://github.com/ByteDream/stream-bypass/issues" >Report issues or requests</a
>Something does not work</a
> >
</main> </main>
@ -125,7 +105,12 @@
padding: 0 8px; padding: 0 8px;
} }
#bug-notice { fieldset {
border-radius: 5px;
border-color: gray;
}
#report-notice {
border: none; border: none;
color: white; color: white;
display: block; display: block;
@ -148,52 +133,33 @@
text-align: center; text-align: center;
} }
.setting-table { .setting-container {
border-collapse: collapse; display: grid;
border-spacing: 0; grid-template-columns: auto auto;
} grid-column-gap: 5px;
grid-row-gap: 4px;
align-items: end;
width: 100%;
.setting-name { & > label {
height: 34px; height: 34px;
p {
margin: 0; margin: 0;
cursor: default; user-select: none;
}
}
.buttons {
display: flex;
flex-direction: row;
height: 34px;
button,
a {
border: 1px solid #281515;
background-color: transparent;
color: white;
cursor: pointer; cursor: pointer;
padding: 5px 8px;
margin: 0;
text-decoration: none;
&.active {
background-color: rgba(255, 65, 65, 0.74);
cursor: default;
}
&.disabled {
background-color: gray;
cursor: not-allowed;
}
}
&.super-buttons {
display: flex; display: flex;
justify-content: center; align-items: center;
gap: 4px;
width: 100%;
margin-bottom: 10px;
} }
& > hr {
grid-column: 1 / span 2;
width: 100%;
}
}
.info-questionmark {
display: inline-block;
transform: translateX(-40%) translateY(-100%);
color: black;
text-decoration: none;
} }
</style> </style>

View File

@ -1,10 +1,11 @@
<!doctype html> <!doctype html>
<html style="width: fit-content; height: 500px; overflow-y: hidden" lang="en"> <html style="overflow-y: hidden" lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Stream Bypass</title> <title>Stream Bypass</title>
</head> </head>
<body style="width: fit-content; height: 500px; overflow-y: scroll"> <body style="overflow-y: scroll">
<script type="module"> <script type="module">
import Popup from '~/entries/popup/Popup.svelte'; import Popup from '~/entries/popup/Popup.svelte';

View File

@ -1,5 +1,5 @@
import App from './Popup.svelte'; import App from './Popup.svelte';
new App({ new App({
target: document.getElementById('app') target: document.getElementById('app') as Element
}); });

View File

@ -0,0 +1,65 @@
<!-- https://flowbite.com/docs/forms/toggle/ -->
<script lang="ts">
import { createEventDispatcher } from 'svelte';
export let checked = false;
export let disabled = false;
export let id: string | null = null;
const dispatch = createEventDispatcher();
</script>
<label class="toggle">
<slot />
<input type="checkbox" {id} bind:checked {disabled} on:change={(e) => dispatch('change', e)} />
<span />
</label>
<style lang="scss" global>
.toggle {
display: inline-flex;
align-items: center;
cursor: pointer;
input {
clip: rect(0, 0, 0, 0);
position: absolute;
&:checked + span {
background: limegreen;
&:after {
transform: translateX(100%);
}
}
&:disabled + span {
background: gray;
}
}
span {
position: relative;
width: 2.75rem;
height: 1.5rem;
background: #cf0000;
border-radius: 9999px;
&:after {
content: '';
position: absolute;
top: 2px;
inset-inline-start: 2px;
background: white;
border-radius: 9999px;
height: 1.25rem;
width: 1.25rem;
transition: all 0.15s;
}
}
&:has(input:disabled) {
cursor: default;
}
}
</style>

View File

@ -1,5 +1,5 @@
import { unpack } from './utils'; import { unpack } from './utils';
import { Hosters } from './settings'; import { Hosters, Redirect } from './settings';
export interface Match { export interface Match {
name: string; name: string;
@ -9,7 +9,7 @@ export interface Match {
regex: RegExp; regex: RegExp;
notice?: string; notice?: string;
match(match: RegExpMatchArray): Promise<string>; match(match: RegExpMatchArray): Promise<string | null>;
} }
export const Doodstream: Match = { export const Doodstream: Match = {
@ -26,11 +26,13 @@ export const Doodstream: Match = {
'dood.to', 'dood.to',
'dood.so', 'dood.so',
'dood.la', 'dood.la',
'dood.li',
'dood.re', 'dood.re',
'dood.yt', 'dood.yt',
'doods.pro', 'doods.pro',
'ds2play.com', 'ds2play.com',
'dooood.com' 'dooood.com',
'd000d.com'
], ],
replace: true, replace: true,
regex: /(\/pass_md5\/.*?)'.*(\?token=.*?expiry=)/s, regex: /(\/pass_md5\/.*?)'.*(\?token=.*?expiry=)/s,
@ -56,7 +58,7 @@ export const DropLoad: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=file:").*(?=")/)[0]; return unpacked.match(/(?<=file:").*(?=")/)![0];
} }
}; };
@ -68,7 +70,7 @@ export const Filemoon: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=file:").*(?=")/)[0]; return unpacked.match(/(?<=file:").*(?=")/)![0];
} }
}; };
@ -91,7 +93,7 @@ export const Kwik: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=source=').*(?=')/)[0]; return unpacked.match(/(?<=source=').*(?=')/)![0];
} }
}; };
@ -103,7 +105,7 @@ export const Mixdrop: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
const url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)[0]; const url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)![0];
return `https:${url}`; return `https:${url}`;
} }
}; };
@ -117,7 +119,7 @@ export const Mp4Upload: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=player.src\(").*(?=")/)[0]; return unpacked.match(/(?<=player.src\(").*(?=")/)![0];
} }
}; };
@ -139,6 +141,21 @@ export const Newgrounds: Match = {
} }
}; };
export const StreamA2z: Match = {
name: 'Stream2Az',
id: 'stream2az',
domains: ['streama2z.com', 'streama2z.xyz'],
regex: /https?:\/\/\S*m3u8.+(?=['"])/gm,
match: async (match: RegExpMatchArray) => {
if (StreamA2z.domains.indexOf(window.location.hostname) !== -1) {
await Redirect.set(StreamA2z);
return null;
}
return match[0];
}
};
export const Streamtape: Match = { export const Streamtape: Match = {
name: 'Streamtape', name: 'Streamtape',
id: 'streamtape', id: 'streamtape',
@ -179,7 +196,7 @@ export const SuperVideo: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=file:").*(?=")/)[0]; return unpacked.match(/(?<=file:").*(?=")/)![0];
} }
}; };
@ -191,7 +208,7 @@ export const Upstream: Match = {
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
const unpacked = await unpack(match[0]); const unpacked = await unpack(match[0]);
return unpacked.match(/(?<=file:").*(?=")/)[0]; return unpacked.match(/(?<=file:").*(?=")/)![0];
} }
}; };
@ -212,6 +229,7 @@ export const Vidoza: Match = {
id: 'vidoza', id: 'vidoza',
domains: ['vidoza.net'], domains: ['vidoza.net'],
regex: /(?<=src:\s?").+?(?=")/gm, regex: /(?<=src:\s?").+?(?=")/gm,
replace: true,
match: async (match: RegExpMatchArray) => { match: async (match: RegExpMatchArray) => {
return match[0]; return match[0];
@ -249,6 +267,7 @@ export const matches = {
[Mixdrop.id]: Mixdrop, [Mixdrop.id]: Mixdrop,
[Mp4Upload.id]: Mp4Upload, [Mp4Upload.id]: Mp4Upload,
[Newgrounds.id]: Newgrounds, [Newgrounds.id]: Newgrounds,
[StreamA2z.id]: StreamA2z,
[Streamtape.id]: Streamtape, [Streamtape.id]: Streamtape,
[Streamzz.id]: Streamzz, [Streamzz.id]: Streamzz,
[SuperVideo.id]: SuperVideo, [SuperVideo.id]: SuperVideo,

View File

@ -3,11 +3,11 @@ import { matches } from './match';
export const Hosters = { export const Hosters = {
getDisabled: async () => { getDisabled: async () => {
const disabled = await storageGet<string[]>('hosters.disabled', []); const disabled = (await storageGet('hosters.disabled', [])) as string[];
return disabled.map((id) => matches[id]).filter((m) => m !== undefined); return disabled.map((id) => matches[id]).filter((m) => m !== undefined);
}, },
disable: async (match: Match) => { disable: async (match: Match) => {
const disabled = await storageGet('hosters.disabled', []); const disabled = (await storageGet('hosters.disabled', [])) as string[];
const index = disabled.indexOf(match.id); const index = disabled.indexOf(match.id);
if (index === -1) { if (index === -1) {
disabled.push(match.id); disabled.push(match.id);
@ -15,7 +15,7 @@ export const Hosters = {
} }
}, },
enable: async (match: Match) => { enable: async (match: Match) => {
const disabled = await storageGet('hosters.disabled', []); const disabled = (await storageGet('hosters.disabled', [])) as string[];
const index = disabled.indexOf(match.id); const index = disabled.indexOf(match.id);
if (index !== -1) { if (index !== -1) {
disabled.splice(index, 1); disabled.splice(index, 1);
@ -25,17 +25,14 @@ export const Hosters = {
getAllDisabled: async () => { getAllDisabled: async () => {
return await storageGet<boolean>('hosters.allDisabled', false); return await storageGet<boolean>('hosters.allDisabled', false);
}, },
disableAll: async () => { setAll: async (enable: boolean) => {
await storageSet('hosters.allDisabled', true); await storageSet('hosters.allDisabled', !enable);
},
enableAll: async () => {
await storageSet('hosters.allDisabled', false);
} }
}; };
export const Redirect = { export const Redirect = {
get: async (): Promise<Match | null> => { get: async (): Promise<Match | null> => {
return matches[await storageGet<string>('redirect')] || null; return matches[(await storageGet('redirect')) as string] || null;
}, },
set: async (match: Match) => { set: async (match: Match) => {
await storageSet('redirect', match.id); await storageSet('redirect', match.id);
@ -47,7 +44,7 @@ export const Redirect = {
export const Other = { export const Other = {
getFf2mpv: async () => { getFf2mpv: async () => {
return await storageGet('other.ff2mpv', true); return await storageGet('other.ff2mpv', false);
}, },
setFf2mpv: async (enable: boolean) => { setFf2mpv: async (enable: boolean) => {
await storageSet('other.ff2mpv', enable); await storageSet('other.ff2mpv', enable);

View File

@ -19,7 +19,7 @@ export async function unpack(packed: string): Promise<string> {
}' }'
`; `;
const res: string = await runInPageContext(toExecute); const res = (await runInPageContext(toExecute)) as string;
return res return res
.replace(/;/g, ';\n') .replace(/;/g, ';\n')
.replace(/{/g, '\n{\n') .replace(/{/g, '\n{\n')
@ -29,7 +29,7 @@ export async function unpack(packed: string): Promise<string> {
} }
// Adapted from: https://github.com/arikw/extension-page-context // Adapted from: https://github.com/arikw/extension-page-context
async function runInPageContext<T>(toExecute: string): Promise<T> { async function runInPageContext<T>(toExecute: string): Promise<T | null> {
// test that we are running with the allow-scripts permission // test that we are running with the allow-scripts permission
try { try {
window.sessionStorage; window.sessionStorage;
@ -44,7 +44,8 @@ async function runInPageContext<T>(toExecute: string): Promise<T> {
const scriptElm = document.createElement('script'); const scriptElm = document.createElement('script');
scriptElm.setAttribute('type', 'application/javascript'); scriptElm.setAttribute('type', 'application/javascript');
const code = ` // inject the script
scriptElm.textContent = `
( (
async function () { async function () {
@ -63,9 +64,6 @@ async function runInPageContext<T>(toExecute: string): Promise<T> {
)(); )();
`; `;
// inject the script
scriptElm.textContent = code;
// run the script // run the script
document.documentElement.appendChild(scriptElm); document.documentElement.appendChild(scriptElm);

View File

@ -5,7 +5,8 @@ const sharedManifest: Partial<chrome.runtime.ManifestBase> = {
browser_specific_settings: { browser_specific_settings: {
gecko: { gecko: {
id: '{55dd42e8-3dd9-455a-b4fe-86664881b10c}' id: '{55dd42e8-3dd9-455a-b4fe-86664881b10c}'
} },
gecko_android: {}
}, },
content_scripts: [ content_scripts: [
{ {
@ -22,7 +23,8 @@ const sharedManifest: Partial<chrome.runtime.ManifestBase> = {
96: 'icons/stream-bypass@96px.png', 96: 'icons/stream-bypass@96px.png',
128: 'icons/stream-bypass@128px.png' 128: 'icons/stream-bypass@128px.png'
}, },
permissions: ['storage', 'nativeMessaging'] permissions: ['storage'],
optional_permissions: ['nativeMessaging']
}; };
const browserAction = { const browserAction = {
@ -39,7 +41,7 @@ const ManifestV2 = {
scripts: ['src/entries/background/mv2.ts'], scripts: ['src/entries/background/mv2.ts'],
persistent: true persistent: true
}, },
content_scripts: [{ ...sharedManifest.content_scripts[0], matches: ['<all_urls>'] }], content_scripts: [{ ...sharedManifest.content_scripts![0], matches: ['<all_urls>'] }],
browser_action: browserAction, browser_action: browserAction,
permissions: [...sharedManifest.permissions, 'webRequest', 'webRequestBlocking', '<all_urls>'] permissions: [...sharedManifest.permissions, 'webRequest', 'webRequestBlocking', '<all_urls>']
}; };
@ -67,7 +69,7 @@ export function getManifest(
...manifest, ...manifest,
...ManifestV2, ...ManifestV2,
manifest_version: manifestVersion manifest_version: manifestVersion
}; } as chrome.runtime.ManifestV2;
} }
if (manifestVersion === 3) { if (manifestVersion === 3) {
@ -78,7 +80,7 @@ export function getManifest(
name: `${manifest.name} Lite`, name: `${manifest.name} Lite`,
...ManifestV3, ...ManifestV3,
manifest_version: manifestVersion manifest_version: manifestVersion
}; } as chrome.runtime.ManifestV3;
} }
throw new Error(`Missing manifest definition for manifestVersion ${manifestVersion}`); throw new Error(`Missing manifest definition for manifestVersion ${manifestVersion}`);