notifications.js
1 import { cli } from '@jackwener/opencli/registry'; 2 3 cli({ 4 site: 'nowcoder', 5 name: 'notifications', 6 description: 'Unread message summary', 7 domain: 'www.nowcoder.com', 8 args: [], 9 columns: ['type', 'unread'], 10 pipeline: [ 11 { navigate: 'https://www.nowcoder.com' }, 12 { evaluate: `(async () => { 13 const r = await fetch('https://gw-c.nowcoder.com/api/sparta/message/pc/unread/detail', {credentials: 'include'}); 14 const d = await r.json(); 15 if (!d.success) throw new Error(d.msg || 'API failed'); 16 const data = d.data; 17 return [ 18 {type: 'system', unread: data.systemNotice?.unreadCount || 0}, 19 {type: 'likes', unread: data.likeCollect?.unreadCount || 0}, 20 {type: 'comments', unread: data.commentMessage?.unreadCount || 0}, 21 {type: 'follows', unread: data.followMessage?.unreadCount || 0}, 22 {type: 'messages', unread: data.privateMessage?.unreadCount || 0}, 23 {type: 'job_apply', unread: data.nowPickJobApply?.unreadCount || 0}, 24 {type: 'total', unread: data.total?.unreadCount || 0}, 25 ]; 26 })() 27 ` }, 28 ], 29 });