fix: rules
This commit is contained in:
@@ -700,9 +700,14 @@ export const I18N = {
|
|||||||
},
|
},
|
||||||
selector_parent_style: {
|
selector_parent_style: {
|
||||||
zh: `选择器父节点样式`,
|
zh: `选择器父节点样式`,
|
||||||
en: `Selector Parent Style`,
|
en: `Parent Selector Style`,
|
||||||
zh_TW: `選擇器父節點樣式`,
|
zh_TW: `選擇器父節點樣式`,
|
||||||
},
|
},
|
||||||
|
selector_grand_style: {
|
||||||
|
zh: `选择器祖节点样式`,
|
||||||
|
en: `Grand Selector Style`,
|
||||||
|
zh_TW: `選擇器祖節點樣式`,
|
||||||
|
},
|
||||||
inject_js: {
|
inject_js: {
|
||||||
zh: `注入JS`,
|
zh: `注入JS`,
|
||||||
en: `Inject JS`,
|
en: `Inject JS`,
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export const DEFAULT_RULE = {
|
|||||||
textDiyStyle: "", // 自定义译文样式
|
textDiyStyle: "", // 自定义译文样式
|
||||||
selectStyle: "", // 选择器节点样式
|
selectStyle: "", // 选择器节点样式
|
||||||
parentStyle: "", // 选择器父节点样式
|
parentStyle: "", // 选择器父节点样式
|
||||||
|
grandStyle: "", // 选择器父节点样式
|
||||||
injectJs: "", // 注入JS
|
injectJs: "", // 注入JS
|
||||||
injectCss: "", // 注入CSS
|
injectCss: "", // 注入CSS
|
||||||
transOnly: GLOBAL_KEY, // 是否仅显示译文
|
transOnly: GLOBAL_KEY, // 是否仅显示译文
|
||||||
@@ -127,6 +128,7 @@ export const GLOBLA_RULE = {
|
|||||||
textDiyStyle: DEFAULT_DIY_STYLE, // 自定义译文样式
|
textDiyStyle: DEFAULT_DIY_STYLE, // 自定义译文样式
|
||||||
selectStyle: DEFAULT_SELECT_STYLE, // 选择器节点样式
|
selectStyle: DEFAULT_SELECT_STYLE, // 选择器节点样式
|
||||||
parentStyle: DEFAULT_SELECT_STYLE, // 选择器父节点样式
|
parentStyle: DEFAULT_SELECT_STYLE, // 选择器父节点样式
|
||||||
|
grandStyle: DEFAULT_SELECT_STYLE, // 选择器祖节点样式
|
||||||
injectJs: "", // 注入JS
|
injectJs: "", // 注入JS
|
||||||
injectCss: "", // 注入CSS
|
injectCss: "", // 注入CSS
|
||||||
transOnly: "false", // 是否仅显示译文
|
transOnly: "false", // 是否仅显示译文
|
||||||
@@ -178,10 +180,6 @@ const RULES_MAP = {
|
|||||||
autoScan: `false`,
|
autoScan: `false`,
|
||||||
textStyle: OPT_STYLE_BLOCKQUOTE,
|
textStyle: OPT_STYLE_BLOCKQUOTE,
|
||||||
},
|
},
|
||||||
// "github.com": {
|
|
||||||
// selector: `.markdown-body ${DEFAULT_SELECTOR}, .repo-description p, .Layout-sidebar .f4, .container-lg .py-4 .f5, .container-lg .my-4 .f5, .Box-row .pr-4, .Box-row article .mt-1, [itemprop="description"], .markdown-title, bdi, .ws-pre-wrap, .status-meta, span.status-meta, .col-10.color-fg-muted, .TimelineItem-body, .pinned-item-list-item-content .color-fg-muted, .markdown-body td, .markdown-body th`,
|
|
||||||
// keepSelector: DEFAULT_KEEP_SELECTOR,
|
|
||||||
// },
|
|
||||||
"twitter.com, https://x.com": {
|
"twitter.com, https://x.com": {
|
||||||
selector: `[data-testid='tweetText']`,
|
selector: `[data-testid='tweetText']`,
|
||||||
keepSelector: `img, svg, span:has(a), div:has(a)`,
|
keepSelector: `img, svg, span:has(a), div:has(a)`,
|
||||||
@@ -191,7 +189,6 @@ const RULES_MAP = {
|
|||||||
"www.youtube.com": {
|
"www.youtube.com": {
|
||||||
rootsSelector: `ytd-page-manager`,
|
rootsSelector: `ytd-page-manager`,
|
||||||
ignoreSelector: `aside, button, footer, form, header, pre, mark, nav, #player`,
|
ignoreSelector: `aside, button, footer, form, header, pre, mark, nav, #player`,
|
||||||
transEndHook: `({ parentNode }) => {parentNode?.parentElement?.style.cssText += "-webkit-line-clamp: unset; max-height: none; height: auto;";}`,
|
|
||||||
textStyle: OPT_STYLE_DASHBOX,
|
textStyle: OPT_STYLE_DASHBOX,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ export const matchRule = async (href, { injectRules, subrulesList }) => {
|
|||||||
"aiTerms",
|
"aiTerms",
|
||||||
"selectStyle",
|
"selectStyle",
|
||||||
"parentStyle",
|
"parentStyle",
|
||||||
|
"grandStyle",
|
||||||
"injectJs",
|
"injectJs",
|
||||||
"injectCss",
|
"injectCss",
|
||||||
// "fixerSelector",
|
// "fixerSelector",
|
||||||
@@ -138,6 +139,7 @@ export const checkRules = (rules) => {
|
|||||||
aiTerms,
|
aiTerms,
|
||||||
selectStyle,
|
selectStyle,
|
||||||
parentStyle,
|
parentStyle,
|
||||||
|
grandStyle,
|
||||||
injectJs,
|
injectJs,
|
||||||
injectCss,
|
injectCss,
|
||||||
apiSlug,
|
apiSlug,
|
||||||
@@ -171,6 +173,7 @@ export const checkRules = (rules) => {
|
|||||||
aiTerms: type(aiTerms) === "string" ? aiTerms : "",
|
aiTerms: type(aiTerms) === "string" ? aiTerms : "",
|
||||||
selectStyle: type(selectStyle) === "string" ? selectStyle : "",
|
selectStyle: type(selectStyle) === "string" ? selectStyle : "",
|
||||||
parentStyle: type(parentStyle) === "string" ? parentStyle : "",
|
parentStyle: type(parentStyle) === "string" ? parentStyle : "",
|
||||||
|
grandStyle: type(grandStyle) === "string" ? grandStyle : "",
|
||||||
injectJs: type(injectJs) === "string" ? injectJs : "",
|
injectJs: type(injectJs) === "string" ? injectJs : "",
|
||||||
injectCss: type(injectCss) === "string" ? injectCss : "",
|
injectCss: type(injectCss) === "string" ? injectCss : "",
|
||||||
bgColor: type(bgColor) === "string" ? bgColor : "",
|
bgColor: type(bgColor) === "string" ? bgColor : "",
|
||||||
|
|||||||
@@ -960,6 +960,7 @@ export class Translator {
|
|||||||
transOnly,
|
transOnly,
|
||||||
selectStyle,
|
selectStyle,
|
||||||
parentStyle,
|
parentStyle,
|
||||||
|
grandStyle,
|
||||||
// detectRemote,
|
// detectRemote,
|
||||||
// toLang,
|
// toLang,
|
||||||
// skipLangs = [],
|
// skipLangs = [],
|
||||||
@@ -1046,6 +1047,9 @@ export class Translator {
|
|||||||
if (parentStyle && parentNode && parentNode.style) {
|
if (parentStyle && parentNode && parentNode.style) {
|
||||||
parentNode.style.cssText += parentStyle;
|
parentNode.style.cssText += parentStyle;
|
||||||
}
|
}
|
||||||
|
if (grandStyle && parentNode && parentNode.parentElement) {
|
||||||
|
parentNode.parentElement.style.cssText += grandStyle;
|
||||||
|
}
|
||||||
|
|
||||||
// 翻译完成钩子函数
|
// 翻译完成钩子函数
|
||||||
if (transEndHook?.trim()) {
|
if (transEndHook?.trim()) {
|
||||||
|
|||||||
@@ -278,7 +278,10 @@ class YouTubeCaptionProvider {
|
|||||||
|
|
||||||
const { segApiSetting, toLang } = this.#setting;
|
const { segApiSetting, toLang } = this.#setting;
|
||||||
const lang = potUrl.searchParams.get("lang");
|
const lang = potUrl.searchParams.get("lang");
|
||||||
const fromLang = OPT_LANGS_TO_CODE[OPT_TRANS_MICROSOFT].get(lang) || lang;
|
const fromLang =
|
||||||
|
OPT_LANGS_TO_CODE[OPT_TRANS_MICROSOFT].get(lang) ||
|
||||||
|
OPT_LANGS_TO_CODE[OPT_TRANS_MICROSOFT].get(lang.slice(0, 2)) ||
|
||||||
|
"auto";
|
||||||
if (potUrl.searchParams.get("kind") === "asr" && segApiSetting) {
|
if (potUrl.searchParams.get("kind") === "asr" && segApiSetting) {
|
||||||
subtitles = await this.#aiSegment({
|
subtitles = await this.#aiSegment({
|
||||||
videoId,
|
videoId,
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
|||||||
aiTerms = "",
|
aiTerms = "",
|
||||||
selectStyle = "",
|
selectStyle = "",
|
||||||
parentStyle = "",
|
parentStyle = "",
|
||||||
|
grandStyle = "",
|
||||||
injectJs = "",
|
injectJs = "",
|
||||||
injectCss = "",
|
injectCss = "",
|
||||||
apiSlug,
|
apiSlug,
|
||||||
@@ -540,6 +541,17 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
|
|||||||
maxRows={10}
|
maxRows={10}
|
||||||
multiline
|
multiline
|
||||||
/>
|
/>
|
||||||
|
<TextField
|
||||||
|
size="small"
|
||||||
|
label={i18n("selector_grand_style")}
|
||||||
|
helperText={i18n("selector_style_helper")}
|
||||||
|
name="grandStyle"
|
||||||
|
value={grandStyle}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={handleChange}
|
||||||
|
maxRows={10}
|
||||||
|
multiline
|
||||||
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
|
|||||||
Reference in New Issue
Block a user