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: {
'@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.
<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">
</a>
<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 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">
</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 Users">
</a>
<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/downloads/ByteDream/stream-bypass/total?label=GitHub%20Downloads&style=flat-square" alt="GitHub Downloads">
</a>
</p>
@ -71,14 +71,18 @@ The best way to install the extension are the official browser extension stores:
| Site | Supported | Note |
| --------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------ |
| [dropload.io](https://dropload.io) | ✔ | |
| [doodstream.com](doodstream.com) / [dood.pm](https://dood.pm) | ✔️ | |
| [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)) |
| [mixdrop.co](https://mixdrop.co) | ✔ | |
| [mp4upload.com](https://mp4upload.com) | ✔ | |
| [newgrounds.com](https://newgrounds.com) | ✔ | |
| [streama2s.com](https://streama2z.com) | ✔ |
| [streamtape.com](https://streamtape.com) | ✔ | |
| [streamzz.to](https://streamzz.to) / [streamz.ws](https://streamz.ws) | ✔ | |
| [supervideo.tv](https://supervideo.tv) | ✔ | |
| [upstream.to](https://upstream.to) | ✔ | |
| [videovard.sx](https://videovard.sx) | ❌ | Reverse engineering the site costs too much time |
| [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) | ✔ | |
| [vupload.com](https://vupload.com) | ✔ | |
| [kwik.cx](https://kwik.cx) | ✔ | |
| [dropload.io](https://dropload.io) | ✔ | |
| [supervideo.tv](https://supervideo.tv) | ✔ | |
| [goodstream.uno](https://goodstream.uno) | ✔ | |
- ✔️: 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.

2299
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,15 +1,17 @@
import './shared';
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';
chrome.webRequest.onBeforeSendHeaders.addListener(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async (details) => {
const referer: { domain: string } | undefined = await storageGet('referer');
if (referer === undefined) return;
details.requestHeaders.push({
details.requestHeaders!.push({
name: 'Referer',
value: `https://${referer.domain}/`
});
@ -25,13 +27,13 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
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).hostname)) !== undefined) {
await storageSet('redirect', match.id);
if ((await Redirect.get()) == null) {
let match: Match | null;
if ((match = await getMatch(new URL(details.url).hostname)) !== null) {
await Redirect.set(match);
}
} else {
await storageDelete('redirect');
await Redirect.delete();
}
},
{ 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';
async function main() {
let match: Match;
let match: Match | null;
let redirect = false;
if ((match = await getMatch(window.location.host)) === null) {
if ((match = await Redirect.get()) === null) {
@ -12,6 +12,14 @@ async function main() {
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);
if (re === null) {
return;
@ -20,7 +28,16 @@ async function main() {
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
if (await Other.getFf2mpv()) {
@ -28,13 +45,28 @@ async function main() {
}
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');
player.style.width = '100%';
player.style.height = '100%';
player.controls = true;
player.src = url;
document.body.innerHTML = '';
// add video player to document body
document.body.style.margin = '0';
document.body.append(player);
} else {
window.location.assign(

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import App from './Popup.svelte';
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 { Hosters } from './settings';
import { Hosters, Redirect } from './settings';
export interface Match {
name: string;
@ -9,7 +9,7 @@ export interface Match {
regex: RegExp;
notice?: string;
match(match: RegExpMatchArray): Promise<string>;
match(match: RegExpMatchArray): Promise<string | null>;
}
export const Doodstream: Match = {
@ -26,11 +26,13 @@ export const Doodstream: Match = {
'dood.to',
'dood.so',
'dood.la',
'dood.li',
'dood.re',
'dood.yt',
'doods.pro',
'ds2play.com',
'dooood.com'
'dooood.com',
'd000d.com'
],
replace: true,
regex: /(\/pass_md5\/.*?)'.*(\?token=.*?expiry=)/s,
@ -56,7 +58,7 @@ export const DropLoad: Match = {
match: async (match: RegExpMatchArray) => {
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) => {
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) => {
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) => {
const unpacked = await unpack(match[0]);
const url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)[0];
const url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)![0];
return `https:${url}`;
}
};
@ -117,7 +119,7 @@ export const Mp4Upload: Match = {
match: async (match: RegExpMatchArray) => {
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 = {
name: 'Streamtape',
id: 'streamtape',
@ -179,7 +196,7 @@ export const SuperVideo: Match = {
match: async (match: RegExpMatchArray) => {
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) => {
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',
domains: ['vidoza.net'],
regex: /(?<=src:\s?").+?(?=")/gm,
replace: true,
match: async (match: RegExpMatchArray) => {
return match[0];
@ -249,6 +267,7 @@ export const matches = {
[Mixdrop.id]: Mixdrop,
[Mp4Upload.id]: Mp4Upload,
[Newgrounds.id]: Newgrounds,
[StreamA2z.id]: StreamA2z,
[Streamtape.id]: Streamtape,
[Streamzz.id]: Streamzz,
[SuperVideo.id]: SuperVideo,

View File

@ -3,11 +3,11 @@ import { matches } from './match';
export const Hosters = {
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);
},
disable: async (match: Match) => {
const disabled = await storageGet('hosters.disabled', []);
const disabled = (await storageGet('hosters.disabled', [])) as string[];
const index = disabled.indexOf(match.id);
if (index === -1) {
disabled.push(match.id);
@ -15,7 +15,7 @@ export const Hosters = {
}
},
enable: async (match: Match) => {
const disabled = await storageGet('hosters.disabled', []);
const disabled = (await storageGet('hosters.disabled', [])) as string[];
const index = disabled.indexOf(match.id);
if (index !== -1) {
disabled.splice(index, 1);
@ -25,17 +25,14 @@ export const Hosters = {
getAllDisabled: async () => {
return await storageGet<boolean>('hosters.allDisabled', false);
},
disableAll: async () => {
await storageSet('hosters.allDisabled', true);
},
enableAll: async () => {
await storageSet('hosters.allDisabled', false);
setAll: async (enable: boolean) => {
await storageSet('hosters.allDisabled', !enable);
}
};
export const Redirect = {
get: async (): Promise<Match | null> => {
return matches[await storageGet<string>('redirect')] || null;
return matches[(await storageGet('redirect')) as string] || null;
},
set: async (match: Match) => {
await storageSet('redirect', match.id);
@ -47,7 +44,7 @@ export const Redirect = {
export const Other = {
getFf2mpv: async () => {
return await storageGet('other.ff2mpv', true);
return await storageGet('other.ff2mpv', false);
},
setFf2mpv: async (enable: boolean) => {
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
.replace(/;/g, ';\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
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
try {
window.sessionStorage;
@ -44,7 +44,8 @@ async function runInPageContext<T>(toExecute: string): Promise<T> {
const scriptElm = document.createElement('script');
scriptElm.setAttribute('type', 'application/javascript');
const code = `
// inject the script
scriptElm.textContent = `
(
async function () {
@ -63,9 +64,6 @@ async function runInPageContext<T>(toExecute: string): Promise<T> {
)();
`;
// inject the script
scriptElm.textContent = code;
// run the script
document.documentElement.appendChild(scriptElm);

View File

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