profile.js
1 import { cli } from '@jackwener/opencli/registry'; 2 cli({ 3 site: 'facebook', 4 name: 'profile', 5 description: 'Get Facebook user/page profile info', 6 domain: 'www.facebook.com', 7 args: [ 8 { 9 name: 'username', 10 required: true, 11 positional: true, 12 help: 'Facebook username or page name', 13 }, 14 ], 15 columns: ['name', 'username', 'friends', 'followers', 'url'], 16 pipeline: [ 17 { navigate: { url: 'https://www.facebook.com/${{ args.username }}', settleMs: 3000 } }, 18 { evaluate: `(() => { 19 const h1 = document.querySelector('h1'); 20 let name = h1 ? h1.textContent.trim() : ''; 21 22 // Find friends/followers links 23 const links = Array.from(document.querySelectorAll('a')); 24 const friendsLink = links.find(a => a.href && a.href.includes('/friends')); 25 const followersLink = links.find(a => a.href && a.href.includes('/followers')); 26 27 return [{ 28 name: name, 29 username: \${{ args.username | json }}, 30 friends: friendsLink ? friendsLink.textContent.trim() : '-', 31 followers: followersLink ? followersLink.textContent.trim() : '-', 32 url: window.location.href, 33 }]; 34 })() 35 ` }, 36 ], 37 });