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
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
import { cli } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'facebook',
|
|
name: 'add-friend',
|
|
access: 'write',
|
|
description: 'Send a friend request on Facebook',
|
|
domain: 'www.facebook.com',
|
|
args: [
|
|
{
|
|
name: 'username',
|
|
required: true,
|
|
positional: true,
|
|
help: 'Facebook username or profile URL',
|
|
},
|
|
],
|
|
columns: ['status', 'username'],
|
|
pipeline: [
|
|
{ navigate: { url: 'https://www.facebook.com/${{ args.username }}', settleMs: 3000 } },
|
|
{ evaluate: `(async () => {
|
|
const username = \${{ args.username | json }};
|
|
// Find "Add Friend" button
|
|
const buttons = Array.from(document.querySelectorAll('[role="button"]'));
|
|
const addBtn = buttons.find(b => {
|
|
const text = b.textContent.trim();
|
|
return text === '加好友' || text === 'Add Friend' || text === 'Add friend';
|
|
});
|
|
|
|
if (!addBtn) {
|
|
// Check if already friends
|
|
const isFriend = buttons.some(b => {
|
|
const t = b.textContent.trim();
|
|
return t === '好友' || t === 'Friends' || t.includes('已发送') || t.includes('Pending');
|
|
});
|
|
if (isFriend) return [{ status: 'Already friends or request pending', username }];
|
|
return [{ status: 'Add Friend button not found', username }];
|
|
}
|
|
|
|
addBtn.click();
|
|
await new Promise(r => setTimeout(r, 1500));
|
|
return [{ status: 'Friend request sent', username }];
|
|
})()
|
|
` },
|
|
],
|
|
});
|