Skip to content

Commit 6be8fd3

Browse files
authored
fix: content script register (#12306)
1 parent 0c27708 commit 6be8fd3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/mask/background/tasks/Cancellable/InjectContentScripts_declarative.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Sniffings } from '@masknet/shared-base'
66
import { definedSiteAdaptors } from '../../../shared/site-adaptors/definitions.js'
77

88
const { signal } = hmr(import.meta.webpackHot)
9+
const envSupportPersistAcrossSessions = !Sniffings.is_firefox
910
if (typeof browser.scripting?.registerContentScripts === 'function') {
1011
;(async () => {
1112
await unregisterExistingScripts()
@@ -32,7 +33,7 @@ function prepareMainWorldScript(name: string, matches: string[], url: string): S
3233
id: 'injected_' + name,
3334
allFrames: true,
3435
js: [url],
35-
persistAcrossSessions: false,
36+
persistAcrossSessions: envSupportPersistAcrossSessions,
3637
// @ts-expect-error Chrome API
3738
world: 'MAIN',
3839
runAt: 'document_start',
@@ -47,7 +48,7 @@ async function prepareContentScript(matches: string[]): Promise<Scripting.Regist
4748
id: 'xray',
4849
allFrames: true,
4950
js: [injectedScriptURL],
50-
persistAcrossSessions: false,
51+
persistAcrossSessions: envSupportPersistAcrossSessions,
5152
// @ts-expect-error Chrome API
5253
world: 'ISOLATED',
5354
runAt: 'document_start',
@@ -57,7 +58,7 @@ async function prepareContentScript(matches: string[]): Promise<Scripting.Regist
5758
id: 'content',
5859
allFrames: true,
5960
js: contentScriptList,
60-
persistAcrossSessions: false,
61+
persistAcrossSessions: envSupportPersistAcrossSessions,
6162
// @ts-expect-error Chrome API
6263
world: 'ISOLATED',
6364
runAt: 'document_idle',

0 commit comments

Comments
 (0)