diff --git a/src/main.ts b/src/main.ts index c476303..d20ed8c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,8 @@ import { Functions } from "./functions"; import { createConsole, createConsoleGroup, getRoomsPanelWidth } from "./utils"; function init() { - if (!getRoomsPanelWidth()) { + // #app > .vac-col-messages 是用于判断是否在「转发聊天页面」页面 + if (!getRoomsPanelWidth() && !document.querySelector("#app > .vac-col-messages")) { setTimeout(init, 1000); createConsole("ADDON", "rooms-panel not found, try again after 1s"); return; diff --git a/src/utils.ts b/src/utils.ts index e221f1e..9e3fd37 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -45,8 +45,8 @@ export function getRootStyle(key: any) { } export function getRoomsPanelWidth() { - return (document.getElementsByClassName("rooms-panel")[0] as HTMLElement) - .style.width; + return (document.getElementsByClassName("rooms-panel")[0] as HTMLElement || undefined) + ?.style.width; } export function createConsole(code: string, desc: string) {