channel-worker 2.5.37 → 2.5.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/upload_facebook.js +27 -1
package/package.json
CHANGED
|
@@ -1550,7 +1550,33 @@ async function run({ page, payload, log }) {
|
|
|
1550
1550
|
// new one is the publish mutation response.
|
|
1551
1551
|
capturedReelIdsSnapshotLen = capturedReelIds.length;
|
|
1552
1552
|
try {
|
|
1553
|
-
|
|
1553
|
+
// Retry the publish click. The button is FOUND + enabled, yet
|
|
1554
|
+
// locator.click can still time out (transient overlay / React
|
|
1555
|
+
// re-render detaching the node → "locator.click: Timeout 5000ms").
|
|
1556
|
+
// Re-find + re-click up to 3×, and on the last try fall back to a raw
|
|
1557
|
+
// JS dispatch (bypasses Playwright's obscured/stable guards).
|
|
1558
|
+
let clickedPublish = false;
|
|
1559
|
+
for (let attempt = 0; attempt < 3 && !clickedPublish; attempt++) {
|
|
1560
|
+
const target = attempt === 0 ? pub : await findByVerbs(publishVerbs, { requireBottomHalf: true });
|
|
1561
|
+
if (!target) { await page.waitForTimeout(1500); continue; }
|
|
1562
|
+
try {
|
|
1563
|
+
await target.hit.click({ timeout: 15000 });
|
|
1564
|
+
clickedPublish = true;
|
|
1565
|
+
} catch (ce) {
|
|
1566
|
+
log('warn', `[fb-pw] publish click attempt ${attempt + 1}/3 failed: ${ce.message.slice(0, 90)}`);
|
|
1567
|
+
if (attempt === 2) {
|
|
1568
|
+
const js = await page.evaluate(() => {
|
|
1569
|
+
const el = document.querySelector("[__fbpw_target__='1']")
|
|
1570
|
+
|| [...document.querySelectorAll("[role='button'],button")].find(b => ((b.getAttribute('aria-label') || b.innerText || '').trim() === 'Đăng'));
|
|
1571
|
+
if (!el) return false;
|
|
1572
|
+
el.scrollIntoView({ block: 'center' }); el.click(); return true;
|
|
1573
|
+
}).catch(() => false);
|
|
1574
|
+
if (js) { clickedPublish = true; log('info', '[fb-pw] publish via JS-dispatch fallback'); }
|
|
1575
|
+
}
|
|
1576
|
+
if (!clickedPublish) await page.waitForTimeout(2000);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (!clickedPublish) throw new Error(`publish button not clickable after 3 attempts`);
|
|
1554
1580
|
|
|
1555
1581
|
// FB shows a confirmation dialog ("Chia sẻ ai biết tin trên Facebook"
|
|
1556
1582
|
// / "Are you sure you want to share?") after the primary publish
|