channel-worker 2.5.71 → 2.5.72
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 +64 -7
package/package.json
CHANGED
|
@@ -574,6 +574,30 @@ async function isThumbnailEditorVisible(page) {
|
|
|
574
574
|
}, THUMBNAIL_EDITOR_TEXT_MARKERS).catch(() => false);
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
+
// Bằng chứng "thumb tuỳ chỉnh ĐANG được áp" không thể nhầm: nút "Gỡ hình thu
|
|
578
|
+
// nhỏ tùy chỉnh khỏi thước phim" chỉ tồn tại khi đã có thumb tuỳ chỉnh. Cần
|
|
579
|
+
// cho biến thể INLINE (bắt 03/09, idea 6a965a32 fail 5 lượt liên tiếp):
|
|
580
|
+
// editor "nested" nằm HẲN trong bước "Cài đặt thước phim" và không bao giờ
|
|
581
|
+
// "đóng" — marker "Chỉnh sửa hình thu nhỏ" thường trực trong innerText của
|
|
582
|
+
// dialog nên isThumbnailEditorVisible kẹt true, vòng chờ đóng cạn 60s rồi
|
|
583
|
+
// ESC+Hủy phá lượt dù thumb đã dán xong (diag 158386: Gỡ/Lưu/Hủy + Đăng
|
|
584
|
+
// cùng hiện trên một bước).
|
|
585
|
+
async function isCustomThumbApplied(page) {
|
|
586
|
+
return page.evaluate(() => {
|
|
587
|
+
const vis = (el) => {
|
|
588
|
+
const r = el.getBoundingClientRect();
|
|
589
|
+
if (r.width < 8 || r.height < 8) return false;
|
|
590
|
+
const cs = getComputedStyle(el);
|
|
591
|
+
return cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0';
|
|
592
|
+
};
|
|
593
|
+
for (const el of document.querySelectorAll('[aria-label]')) {
|
|
594
|
+
const al = el.getAttribute('aria-label') || '';
|
|
595
|
+
if (/Gỡ hình thu nhỏ tùy chỉnh|Remove( your)? custom thumbnail/i.test(al) && vis(el)) return true;
|
|
596
|
+
}
|
|
597
|
+
return false;
|
|
598
|
+
}).catch(() => false);
|
|
599
|
+
}
|
|
600
|
+
|
|
577
601
|
const SAFE_RETRY_COMPOSER_CLOSED = 'FB_SAFE_RETRY_COMPOSER_CLOSED';
|
|
578
602
|
|
|
579
603
|
function safeComposerRetryError(message) {
|
|
@@ -1654,6 +1678,7 @@ async function runOnce({ page, payload, log }) {
|
|
|
1654
1678
|
const closeDeadline = Date.now() + 60_000;
|
|
1655
1679
|
let modalClosed = false;
|
|
1656
1680
|
let closedPolls = 0;
|
|
1681
|
+
let appliedPolls = 0;
|
|
1657
1682
|
let retryCount = 0;
|
|
1658
1683
|
const RETRY_AFTER_MS = 12_000;
|
|
1659
1684
|
let lastRetryAt = Date.now();
|
|
@@ -1663,6 +1688,23 @@ async function runOnce({ page, payload, log }) {
|
|
|
1663
1688
|
// nested form (no own dialog — its upload button, aria
|
|
1664
1689
|
// "Tải hình thu nhỏ tùy chỉnh lên…", only exists while the
|
|
1665
1690
|
// editor is showing).
|
|
1691
|
+
// Biến thể inline: panel không bao giờ đóng nhưng nút "Gỡ hình
|
|
1692
|
+
// thu nhỏ tùy chỉnh" đã hiện = thumb ĐÃ áp. Chỉ tin ở nhánh
|
|
1693
|
+
// nested (modal thật vẫn phải đóng sau Lưu như cũ) và đòi 2
|
|
1694
|
+
// mẫu liên tiếp như luật closedPolls; bấm Lưu chốt một nhịp
|
|
1695
|
+
// cuối phòng cohort nào đó vẫn cần Lưu để giữ trạng thái.
|
|
1696
|
+
if (thumbEditorVia === 'nested' && await isCustomThumbApplied(page)) {
|
|
1697
|
+
if (++appliedPolls >= 2) {
|
|
1698
|
+
for (const sel of saveCandidates) {
|
|
1699
|
+
const btn = await firstVisible(page.locator(sel), 1);
|
|
1700
|
+
if (btn) { await btn.click({ timeout: 1500 }).catch(() => {}); break; }
|
|
1701
|
+
}
|
|
1702
|
+
log('info', '[fb-pw] page-wall thumb — panel inline không đóng nhưng nút "Gỡ hình thu nhỏ" đang hiện → coi như dán xong');
|
|
1703
|
+
modalClosed = true; break;
|
|
1704
|
+
}
|
|
1705
|
+
} else {
|
|
1706
|
+
appliedPolls = 0;
|
|
1707
|
+
}
|
|
1666
1708
|
const still = await isThumbnailEditorVisible(page);
|
|
1667
1709
|
if (!still) {
|
|
1668
1710
|
// Require two consecutive closed samples. Facebook briefly
|
|
@@ -1702,6 +1744,11 @@ async function runOnce({ page, payload, log }) {
|
|
|
1702
1744
|
}
|
|
1703
1745
|
thumbApplied = true;
|
|
1704
1746
|
log('info', `[fb-pw] page-wall thumb — modal closed after save (retries=${retryCount})`);
|
|
1747
|
+
} else if (thumbEditorVia === 'nested' && await isCustomThumbApplied(page)) {
|
|
1748
|
+
// Hết giờ chờ đóng nhưng bằng chứng áp thumb còn đó — tuyệt
|
|
1749
|
+
// đối không ESC/Hủy (Hủy trên panel inline là GỠ thumb).
|
|
1750
|
+
log('info', '[fb-pw] page-wall thumb — hết giờ chờ đóng nhưng nút "Gỡ hình thu nhỏ" đang hiện → giữ panel, coi như dán xong');
|
|
1751
|
+
thumbApplied = true;
|
|
1705
1752
|
} else {
|
|
1706
1753
|
log('warn', '[fb-pw] page-wall thumb — modal still open 60s after Lưu click; trying ESC + click Hủy fallback');
|
|
1707
1754
|
await page.keyboard.press('Escape').catch(() => {});
|
|
@@ -2077,13 +2124,22 @@ async function runOnce({ page, payload, log }) {
|
|
|
2077
2124
|
// output. (Observed on reel 1506614811005729: step 1 → click Tiếp
|
|
2078
2125
|
// → publish, the thumb-edit pill never appeared.)
|
|
2079
2126
|
if (thumbPath && !customThumbDone) {
|
|
2080
|
-
//
|
|
2081
|
-
//
|
|
2082
|
-
//
|
|
2083
|
-
//
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2127
|
+
// Cứu theo BẰNG CHỨNG trước khi chặn: biến thể inline có thể làm cờ
|
|
2128
|
+
// customThumbDone lỡ false trong khi nút "Gỡ hình thu nhỏ tùy chỉnh"
|
|
2129
|
+
// ngay trên bước này chứng minh thumb ĐANG được áp — cả 5 lượt fail
|
|
2130
|
+
// 02-03/09 của idea 6a965a32 đều ở trạng thái này (diag 158386).
|
|
2131
|
+
if (await isCustomThumbApplied(page)) {
|
|
2132
|
+
log('info', '[fb-pw] pre-publish: nút "Gỡ hình thu nhỏ tùy chỉnh" đang hiện — thumb đã áp dù cờ chưa bật, tiếp tục đăng');
|
|
2133
|
+
customThumbDone = true;
|
|
2134
|
+
} else {
|
|
2135
|
+
// Defensive: we normally fail at the caption step (before any Tiếp)
|
|
2136
|
+
// when a required custom thumb can't be applied. If we somehow reach
|
|
2137
|
+
// here without it, refuse to publish — but BEFORE clicking Đăng, so
|
|
2138
|
+
// nothing ships and a retry can't double-post. (The v2.5.14 double-post
|
|
2139
|
+
// came from failing AFTER publish; this throw is pre-publish.)
|
|
2140
|
+
await dumpFailure(page, 'thumb-required-at-publish', log);
|
|
2141
|
+
throw new Error('Custom thumbnail required but not applied — refusing to publish with FB auto-thumb');
|
|
2142
|
+
}
|
|
2087
2143
|
}
|
|
2088
2144
|
log('info', `[fb-pw] click publish "${pub.verb}" via "${pub.sel}" (step ${step + 1})`);
|
|
2089
2145
|
// Snapshot the captured-IDs list RIGHT BEFORE the publish click. The
|
|
@@ -2850,6 +2906,7 @@ module.exports.__testables = {
|
|
|
2850
2906
|
PUBLISH_ENABLE_TIMEOUT_MS,
|
|
2851
2907
|
PUBLISH_CTA_ABSENT_GRACE_MS,
|
|
2852
2908
|
THUMBNAIL_EDITOR_TEXT_MARKERS,
|
|
2909
|
+
isCustomThumbApplied,
|
|
2853
2910
|
REEL_CREATE_SELECTORS,
|
|
2854
2911
|
REEL_ENTRY_SELECTORS,
|
|
2855
2912
|
ADD_VIDEO_SELECTORS,
|