mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-16 07:29:48 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21a5167b61 | |||
| 4d3957ca06 |
@@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
||||||
"version": "1.24.3"
|
"version": "1.24.4"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
English | [中文](./CHANGELOG.zh.md)
|
English | [中文](./CHANGELOG.zh.md)
|
||||||
|
|
||||||
|
## 1.24.4 - 2026-01-28
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- `baoyu-post-to-x`: fix Apply button click for cover image modal; add retry logic and wait for modal close.
|
||||||
|
|
||||||
## 1.24.3 - 2026-01-28
|
## 1.24.3 - 2026-01-28
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
[English](./CHANGELOG.md) | 中文
|
[English](./CHANGELOG.md) | 中文
|
||||||
|
|
||||||
|
## 1.24.4 - 2026-01-28
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
- `baoyu-post-to-x`:修复封面图上传后 Apply 按钮点击问题;增加重试逻辑并等待弹窗关闭后再继续。
|
||||||
|
|
||||||
## 1.24.3 - 2026-01-28
|
## 1.24.3 - 2026-01-28
|
||||||
|
|
||||||
### 文档
|
### 文档
|
||||||
|
|||||||
@@ -229,11 +229,51 @@ export async function publishArticle(options: ArticleOptions): Promise<void> {
|
|||||||
console.log('[x-article] Waiting for Apply button...');
|
console.log('[x-article] Waiting for Apply button...');
|
||||||
const applyFound = await waitForElement('[data-testid="applyButton"]', 15_000);
|
const applyFound = await waitForElement('[data-testid="applyButton"]', 15_000);
|
||||||
if (applyFound) {
|
if (applyFound) {
|
||||||
await cdp.send('Runtime.evaluate', {
|
// Check if modal is present
|
||||||
expression: `document.querySelector('[data-testid="applyButton"]')?.click()`,
|
const isModalOpen = async (): Promise<boolean> => {
|
||||||
}, { sessionId });
|
const result = await cdp!.send<{ result: { value: boolean } }>('Runtime.evaluate', {
|
||||||
console.log('[x-article] Cover image applied');
|
expression: `!!document.querySelector('[role="dialog"][aria-modal="true"]')`,
|
||||||
await sleep(1000);
|
returnByValue: true,
|
||||||
|
}, { sessionId });
|
||||||
|
return result.result.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Click Apply button with retry logic
|
||||||
|
const maxRetries = 3;
|
||||||
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
|
console.log(`[x-article] Clicking Apply button (attempt ${attempt}/${maxRetries})...`);
|
||||||
|
|
||||||
|
await cdp.send('Runtime.evaluate', {
|
||||||
|
expression: `document.querySelector('[data-testid="applyButton"]')?.click()`,
|
||||||
|
}, { sessionId });
|
||||||
|
|
||||||
|
// Wait for modal to close (up to 5 seconds per attempt)
|
||||||
|
const closeTimeout = 5000;
|
||||||
|
const checkInterval = 300;
|
||||||
|
const startTime = Date.now();
|
||||||
|
let modalClosed = false;
|
||||||
|
|
||||||
|
while (Date.now() - startTime < closeTimeout) {
|
||||||
|
await sleep(checkInterval);
|
||||||
|
const stillOpen = await isModalOpen();
|
||||||
|
if (!stillOpen) {
|
||||||
|
modalClosed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modalClosed) {
|
||||||
|
console.log('[x-article] Cover image applied, modal closed');
|
||||||
|
await sleep(500);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attempt < maxRetries) {
|
||||||
|
console.log('[x-article] Modal still open, retrying...');
|
||||||
|
} else {
|
||||||
|
console.log('[x-article] Modal did not close after all attempts, continuing anyway...');
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('[x-article] Apply button not found, continuing...');
|
console.log('[x-article] Apply button not found, continuing...');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user