fix(quark): 添加对document.body的null检查并改进脚本加载逻辑

添加防御性检查确保在document_start阶段也能正确处理DOM标记
同时更新版本号至0.1.1
这个提交包含在:
Zain 2025-12-17 13:01:36 +08:00
父节点 5830b3436d
当前提交 0ad07b98e4
共有 4 个文件被更改,包括 21 次插入 和 8 次删除

查看文件

@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"default_locale": "zh_CN", "default_locale": "zh_CN",
"name": "__MSG_extName__", "name": "__MSG_extName__",
"version": "0.1.0", "version": "0.1.1",
"description": "__MSG_extDescription__", "description": "__MSG_extDescription__",
"permissions": [ "permissions": [
"storage", "storage",

查看文件

@ -1,6 +1,6 @@
{ {
"name": "cloud-drive-renamer", "name": "cloud-drive-renamer",
"version": "0.1.0", "version": "0.1.1",
"description": "批量重命名工具,支持夸克网盘(阿里云盘和百度网盘开发中)", "description": "批量重命名工具,支持夸克网盘(阿里云盘和百度网盘开发中)",
"type": "module", "type": "module",
"scripts": { "scripts": {

查看文件

@ -186,8 +186,21 @@ window.__QUARK_PAGE_SCRIPT_READY__ = {
// === PRIMARY: Set DOM-based flag for cross-world communication === // === PRIMARY: Set DOM-based flag for cross-world communication ===
// This is the reliable method that works across MAIN and ISOLATED worlds // This is the reliable method that works across MAIN and ISOLATED worlds
// 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.quarkPageScriptReady = 'true';
document.body.dataset.quarkPageScriptTimestamp = flagTimestamp.toString(); 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 // 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' }, '*'); window.postMessage({ type: 'QUARK_PAGE_SCRIPT_READY' }, '*');

查看文件

@ -10,19 +10,19 @@
* 1. Edit version in package.json * 1. Edit version in package.json
* 2. Run: npm run sync:version (or automatically via prebuild/predev) * 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") * 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") * Application version with 'v' prefix (e.g., "v0.1.0")
* Commonly used for display purposes * 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 * Parse version into components
@ -30,5 +30,5 @@ export const APP_VERSION_WITH_PREFIX = 'v0.1.0' as const;
export const VERSION_PARTS = { export const VERSION_PARTS = {
major: 0, major: 0,
minor: 1, minor: 1,
patch: 0, patch: 1,
} as const; } as const;