channel-worker 2.5.49 → 2.5.50
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/nurture_facebook.js +21 -0
package/package.json
CHANGED
|
@@ -351,6 +351,26 @@ async function followVisiblePage(page, log) {
|
|
|
351
351
|
return ok;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
+
// debug:true only — screenshot the feed and hand back a viewable URL. Cheaper
|
|
355
|
+
// than another round of guessing at selectors from log lines.
|
|
356
|
+
async function dumpFeedShot(page, log, tag) {
|
|
357
|
+
try {
|
|
358
|
+
const fs = require('fs');
|
|
359
|
+
const os = require('os');
|
|
360
|
+
const path = require('path');
|
|
361
|
+
const dir = path.join(os.tmpdir(), 'cm-worker-pw');
|
|
362
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
363
|
+
const png = path.join(dir, `nurture-${tag}-${Date.now()}.png`);
|
|
364
|
+
await page.screenshot({ path: png, fullPage: false, timeout: 8000 }).catch(() => {});
|
|
365
|
+
if (fs.existsSync(png) && typeof log.uploadDebugScreenshot === 'function') {
|
|
366
|
+
const url = await log.uploadDebugScreenshot(png, { tag });
|
|
367
|
+
log('warn', `[nurture-fb][dbg] screenshot ${tag}: ${url && url.url ? url.url : JSON.stringify(url)}`);
|
|
368
|
+
}
|
|
369
|
+
} catch (e) {
|
|
370
|
+
log('info', `[nurture-fb][dbg] screenshot failed: ${String(e.message || e).slice(0, 80)}`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
354
374
|
// ─── main ───────────────────────────────────────────────────────────────────
|
|
355
375
|
async function run({ page, payload, log }) {
|
|
356
376
|
const t0 = Date.now();
|
|
@@ -378,6 +398,7 @@ async function run({ page, payload, log }) {
|
|
|
378
398
|
await dismissDialogs(page, log);
|
|
379
399
|
|
|
380
400
|
await centerMouse(page); // wheel events need the cursor over the feed column
|
|
401
|
+
if (payload.debug) await dumpFeedShot(page, log, 'feed-start');
|
|
381
402
|
|
|
382
403
|
let postsSeen = 0, likes = 0, videos = 0, pagesFollowed = 0, postsOpened = 0;
|
|
383
404
|
let postsSinceLike = likeGap; // allow the first like once enough posts scroll by
|