feat: translate blacklist

This commit is contained in:
Gabe Yuan
2023-11-24 17:07:29 +08:00
parent 7bc39dd1bc
commit 22c50e7765
8 changed files with 200 additions and 193 deletions

13
src/libs/blacklist.js Normal file
View File

@@ -0,0 +1,13 @@
import { isMatch } from "./utils";
import { DEFAULT_BLACKLIST } from "../config";
/**
* 检查是否在黑名单中
* @param {*} href
* @param {*} param1
* @returns
*/
export const isInBlacklist = (
href,
{ blacklist = DEFAULT_BLACKLIST.join(",\n") }
) => blacklist.split(",").some((url) => isMatch(href, url.trim()));

View File

@@ -21,7 +21,6 @@ import { trySyncRules } from "./sync";
* @returns
*/
export const matchRule = async (
rules,
href,
{
injectRules = true,
@@ -29,7 +28,7 @@ export const matchRule = async (
owSubrule = DEFAULT_OW_RULE,
}
) => {
rules = [...rules];
const rules = await getRulesWithDefault();
if (injectRules) {
try {
const selectedSub = subrulesList.find((item) => item.selected);