notebooks.js
1 import { cli, Strategy } from '@jackwener/opencli/registry'; 2 import { fetchPrivateApi } from './utils.js'; 3 cli({ 4 site: 'weread', 5 name: 'notebooks', 6 description: 'List books that have highlights or notes', 7 domain: 'weread.qq.com', 8 strategy: Strategy.COOKIE, 9 columns: ['title', 'author', 'noteCount', 'bookId'], 10 func: async (page, _args) => { 11 const data = await fetchPrivateApi(page, '/user/notebooks'); 12 const books = data?.books ?? []; 13 return books.map((item) => ({ 14 title: item.book?.title ?? '', 15 author: item.book?.author ?? '', 16 // TODO: bookmarkCount/reviewCount field names from community docs, verify with real API 17 noteCount: (item.bookmarkCount ?? 0) + (item.reviewCount ?? 0), 18 bookId: item.bookId ?? '', 19 })); 20 }, 21 });