mirror of
https://github.com/bytedream/stream-bypass.git
synced 2026-02-04 05:16:27 +01:00
fix background listeners not working
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import { UrlReferer } from '@/lib/settings';
|
import { getHost } from '@/lib/host';
|
||||||
|
import { HostSettings, UrlReferer } from '@/lib/settings';
|
||||||
|
|
||||||
export default defineBackground(() => {
|
export default defineBackground(() => {
|
||||||
browser.runtime.onMessage.addListener(async (message) => {
|
browser.runtime.onMessage.addListener(async (message) => {
|
||||||
if (message.action == 'ff2mpv') {
|
if (message.action == 'ff2mpv') {
|
||||||
await browser.runtime.sendNativeMessage('ff2mpv', { url: message.url });
|
await browser.runtime.sendNativeMessage('ff2mpv', { url: message.url });
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// the following listener is only available in mv2
|
// the following listener is only available in mv2
|
||||||
if (import.meta.env.MANIFEST_VERSION === 3) return;
|
if (import.meta.env.MANIFEST_VERSION === 3) return;
|
||||||
@@ -26,5 +28,14 @@ export default defineBackground(() => {
|
|||||||
{ urls: ['<all_urls>'], types: ['xmlhttprequest'] },
|
{ urls: ['<all_urls>'], types: ['xmlhttprequest'] },
|
||||||
['blocking', 'requestHeaders']
|
['blocking', 'requestHeaders']
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
browser.webRequest.onBeforeRedirect.addListener(
|
||||||
|
async (details) => {
|
||||||
|
const host = await getHost(new URL(details.url).hostname);
|
||||||
|
if (!host) return;
|
||||||
|
|
||||||
|
await HostSettings.addTemporaryHostDomain(host, new URL(details.redirectUrl).hostname);
|
||||||
|
},
|
||||||
|
{ urls: ['<all_urls>'], types: ['main_frame', 'sub_frame'] }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user