notes.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 import { fetchPrivateApi, formatDate } from './utils.js'; 3 cli({ 4 site: 'weread', 5 name: 'notes', 6 description: 'List your notes (thoughts) on a book', 7 domain: 'weread.qq.com', 8 strategy: Strategy.COOKIE, 9 args: [ 10 { name: 'book-id', positional: true, required: true, help: 'Book ID (from shelf or search results)' }, 11 { name: 'limit', type: 'int', default: 20, help: 'Max results' }, 12 ], 13 columns: ['chapter', 'text', 'review', 'createTime'], 14 func: async (page, args) => { 15 const data = await fetchPrivateApi(page, '/review/list', { 16 bookId: args['book-id'], 17 listType: '11', 18 mine: '1', 19 synckey: '0', 20 }); 21 const items = data?.reviews ?? []; 22 return items.slice(0, Number(args.limit)).map((item) => ({ 23 chapter: item.review?.chapterName ?? '', 24 text: item.review?.abstract ?? '', 25 review: item.review?.content ?? '', 26 createTime: formatDate(item.review?.createTime), 27 })); 28 }, 29 });