channel-worker 2.5.19 → 2.5.21
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 +42 -19
package/package.json
CHANGED
|
@@ -283,7 +283,7 @@ async function run({ page, payload, log }) {
|
|
|
283
283
|
} = payload || {};
|
|
284
284
|
if (!video_url) throw new Error('No video_url provided');
|
|
285
285
|
|
|
286
|
-
log('info', '[fb-pw] selectors version=2026.06.
|
|
286
|
+
log('info', '[fb-pw] selectors version=2026.06.19b-thumb-diag');
|
|
287
287
|
|
|
288
288
|
page.on('dialog', (d) => { d.accept().catch(() => {}); });
|
|
289
289
|
|
|
@@ -948,7 +948,6 @@ async function run({ page, payload, log }) {
|
|
|
948
948
|
// iterations, throw with diagnostics.
|
|
949
949
|
let published = false;
|
|
950
950
|
let customThumbDone = false;
|
|
951
|
-
let thumbWaitDone = false; // poll for the thumb-edit pill at most once
|
|
952
951
|
let pubWaitDone = false; // guard: wait for a disabled "Đăng" at most once
|
|
953
952
|
for (let step = 0; step < 7 && !published; step++) {
|
|
954
953
|
await page.waitForTimeout(3000);
|
|
@@ -969,7 +968,9 @@ async function run({ page, payload, log }) {
|
|
|
969
968
|
const dlgs = [];
|
|
970
969
|
for (const d of allDlgs) {
|
|
971
970
|
const txt = (d.innerText || '').slice(0, 400);
|
|
972
|
-
|
|
971
|
+
// Match ALL reel-composer steps: "Tạo thước phim" (video step),
|
|
972
|
+
// the caption/cover step, and "Cài đặt thước phim" (settings step).
|
|
973
|
+
if (/thước phim|create reel|create a reel|reel settings/i.test(txt)) dlgs.push(d);
|
|
973
974
|
}
|
|
974
975
|
if (dlgs.length === 0) return null;
|
|
975
976
|
for (const dlg of dlgs) {
|
|
@@ -1001,17 +1002,18 @@ async function run({ page, payload, log }) {
|
|
|
1001
1002
|
return null;
|
|
1002
1003
|
}).catch(() => null);
|
|
1003
1004
|
let editBtn = await findThumbBtn();
|
|
1004
|
-
// The "Chỉnh sửa hình thu nhỏ" pill
|
|
1005
|
-
//
|
|
1006
|
-
//
|
|
1007
|
-
//
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1005
|
+
// The "Chỉnh sửa hình thu nhỏ" pill appears AFTER FB finishes processing
|
|
1006
|
+
// the video AND, on the Page-wall composer, only on a LATER step (the
|
|
1007
|
+
// cover/caption step AFTER clicking "Tiếp" from the video step) — NOT on
|
|
1008
|
+
// the first video step. So poll briefly on THIS step; if it never shows,
|
|
1009
|
+
// fall through to click "Tiếp" and look again on the next step. Per-step
|
|
1010
|
+
// (not one-time) so the pill is caught on whichever step it renders.
|
|
1011
|
+
if (!editBtn) {
|
|
1012
|
+
log('info', '[fb-pw] thumb-edit pill not visible on this step — polling up to 18s…');
|
|
1013
|
+
const tdl = Date.now() + 18_000;
|
|
1014
|
+
while (!editBtn && Date.now() < tdl) { await page.waitForTimeout(3000); editBtn = await findThumbBtn(); }
|
|
1012
1015
|
if (editBtn) log('info', '[fb-pw] thumb-edit pill appeared after wait');
|
|
1013
1016
|
}
|
|
1014
|
-
thumbWaitDone = true;
|
|
1015
1017
|
|
|
1016
1018
|
let thumbApplied = false;
|
|
1017
1019
|
if (editBtn) {
|
|
@@ -1158,14 +1160,35 @@ async function run({ page, payload, log }) {
|
|
|
1158
1160
|
}
|
|
1159
1161
|
customThumbDone = thumbApplied;
|
|
1160
1162
|
}
|
|
1161
|
-
//
|
|
1162
|
-
//
|
|
1163
|
-
//
|
|
1164
|
-
//
|
|
1163
|
+
// Pill not on THIS step (e.g. the video step before "Tiếp", or the
|
|
1164
|
+
// cover step hasn't rendered yet). Do NOT hard-fail here — click "Tiếp"
|
|
1165
|
+
// to advance and retry the thumb flow on the next step. The pre-publish
|
|
1166
|
+
// check below (before clicking "Đăng") hard-fails if the thumb was never
|
|
1167
|
+
// applied across ANY step, so nothing ships with FB's auto-thumb and a
|
|
1168
|
+
// retry can't double-post.
|
|
1165
1169
|
if (!customThumbDone) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1170
|
+
// DIAG: dump the reel-dialog buttons on this step so we can locate the
|
|
1171
|
+
// cover/thumbnail control when detection misses it (different UI variant).
|
|
1172
|
+
try {
|
|
1173
|
+
const diag = await page.evaluate(() => {
|
|
1174
|
+
const dlgs = [...document.querySelectorAll("[role='dialog']")]
|
|
1175
|
+
.filter(d => /thước phim|create reel|reel settings/i.test((d.innerText || '').slice(0, 400)));
|
|
1176
|
+
const out = [];
|
|
1177
|
+
for (const d of dlgs) {
|
|
1178
|
+
const hdr = (d.innerText || '').split('\n')[0].slice(0, 40);
|
|
1179
|
+
for (const el of d.querySelectorAll("[role='button'],button,[aria-label],img")) {
|
|
1180
|
+
const t = (el.innerText || '').trim().slice(0, 28);
|
|
1181
|
+
const al = (el.getAttribute('aria-label') || '').trim().slice(0, 40);
|
|
1182
|
+
const r = el.getBoundingClientRect();
|
|
1183
|
+
if (r.width < 10 || r.height < 10) continue;
|
|
1184
|
+
if (t || al) out.push(`[${hdr}] <${el.tagName.toLowerCase()}> t="${t}" al="${al}" ${Math.round(r.width)}x${Math.round(r.height)}`);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return out.slice(0, 45);
|
|
1188
|
+
}).catch(() => []);
|
|
1189
|
+
log('info', `[fb-pw] thumb-diag step ${step + 1}: ${JSON.stringify(diag)}`);
|
|
1190
|
+
} catch { /* diag best-effort */ }
|
|
1191
|
+
log('info', '[fb-pw] thumb-edit pill not on this step yet — advancing via "Tiếp" to retry on the next step');
|
|
1169
1192
|
}
|
|
1170
1193
|
}
|
|
1171
1194
|
|