Skip to content

Commit e434545

Browse files
author
hoang.tran12
committed
add globalBlacklist
1 parent 2346e65 commit e434545

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

popup/helpers/scriptHelpers.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export async function getAvailableScripts() {
1313
return avai;
1414
}
1515

16+
export const GlobalBlackList = ["edge://*", "chrome://*"];
1617
export async function checkBlackWhiteList(script, url = null) {
1718
if (!url) {
1819
url = await getCurrentURL();
@@ -23,12 +24,15 @@ export async function checkBlackWhiteList(script, url = null) {
2324
hasWhiteList = w?.length > 0,
2425
hasBlackList = b?.length > 0,
2526
inWhiteList = w?.findIndex((_) => isUrlMatchPattern(url, _)) >= 0,
26-
inBlackList = b?.findIndex((_) => isUrlMatchPattern(url, _)) >= 0;
27+
inBlackList = b?.findIndex((_) => isUrlMatchPattern(url, _)) >= 0,
28+
inGlobalBlackList =
29+
GlobalBlackList.findIndex((_) => isUrlMatchPattern(url, _)) >= 0;
2730

2831
let willRun =
29-
(!hasWhiteList && !hasBlackList) ||
30-
(hasWhiteList && inWhiteList) ||
31-
(hasBlackList && !inBlackList);
32+
!inGlobalBlackList &&
33+
((!hasWhiteList && !hasBlackList) ||
34+
(hasWhiteList && inWhiteList) ||
35+
(hasBlackList && !inBlackList));
3236

3337
return willRun;
3438
}

popup/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { allScripts } from "../scripts/index.js";
22
import { checkForUpdate } from "./helpers/checkForUpdate.js";
33
import { getFlag, t, toggleLang } from "./helpers/lang.js";
44
import { viewScriptSource, runScriptInCurrentTab } from "./helpers/utils.js";
5-
import { checkBlackWhiteList } from "./helpers/scriptHelpers.js";
5+
import {
6+
checkBlackWhiteList,
7+
GlobalBlackList,
8+
} from "./helpers/scriptHelpers.js";
69
import { openModal } from "./helpers/modal.js";
710
import {
811
activeTabIdSaver,
@@ -242,7 +245,7 @@ async function runScript(script) {
242245
runScriptInCurrentTab(script.func);
243246
} else {
244247
let w = script.whiteList?.join(", ");
245-
let b = script.blackList?.join(", ");
248+
let b = [...script.blackList, ...GlobalBlackList]?.join(", ");
246249

247250
openModal(
248251
t({

0 commit comments

Comments
 (0)