From 1bdf44df9e37c6a080e4f3ed1d678da2ed8d181d Mon Sep 17 00:00:00 2001 From: LyInfi Date: Thu, 19 Feb 2026 12:12:26 +0800 Subject: [PATCH] fix(wechat-browser): fix upload progress check crashing on second iteration Runtime.evaluate reuses the same JS execution context across calls in a session. The previous expression used `const thumbs = ...` which throws "Identifier 'thumbs' has already been declared" on the second loop iteration, causing result.value to be undefined and JSON.parse to throw "JSON Parse error: Unexpected identifier 'undefined'". Fix by inlining the querySelector into a single expression with no variable declaration, eliminating the re-declaration error. Co-Authored-By: Claude Sonnet 4.6 --- skills/baoyu-post-to-wechat/scripts/wechat-browser.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/skills/baoyu-post-to-wechat/scripts/wechat-browser.ts b/skills/baoyu-post-to-wechat/scripts/wechat-browser.ts index d7f0670..d28977d 100644 --- a/skills/baoyu-post-to-wechat/scripts/wechat-browser.ts +++ b/skills/baoyu-post-to-wechat/scripts/wechat-browser.ts @@ -570,10 +570,7 @@ export async function postToWeChat(options: WeChatBrowserOptions): Promise for (let i = 0; i < 30; i++) { await sleep(2000); const uploadCheck = await cdp.send<{ result: { value: string } }>('Runtime.evaluate', { - expression: ` - const thumbs = document.querySelectorAll('.weui-desktop-upload__thumb, .pic_item, [class*=upload_thumb]'); - JSON.stringify({ uploaded: thumbs.length }); - `, + expression: `JSON.stringify({ uploaded: document.querySelectorAll('.weui-desktop-upload__thumb, .pic_item, [class*=upload_thumb]').length })`, returnByValue: true, }, { sessionId }); const status = JSON.parse(uploadCheck.result.value);