fix: rules

This commit is contained in:
Gabe
2025-10-13 23:26:29 +08:00
parent dc35fef873
commit d9acbe865f
2 changed files with 4 additions and 6 deletions

View File

@@ -172,11 +172,9 @@ export const DEFAULT_OW_RULE = {
const RULES_MAP = {
"www.google.com/search": {
rootsSelector: `#rcnt`,
textStyle: OPT_STYLE_BLOCKQUOTE,
},
"en.wikipedia.org": {
ignoreSelector: `.button, code, footer, form, mark, pre, .mwe-math-element, .mw-editsection`,
textStyle: OPT_STYLE_BLOCKQUOTE,
},
"news.ycombinator.com": {
selector: `p, .titleline, .commtext`,
@@ -184,18 +182,15 @@ const RULES_MAP = {
keepSelector: `code, img, svg, pre, .sitebit`,
ignoreSelector: `button, code, footer, form, header, mark, nav, pre, .reply`,
autoScan: `false`,
textStyle: OPT_STYLE_BLOCKQUOTE,
},
"twitter.com, https://x.com": {
selector: `[data-testid='tweetText']`,
keepSelector: `img, svg, span:has(a), div:has(a)`,
autoScan: `false`,
textStyle: OPT_STYLE_DASHBOX,
},
"www.youtube.com": {
rootsSelector: `ytd-page-manager`,
ignoreSelector: `aside, button, footer, form, header, pre, mark, nav, #player, #container, .caption-window, .ytp-settings-menu`,
textStyle: OPT_STYLE_DASHBOX,
},
};

View File

@@ -178,7 +178,10 @@ export const checkRules = (rules) => {
injectCss: type(injectCss) === "string" ? injectCss : "",
bgColor: type(bgColor) === "string" ? bgColor : "",
textDiyStyle: type(textDiyStyle) === "string" ? textDiyStyle : "",
apiSlug: apiSlug?.trim() || DEFAULT_API_TYPE,
apiSlug:
type(apiSlug) === "string" && apiSlug.trim() !== ""
? apiSlug.trim()
: GLOBAL_KEY,
fromLang: matchValue([GLOBAL_KEY, ...fromLangs], fromLang),
toLang: matchValue([GLOBAL_KEY, ...toLangs], toLang),
textStyle: matchValue([GLOBAL_KEY, ...OPT_STYLE_ALL], textStyle),