9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import { cli } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'facebook',
|
|
name: 'memories',
|
|
access: 'read',
|
|
description: 'Get your Facebook memories (On This Day)',
|
|
domain: 'www.facebook.com',
|
|
args: [
|
|
{ name: 'limit', type: 'int', default: 10, help: 'Number of memories' },
|
|
],
|
|
columns: ['index', 'source', 'content', 'time'],
|
|
pipeline: [
|
|
{ navigate: { url: 'https://www.facebook.com/onthisday', settleMs: 4000 } },
|
|
{ evaluate: `(() => {
|
|
const limit = \${{ args.limit }};
|
|
const articles = document.querySelectorAll('[role="article"]');
|
|
return Array.from(articles)
|
|
.slice(0, limit)
|
|
.map((el, i) => {
|
|
const headerLink = el.querySelector('h2 a, h3 a, h4 a, strong a');
|
|
const spans = Array.from(el.querySelectorAll('div[dir="auto"]'))
|
|
.map(s => s.textContent.trim())
|
|
.filter(t => t.length > 5 && t.length < 500);
|
|
const timeEl = el.querySelector('a[href*="/posts/"] span, a[href*="story_fbid"] span');
|
|
return {
|
|
index: i + 1,
|
|
source: headerLink ? headerLink.textContent.trim().substring(0, 50) : '-',
|
|
content: (spans[0] || '').replace(/\\n/g, ' ').substring(0, 150),
|
|
time: timeEl ? timeEl.textContent.trim() : '-',
|
|
};
|
|
})
|
|
.filter(item => item.content.length > 0 || item.source !== '-');
|
|
})()
|
|
` },
|
|
],
|
|
});
|