From 7e11b467d17f450a76040a70cdaa6d2cd7ca4e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Sun, 5 May 2024 16:19:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20=E5=AE=8C=E5=96=84=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC&p=E9=83=A8=E5=88=86=E7=9A=84=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/utils/parseAnno.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/web/utils/parseAnno.ts b/src/web/utils/parseAnno.ts index a3732a35..5b6b336d 100644 --- a/src/web/utils/parseAnno.ts +++ b/src/web/utils/parseAnno.ts @@ -1,7 +1,7 @@ /** * @file web/utils/parseAnno.ts * @description 解析游戏内公告数据 - * @since Beta v0.4.4 + * @since Beta v0.4.7 */ import { saveImgLocal } from "../../utils/TGShare"; @@ -33,7 +33,7 @@ function parseAnnoA(a: HTMLAnchorElement): HTMLAnchorElement { /** * @description 解析 p - * @since Beta v0.4.4 + * @since Beta v0.4.7 * @param {HTMLParagraphElement} p p 元素 * @returns {HTMLParagraphElement} 解析后的 p 元素 */ @@ -42,9 +42,7 @@ function parseAnnoP(p: HTMLParagraphElement): HTMLParagraphElement { p.innerHTML = decodeRegExp(p.innerHTML); } else { p.querySelectorAll("*").forEach((child) => { - if (child.children.length === 0) { - child.innerHTML = decodeRegExp(child.innerHTML); - } + child.innerHTML = decodeRegExp(child.innerHTML); }); } return p; @@ -72,6 +70,9 @@ function parseAnnoSpan(span: HTMLSpanElement): HTMLSpanElement { if (child.children.length === 0) { child.innerHTML = decodeRegExp(child.innerHTML); } + if (child.tagName === "T") { + child.outerHTML = child.innerHTML; + } }); } return span; @@ -79,14 +80,16 @@ function parseAnnoSpan(span: HTMLSpanElement): HTMLSpanElement { /** * @description 解析 table - * @since Beta v0.4.4 + * @since Beta v0.4.7 * @param {HTMLTableElement} table table 元素 * @returns {HTMLTableElement} 解析后的 table 元素 */ function parseAnnoTable(table: HTMLTableElement): HTMLTableElement { table.style.borderColor = "var(--common-shadow-2)"; + table.querySelectorAll("colgroup").forEach((colgroup) => colgroup.remove()); table.querySelectorAll("td").forEach((td) => { if (td.style.backgroundColor) td.style.backgroundColor = "var(--box-bg-1)"; + td.style.textAlign = "center"; }); return table; }