add globalThis.ContextType

This commit is contained in:
Gabe Yuan
2023-09-20 16:02:17 +08:00
parent f591d66365
commit 01ebc184ad
3 changed files with 6 additions and 1 deletions

View File

@@ -40,7 +40,8 @@
], ],
"globals": { "globals": {
"GM": true, "GM": true,
"unsafeWindow": true "unsafeWindow": true,
"globalThis": true
} }
}, },
"browserslist": { "browserslist": {

View File

@@ -16,6 +16,8 @@ import { sendTabMsg } from "./libs/msg";
import { trySyncAllSubRules } from "./libs/subRules"; import { trySyncAllSubRules } from "./libs/subRules";
import { tryClearCaches } from "./libs"; import { tryClearCaches } from "./libs";
globalThis.ContextType = "BACKGROUND";
/** /**
* 插件安装 * 插件安装
*/ */

View File

@@ -13,3 +13,5 @@ function _browser() {
} }
export const browser = _browser(); export const browser = _browser();
export const isBg = () => globalThis?.ContextType === "BACKGROUND";