feat(baoyu-post-to-weibo): add video support and improve upload reliability

- Add --video flag for video uploads (max 18 files total)
- Switch from clipboard paste to DOM.setFileInputFiles for uploads
- Add Chrome health check with auto-restart for unresponsive instances
- Add navigation check to ensure Weibo home page before posting
This commit is contained in:
Jim Liu 宝玉
2026-03-06 20:27:18 -06:00
parent f00ca11d9a
commit 39c7e86a8d
5 changed files with 120 additions and 66 deletions
@@ -53,6 +53,20 @@ export function findExistingChromeDebugPort(profileDir: string): number | null {
return null;
}
export function killChromeByProfile(profileDir: string): void {
try {
const result = spawnSync('ps', ['aux'], { encoding: 'utf-8', timeout: 5000 });
if (result.status !== 0 || !result.stdout) return;
for (const line of result.stdout.split('\n')) {
if (!line.includes(profileDir) || !line.includes('--remote-debugging-port=')) continue;
const pidMatch = line.trim().split(/\s+/)[1];
if (pidMatch) {
try { process.kill(Number(pidMatch), 'SIGTERM'); } catch {}
}
}
} catch {}
}
export function getDefaultProfileDir(): string {
const override = process.env.BAOYU_CHROME_PROFILE_DIR?.trim() || process.env.WEIBO_BROWSER_PROFILE_DIR?.trim();
if (override) return path.resolve(override);