mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-05-09 20:25:14 +02:00
Fix linting errors
This commit is contained in:
parent
c57cd03407
commit
1c9f95cebc
@ -5,11 +5,13 @@ import { storageDelete, storageGet, storageSet } 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}/`
|
||||
});
|
||||
@ -26,8 +28,8 @@ 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) {
|
||||
let match: Match | null;
|
||||
if ((match = await getMatch(new URL(details.url).hostname)) !== null) {
|
||||
await storageSet('redirect', match.id);
|
||||
}
|
||||
} else {
|
||||
|
@ -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) {
|
||||
@ -20,7 +20,12 @@ async function main() {
|
||||
await Redirect.delete();
|
||||
}
|
||||
|
||||
const url = await match.match(re);
|
||||
let url: string;
|
||||
try {
|
||||
url = await match.match(re);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// send the url to the ff2mpv (https://github.com/woodruffw/ff2mpv) application
|
||||
if (await Other.getFf2mpv()) {
|
||||
|
@ -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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import App from './Popup.svelte';
|
||||
|
||||
new App({
|
||||
target: document.getElementById('app')
|
||||
target: document.getElementById('app') as Element
|
||||
});
|
||||
|
@ -56,7 +56,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 +68,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 +91,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 +103,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 +117,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];
|
||||
}
|
||||
};
|
||||
|
||||
@ -179,7 +179,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 +191,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];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
@ -35,7 +35,7 @@ export const Hosters = {
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -39,7 +39,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 +67,7 @@ export function getManifest(
|
||||
...manifest,
|
||||
...ManifestV2,
|
||||
manifest_version: manifestVersion
|
||||
};
|
||||
} as chrome.runtime.ManifestV2;
|
||||
}
|
||||
|
||||
if (manifestVersion === 3) {
|
||||
@ -78,7 +78,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}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user