fix: Some element tagnames are lowercase. (#377)

This commit is contained in:
Gabe
2025-11-05 20:48:12 +08:00
parent 629bf9461a
commit 2bb8a5182c
3 changed files with 10 additions and 5 deletions

View File

@@ -118,6 +118,10 @@ async function getFavWords(rule) {
*/
export async function run(isUserscript = false) {
try {
if (document?.documentElement?.tagName?.toUpperCase() !== "HTML") {
return;
}
// 读取设置信息
const setting = await getSettingWithDefault();

View File

@@ -1,5 +1,3 @@
import { run } from "./common";
if (document.documentElement && document.documentElement.tagName === "HTML") {
run();
}
run();

View File

@@ -1322,7 +1322,10 @@ export class Translator {
// node.matches(this.#ignoreSelector) ||
!node.textContent.trim()
) {
if (node.tagName === "IMG" || node.tagName === "SVG") {
if (
node.tagName?.toUpperCase() === "IMG" ||
node.tagName?.toUpperCase() === "SVG"
) {
node.style.width = `${node.offsetWidth}px`;
node.style.height = `${node.offsetHeight}px`;
}
@@ -1336,7 +1339,7 @@ export class Translator {
if (
this.#rule.hasRichText === "true" &&
Translator.TAGS.WARP.has(node.tagName)
Translator.TAGS.WARP.has(node.tagName?.toUpperCase())
) {
wrapCounter++;
const startPlaceholder = `<${this.#placeholder.tagName}${wrapCounter}>`;