From 0ad07b98e481bed5fcb571474099b54af537d6a6 Mon Sep 17 00:00:00 2001 From: Zain Date: Wed, 17 Dec 2025 13:01:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(quark):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9docume?= =?UTF-8?q?nt.body=E7=9A=84null=E6=A3=80=E6=9F=A5=E5=B9=B6=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=E8=84=9A=E6=9C=AC=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加防御性检查确保在document_start阶段也能正确处理DOM标记 同时更新版本号至0.1.1 --- manifest.json | 2 +- package.json | 2 +- src/adapters/quark/page-script.ts | 17 +++++++++++++++-- src/shared/version.ts | 8 ++++---- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index 940f702..bdedede 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "default_locale": "zh_CN", "name": "__MSG_extName__", - "version": "0.1.0", + "version": "0.1.1", "description": "__MSG_extDescription__", "permissions": [ "storage", diff --git a/package.json b/package.json index a8307c1..7c59686 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloud-drive-renamer", - "version": "0.1.0", + "version": "0.1.1", "description": "批量重命名工具,支持夸克网盘(阿里云盘和百度网盘开发中)", "type": "module", "scripts": { diff --git a/src/adapters/quark/page-script.ts b/src/adapters/quark/page-script.ts index 6fbc455..2698c33 100644 --- a/src/adapters/quark/page-script.ts +++ b/src/adapters/quark/page-script.ts @@ -186,8 +186,21 @@ window.__QUARK_PAGE_SCRIPT_READY__ = { // === PRIMARY: Set DOM-based flag for cross-world communication === // This is the reliable method that works across MAIN and ISOLATED worlds -document.body.dataset.quarkPageScriptReady = 'true'; -document.body.dataset.quarkPageScriptTimestamp = flagTimestamp.toString(); +// Defensive null check: document.body may be null at document_start +if (document.body) { + // Fast path: body already exists (common case after DOMContentLoaded) + document.body.dataset.quarkPageScriptReady = 'true'; + document.body.dataset.quarkPageScriptTimestamp = flagTimestamp.toString(); +} else { + // Fallback: defer to DOMContentLoaded when body is not ready yet + // This ensures we don't lose the DOM dataset signal even at document_start + document.addEventListener('DOMContentLoaded', () => { + const deferredTimestamp = Date.now(); + document.body.dataset.quarkPageScriptReady = 'true'; + document.body.dataset.quarkPageScriptTimestamp = deferredTimestamp.toString(); + }, { once: true }); +} // Send postMessage event for real-time notification +// Note: This is sent immediately regardless of body readiness for lowest latency window.postMessage({ type: 'QUARK_PAGE_SCRIPT_READY' }, '*'); diff --git a/src/shared/version.ts b/src/shared/version.ts index d35d5c6..1afc934 100644 --- a/src/shared/version.ts +++ b/src/shared/version.ts @@ -10,19 +10,19 @@ * 1. Edit version in package.json * 2. Run: npm run sync:version (or automatically via prebuild/predev) * - * Generated at: 2025-12-17T03:32:33.289Z + * Generated at: 2025-12-17T04:47:58.196Z */ /** * Application version number (e.g., "0.1.0") */ -export const APP_VERSION = '0.1.0' as const; +export const APP_VERSION = '0.1.1' as const; /** * Application version with 'v' prefix (e.g., "v0.1.0") * Commonly used for display purposes */ -export const APP_VERSION_WITH_PREFIX = 'v0.1.0' as const; +export const APP_VERSION_WITH_PREFIX = 'v0.1.1' as const; /** * Parse version into components @@ -30,5 +30,5 @@ export const APP_VERSION_WITH_PREFIX = 'v0.1.0' as const; export const VERSION_PARTS = { major: 0, minor: 1, - patch: 0, + patch: 1, } as const;