@jackwener/opencli 1.6.8 → 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -59
- package/README.zh-CN.md +123 -79
- package/dist/clis/_shared/common.d.ts +3 -0
- package/dist/clis/_shared/common.js +22 -0
- package/dist/clis/bilibili/hot.d.ts +1 -0
- package/dist/clis/bilibili/hot.js +35 -0
- package/dist/clis/bluesky/feeds.d.ts +1 -0
- package/dist/clis/bluesky/feeds.js +27 -0
- package/dist/clis/bluesky/followers.d.ts +1 -0
- package/dist/clis/bluesky/followers.js +27 -0
- package/dist/clis/bluesky/following.d.ts +1 -0
- package/dist/clis/bluesky/following.js +27 -0
- package/dist/clis/bluesky/profile.d.ts +1 -0
- package/dist/clis/bluesky/profile.js +29 -0
- package/dist/clis/bluesky/search.d.ts +1 -0
- package/dist/clis/bluesky/search.js +28 -0
- package/dist/clis/bluesky/starter-packs.d.ts +1 -0
- package/dist/clis/bluesky/starter-packs.js +28 -0
- package/dist/clis/bluesky/thread.d.ts +1 -0
- package/dist/clis/bluesky/thread.js +30 -0
- package/dist/clis/bluesky/trending.d.ts +1 -0
- package/dist/clis/bluesky/trending.js +19 -0
- package/dist/clis/bluesky/user.d.ts +1 -0
- package/dist/clis/bluesky/user.js +33 -0
- package/dist/clis/cnki/search.d.ts +1 -0
- package/dist/clis/cnki/search.js +60 -0
- package/dist/clis/cnki/search.test.d.ts +1 -0
- package/dist/clis/cnki/search.test.js +18 -0
- package/dist/clis/devto/tag.d.ts +1 -0
- package/dist/clis/devto/tag.js +32 -0
- package/dist/clis/devto/top.d.ts +1 -0
- package/dist/clis/devto/top.js +26 -0
- package/dist/clis/devto/user.d.ts +1 -0
- package/dist/clis/devto/user.js +31 -0
- package/dist/clis/dictionary/examples.d.ts +1 -0
- package/dist/clis/dictionary/examples.js +27 -0
- package/dist/clis/dictionary/search.d.ts +1 -0
- package/dist/clis/dictionary/search.js +29 -0
- package/dist/clis/dictionary/synonyms.d.ts +1 -0
- package/dist/clis/dictionary/synonyms.js +27 -0
- package/dist/clis/douban/subject.d.ts +1 -0
- package/dist/clis/douban/subject.js +118 -0
- package/dist/clis/douban/top250.d.ts +1 -0
- package/dist/clis/douban/top250.js +67 -0
- package/dist/clis/facebook/add-friend.d.ts +1 -0
- package/dist/clis/facebook/add-friend.js +43 -0
- package/dist/clis/facebook/events.d.ts +1 -0
- package/dist/clis/facebook/events.js +40 -0
- package/dist/clis/facebook/feed.d.ts +1 -0
- package/dist/clis/facebook/feed.js +59 -0
- package/dist/clis/facebook/friends.d.ts +1 -0
- package/dist/clis/facebook/friends.js +38 -0
- package/dist/clis/facebook/groups.d.ts +1 -0
- package/dist/clis/facebook/groups.js +46 -0
- package/dist/clis/facebook/join-group.d.ts +1 -0
- package/dist/clis/facebook/join-group.js +44 -0
- package/dist/clis/facebook/memories.d.ts +1 -0
- package/dist/clis/facebook/memories.js +35 -0
- package/dist/clis/facebook/notifications.d.ts +1 -0
- package/dist/clis/facebook/notifications.js +36 -0
- package/dist/clis/facebook/profile.d.ts +1 -0
- package/dist/clis/facebook/profile.js +37 -0
- package/dist/clis/facebook/search.d.ts +1 -0
- package/dist/clis/facebook/search.js +38 -0
- package/dist/clis/facebook/search.test.d.ts +1 -1
- package/dist/clis/facebook/search.test.js +6 -9
- package/dist/clis/gitee/index.d.ts +3 -0
- package/dist/clis/gitee/index.js +3 -0
- package/dist/clis/gitee/search.d.ts +1 -0
- package/dist/clis/gitee/search.js +136 -0
- package/dist/clis/gitee/trending.d.ts +1 -0
- package/dist/clis/gitee/trending.js +567 -0
- package/dist/clis/gitee/user.d.ts +1 -0
- package/dist/clis/gitee/user.js +199 -0
- package/dist/clis/gitee/user.test.d.ts +1 -0
- package/dist/clis/gitee/user.test.js +63 -0
- package/dist/clis/hackernews/ask.d.ts +1 -0
- package/dist/clis/hackernews/ask.js +29 -0
- package/dist/clis/hackernews/best.d.ts +1 -0
- package/dist/clis/hackernews/best.js +29 -0
- package/dist/clis/hackernews/jobs.d.ts +1 -0
- package/dist/clis/hackernews/jobs.js +27 -0
- package/dist/clis/hackernews/new.d.ts +1 -0
- package/dist/clis/hackernews/new.js +29 -0
- package/dist/clis/hackernews/search.d.ts +1 -0
- package/dist/clis/hackernews/search.js +36 -0
- package/dist/clis/hackernews/show.d.ts +1 -0
- package/dist/clis/hackernews/show.js +29 -0
- package/dist/clis/hackernews/top.d.ts +1 -0
- package/dist/clis/hackernews/top.js +29 -0
- package/dist/clis/hackernews/user.d.ts +1 -0
- package/dist/clis/hackernews/user.js +22 -0
- package/dist/clis/hupu/hot.d.ts +1 -0
- package/dist/clis/hupu/hot.js +40 -0
- package/dist/clis/instagram/comment.d.ts +1 -0
- package/dist/clis/instagram/comment.js +47 -0
- package/dist/clis/instagram/explore.d.ts +1 -0
- package/dist/clis/instagram/explore.js +41 -0
- package/dist/clis/instagram/follow.d.ts +1 -0
- package/dist/clis/instagram/follow.js +43 -0
- package/dist/clis/instagram/followers.d.ts +1 -0
- package/dist/clis/instagram/followers.js +45 -0
- package/dist/clis/instagram/following.d.ts +1 -0
- package/dist/clis/instagram/following.js +45 -0
- package/dist/clis/instagram/like.d.ts +1 -0
- package/dist/clis/instagram/like.js +45 -0
- package/dist/clis/instagram/profile.d.ts +1 -0
- package/dist/clis/instagram/profile.js +39 -0
- package/dist/clis/instagram/save.d.ts +1 -0
- package/dist/clis/instagram/save.js +45 -0
- package/dist/clis/instagram/saved.d.ts +1 -0
- package/dist/clis/instagram/saved.js +38 -0
- package/dist/clis/instagram/search.d.ts +1 -0
- package/dist/clis/instagram/search.js +38 -0
- package/dist/clis/instagram/unfollow.d.ts +1 -0
- package/dist/clis/instagram/unfollow.js +40 -0
- package/dist/clis/instagram/unlike.d.ts +1 -0
- package/dist/clis/instagram/unlike.js +45 -0
- package/dist/clis/instagram/unsave.d.ts +1 -0
- package/dist/clis/instagram/unsave.js +45 -0
- package/dist/clis/instagram/user.d.ts +1 -0
- package/dist/clis/instagram/user.js +48 -0
- package/dist/clis/jd/add-cart.d.ts +1 -0
- package/dist/clis/jd/add-cart.js +71 -0
- package/dist/clis/jd/cart.d.ts +1 -0
- package/dist/clis/jd/cart.js +79 -0
- package/dist/clis/jd/commands.test.d.ts +5 -0
- package/dist/clis/jd/commands.test.js +64 -0
- package/dist/clis/jd/detail.d.ts +1 -0
- package/dist/clis/jd/detail.js +62 -0
- package/dist/clis/jd/reviews.d.ts +1 -0
- package/dist/clis/jd/reviews.js +54 -0
- package/dist/clis/jd/search.d.ts +1 -0
- package/dist/clis/jd/search.js +65 -0
- package/dist/clis/jianyu/search.d.ts +14 -0
- package/dist/clis/jianyu/search.js +135 -0
- package/dist/clis/jianyu/search.test.d.ts +1 -0
- package/dist/clis/jianyu/search.test.js +23 -0
- package/dist/clis/jike/post.d.ts +1 -0
- package/dist/clis/jike/post.js +61 -0
- package/dist/clis/jike/topic.d.ts +1 -0
- package/dist/clis/jike/topic.js +51 -0
- package/dist/clis/jike/user.d.ts +1 -0
- package/dist/clis/jike/user.js +50 -0
- package/dist/clis/jimeng/generate.d.ts +1 -0
- package/dist/clis/jimeng/generate.js +83 -0
- package/dist/clis/jimeng/history.d.ts +1 -0
- package/dist/clis/jimeng/history.js +47 -0
- package/dist/clis/jimeng/new.d.ts +1 -0
- package/dist/clis/jimeng/new.js +43 -0
- package/dist/clis/jimeng/workspaces.d.ts +1 -0
- package/dist/clis/jimeng/workspaces.js +41 -0
- package/dist/clis/linux-do/categories.d.ts +1 -0
- package/dist/clis/linux-do/categories.js +65 -0
- package/dist/clis/linux-do/search.d.ts +1 -0
- package/dist/clis/linux-do/search.js +41 -0
- package/dist/clis/linux-do/tags.d.ts +1 -0
- package/dist/clis/linux-do/tags.js +39 -0
- package/dist/clis/linux-do/topic-content.test.js +5 -5
- package/dist/clis/linux-do/topic.d.ts +1 -0
- package/dist/clis/linux-do/topic.js +56 -0
- package/dist/clis/linux-do/user-posts.d.ts +1 -0
- package/dist/clis/linux-do/user-posts.js +61 -0
- package/dist/clis/linux-do/user-topics.d.ts +1 -0
- package/dist/clis/linux-do/user-topics.js +48 -0
- package/dist/clis/lobsters/active.d.ts +1 -0
- package/dist/clis/lobsters/active.js +26 -0
- package/dist/clis/lobsters/hot.d.ts +1 -0
- package/dist/clis/lobsters/hot.js +26 -0
- package/dist/clis/lobsters/newest.d.ts +1 -0
- package/dist/clis/lobsters/newest.js +26 -0
- package/dist/clis/lobsters/tag.d.ts +1 -0
- package/dist/clis/lobsters/tag.js +32 -0
- package/dist/clis/pixiv/detail.d.ts +1 -0
- package/dist/clis/pixiv/detail.js +58 -0
- package/dist/clis/pixiv/ranking.d.ts +1 -0
- package/dist/clis/pixiv/ranking.js +59 -0
- package/dist/clis/pixiv/user.d.ts +1 -0
- package/dist/clis/pixiv/user.js +52 -0
- package/dist/clis/quark/ls.d.ts +1 -0
- package/dist/clis/quark/ls.js +63 -0
- package/dist/clis/quark/mkdir.d.ts +1 -0
- package/dist/clis/quark/mkdir.js +36 -0
- package/dist/clis/quark/mv.d.ts +1 -0
- package/dist/clis/quark/mv.js +53 -0
- package/dist/clis/quark/rename.d.ts +1 -0
- package/dist/clis/quark/rename.js +26 -0
- package/dist/clis/quark/rm.d.ts +1 -0
- package/dist/clis/quark/rm.js +24 -0
- package/dist/clis/quark/save.d.ts +1 -0
- package/dist/clis/quark/save.js +80 -0
- package/dist/clis/quark/share-tree.d.ts +1 -0
- package/dist/clis/quark/share-tree.js +45 -0
- package/dist/clis/quark/utils.d.ts +50 -0
- package/dist/clis/quark/utils.js +146 -0
- package/dist/clis/quark/utils.test.d.ts +1 -0
- package/dist/clis/quark/utils.test.js +58 -0
- package/dist/clis/reddit/frontpage.d.ts +1 -0
- package/dist/clis/reddit/frontpage.js +31 -0
- package/dist/clis/reddit/hot.d.ts +1 -0
- package/dist/clis/reddit/hot.js +45 -0
- package/dist/clis/reddit/popular.d.ts +1 -0
- package/dist/clis/reddit/popular.js +41 -0
- package/dist/clis/reddit/search.d.ts +1 -0
- package/dist/clis/reddit/search.js +65 -0
- package/dist/clis/reddit/subreddit.d.ts +1 -0
- package/dist/clis/reddit/subreddit.js +52 -0
- package/dist/clis/reddit/user-comments.d.ts +1 -0
- package/dist/clis/reddit/user-comments.js +44 -0
- package/dist/clis/reddit/user-posts.d.ts +1 -0
- package/dist/clis/reddit/user-posts.js +42 -0
- package/dist/clis/reddit/user.d.ts +1 -0
- package/dist/clis/reddit/user.js +37 -0
- package/dist/clis/stackoverflow/bounties.d.ts +1 -0
- package/dist/clis/stackoverflow/bounties.js +27 -0
- package/dist/clis/stackoverflow/hot.d.ts +1 -0
- package/dist/clis/stackoverflow/hot.js +24 -0
- package/dist/clis/stackoverflow/search.d.ts +1 -0
- package/dist/clis/stackoverflow/search.js +27 -0
- package/dist/clis/stackoverflow/unanswered.d.ts +1 -0
- package/dist/clis/stackoverflow/unanswered.js +26 -0
- package/dist/clis/steam/top-sellers.d.ts +1 -0
- package/dist/clis/steam/top-sellers.js +25 -0
- package/dist/clis/taobao/add-cart.d.ts +1 -0
- package/dist/clis/taobao/add-cart.js +149 -0
- package/dist/clis/taobao/cart.d.ts +1 -0
- package/dist/clis/taobao/cart.js +95 -0
- package/dist/clis/taobao/commands.test.d.ts +5 -0
- package/dist/clis/taobao/commands.test.js +64 -0
- package/dist/clis/taobao/detail.d.ts +1 -0
- package/dist/clis/taobao/detail.js +70 -0
- package/dist/clis/taobao/reviews.d.ts +1 -0
- package/dist/clis/taobao/reviews.js +76 -0
- package/dist/clis/taobao/search.d.ts +1 -0
- package/dist/clis/taobao/search.js +96 -0
- package/dist/clis/tiktok/comment.d.ts +1 -0
- package/dist/clis/tiktok/comment.js +57 -0
- package/dist/clis/tiktok/explore.d.ts +1 -0
- package/dist/clis/tiktok/explore.js +35 -0
- package/dist/clis/tiktok/follow.d.ts +1 -0
- package/dist/clis/tiktok/follow.js +39 -0
- package/dist/clis/tiktok/following.d.ts +1 -0
- package/dist/clis/tiktok/following.js +42 -0
- package/dist/clis/tiktok/friends.d.ts +1 -0
- package/dist/clis/tiktok/friends.js +43 -0
- package/dist/clis/tiktok/like.d.ts +1 -0
- package/dist/clis/tiktok/like.js +33 -0
- package/dist/clis/tiktok/live.d.ts +1 -0
- package/dist/clis/tiktok/live.js +47 -0
- package/dist/clis/tiktok/notifications.d.ts +1 -0
- package/dist/clis/tiktok/notifications.js +49 -0
- package/dist/clis/tiktok/profile.d.ts +1 -0
- package/dist/clis/tiktok/profile.js +54 -0
- package/dist/clis/tiktok/save.d.ts +1 -0
- package/dist/clis/tiktok/save.js +29 -0
- package/dist/clis/tiktok/search.d.ts +1 -0
- package/dist/clis/tiktok/search.js +39 -0
- package/dist/clis/tiktok/unfollow.d.ts +1 -0
- package/dist/clis/tiktok/unfollow.js +44 -0
- package/dist/clis/tiktok/unlike.d.ts +1 -0
- package/dist/clis/tiktok/unlike.js +33 -0
- package/dist/clis/tiktok/unsave.d.ts +1 -0
- package/dist/clis/tiktok/unsave.js +31 -0
- package/dist/clis/tiktok/user.d.ts +1 -0
- package/dist/clis/tiktok/user.js +41 -0
- package/dist/clis/twitter/reply.js +3 -8
- package/dist/clis/twitter/reply.test.js +5 -5
- package/dist/clis/v2ex/hot.d.ts +1 -0
- package/dist/clis/v2ex/hot.js +25 -0
- package/dist/clis/v2ex/latest.d.ts +1 -0
- package/dist/clis/v2ex/latest.js +25 -0
- package/dist/clis/v2ex/member.d.ts +1 -0
- package/dist/clis/v2ex/member.js +27 -0
- package/dist/clis/v2ex/node.d.ts +1 -0
- package/dist/clis/v2ex/node.js +38 -0
- package/dist/clis/v2ex/nodes.d.ts +1 -0
- package/dist/clis/v2ex/nodes.js +25 -0
- package/dist/clis/v2ex/replies.d.ts +1 -0
- package/dist/clis/v2ex/replies.js +26 -0
- package/dist/clis/v2ex/topic.d.ts +1 -0
- package/dist/clis/v2ex/topic.js +30 -0
- package/dist/clis/v2ex/user.d.ts +1 -0
- package/dist/clis/v2ex/user.js +33 -0
- package/dist/clis/xiaoe/catalog.d.ts +1 -0
- package/dist/clis/xiaoe/catalog.js +125 -0
- package/dist/clis/xiaoe/content.d.ts +1 -0
- package/dist/clis/xiaoe/content.js +39 -0
- package/dist/clis/xiaoe/courses.d.ts +1 -0
- package/dist/clis/xiaoe/courses.js +69 -0
- package/dist/clis/xiaoe/detail.d.ts +1 -0
- package/dist/clis/xiaoe/detail.js +35 -0
- package/dist/clis/xiaoe/play-url.d.ts +1 -0
- package/dist/clis/xiaoe/play-url.js +120 -0
- package/dist/clis/xiaohongshu/feed.d.ts +1 -0
- package/dist/clis/xiaohongshu/feed.js +32 -0
- package/dist/clis/xiaohongshu/note.js +8 -3
- package/dist/clis/xiaohongshu/note.test.js +11 -0
- package/dist/clis/xiaohongshu/notifications.d.ts +1 -0
- package/dist/clis/xiaohongshu/notifications.js +38 -0
- package/dist/clis/xueqiu/earnings-date.d.ts +1 -0
- package/dist/clis/xueqiu/earnings-date.js +61 -0
- package/dist/clis/xueqiu/feed.d.ts +1 -0
- package/dist/clis/xueqiu/feed.js +48 -0
- package/dist/clis/xueqiu/groups.d.ts +1 -0
- package/dist/clis/xueqiu/groups.js +25 -0
- package/dist/clis/xueqiu/hot-stock.d.ts +1 -0
- package/dist/clis/xueqiu/hot-stock.js +44 -0
- package/dist/clis/xueqiu/hot.d.ts +1 -0
- package/dist/clis/xueqiu/hot.js +44 -0
- package/dist/clis/xueqiu/kline.d.ts +1 -0
- package/dist/clis/xueqiu/kline.js +64 -0
- package/dist/clis/xueqiu/search.d.ts +1 -0
- package/dist/clis/xueqiu/search.js +49 -0
- package/dist/clis/xueqiu/stock.d.ts +1 -0
- package/dist/clis/xueqiu/stock.js +72 -0
- package/dist/clis/xueqiu/watchlist.d.ts +1 -0
- package/dist/clis/xueqiu/watchlist.js +45 -0
- package/dist/clis/zhihu/answer.d.ts +1 -0
- package/dist/clis/zhihu/answer.js +194 -0
- package/dist/clis/zhihu/answer.test.d.ts +1 -0
- package/dist/clis/zhihu/answer.test.js +81 -0
- package/dist/clis/zhihu/comment.d.ts +1 -0
- package/dist/clis/zhihu/comment.js +335 -0
- package/dist/clis/zhihu/comment.test.d.ts +1 -0
- package/dist/clis/zhihu/comment.test.js +54 -0
- package/dist/clis/zhihu/favorite.d.ts +1 -0
- package/dist/clis/zhihu/favorite.js +224 -0
- package/dist/clis/zhihu/favorite.test.d.ts +1 -0
- package/dist/clis/zhihu/favorite.test.js +196 -0
- package/dist/clis/zhihu/follow.d.ts +1 -0
- package/dist/clis/zhihu/follow.js +80 -0
- package/dist/clis/zhihu/follow.test.d.ts +1 -0
- package/dist/clis/zhihu/follow.test.js +45 -0
- package/dist/clis/zhihu/hot.d.ts +1 -0
- package/dist/clis/zhihu/hot.js +43 -0
- package/dist/clis/zhihu/like.d.ts +1 -0
- package/dist/clis/zhihu/like.js +91 -0
- package/dist/clis/zhihu/like.test.d.ts +1 -0
- package/dist/clis/zhihu/like.test.js +64 -0
- package/dist/clis/zhihu/search.d.ts +1 -0
- package/dist/clis/zhihu/search.js +52 -0
- package/dist/clis/zhihu/target.d.ts +24 -0
- package/dist/clis/zhihu/target.js +91 -0
- package/dist/clis/zhihu/target.test.d.ts +1 -0
- package/dist/clis/zhihu/target.test.js +77 -0
- package/dist/clis/zhihu/write-shared.d.ts +32 -0
- package/dist/clis/zhihu/write-shared.js +221 -0
- package/dist/clis/zhihu/write-shared.test.d.ts +1 -0
- package/dist/clis/zhihu/write-shared.test.js +175 -0
- package/dist/src/browser/bridge.d.ts +2 -0
- package/dist/src/browser/bridge.js +30 -24
- package/dist/src/browser/daemon-client.d.ts +30 -10
- package/dist/src/browser/daemon-client.js +42 -27
- package/dist/src/browser/daemon-client.test.js +32 -25
- package/dist/src/browser/dom-helpers.test.js +3 -2
- package/dist/src/browser/errors.d.ts +26 -1
- package/dist/src/browser/errors.js +40 -7
- package/dist/src/browser/errors.test.d.ts +1 -0
- package/dist/src/browser/errors.test.js +51 -0
- package/dist/src/browser/index.d.ts +2 -1
- package/dist/src/browser/index.js +1 -1
- package/dist/src/browser/page.d.ts +9 -8
- package/dist/src/browser/page.js +33 -31
- package/dist/src/browser.test.js +27 -8
- package/dist/src/build-manifest.d.ts +5 -11
- package/dist/src/build-manifest.js +6 -75
- package/dist/src/build-manifest.test.js +1 -39
- package/dist/src/cascade.js +3 -2
- package/dist/src/cli.d.ts +3 -3
- package/dist/src/cli.js +73 -65
- package/dist/src/cli.test.js +20 -15
- package/dist/src/clis/binance/asks.d.ts +1 -0
- package/dist/src/clis/binance/asks.js +20 -0
- package/dist/src/clis/binance/commands.test.d.ts +3 -0
- package/dist/src/clis/binance/commands.test.js +58 -0
- package/dist/src/clis/binance/depth.d.ts +1 -0
- package/dist/src/clis/binance/depth.js +20 -0
- package/dist/src/clis/binance/gainers.d.ts +1 -0
- package/dist/src/clis/binance/gainers.js +21 -0
- package/dist/src/clis/binance/klines.d.ts +1 -0
- package/dist/src/clis/binance/klines.js +20 -0
- package/dist/src/clis/binance/losers.d.ts +1 -0
- package/dist/src/clis/binance/losers.js +21 -0
- package/dist/src/clis/binance/pairs.d.ts +1 -0
- package/dist/src/clis/binance/pairs.js +20 -0
- package/dist/src/clis/binance/price.d.ts +1 -0
- package/dist/src/clis/binance/price.js +17 -0
- package/dist/src/clis/binance/prices.d.ts +1 -0
- package/dist/src/clis/binance/prices.js +18 -0
- package/dist/src/clis/binance/ticker.d.ts +1 -0
- package/dist/src/clis/binance/ticker.js +20 -0
- package/dist/src/clis/binance/top.d.ts +1 -0
- package/dist/src/clis/binance/top.js +20 -0
- package/dist/src/clis/binance/trades.d.ts +1 -0
- package/dist/src/clis/binance/trades.js +19 -0
- package/dist/src/commanderAdapter.js +19 -6
- package/dist/src/completion-fast.d.ts +25 -0
- package/dist/src/completion-fast.js +140 -0
- package/dist/src/completion.d.ts +1 -0
- package/dist/src/completion.js +1 -0
- package/dist/src/diagnostic.d.ts +1 -0
- package/dist/src/diagnostic.js +64 -2
- package/dist/src/diagnostic.test.js +93 -3
- package/dist/src/discovery.d.ts +3 -3
- package/dist/src/discovery.js +34 -97
- package/dist/src/doctor.d.ts +2 -0
- package/dist/src/doctor.js +59 -31
- package/dist/src/doctor.test.js +89 -16
- package/dist/src/download/index.d.ts +1 -1
- package/dist/src/engine.test.js +4 -19
- package/dist/src/execution.js +1 -13
- package/dist/src/explore.js +1 -1
- package/dist/src/generate-verified.d.ts +105 -0
- package/dist/src/generate-verified.js +696 -0
- package/dist/src/generate-verified.test.d.ts +1 -0
- package/dist/src/generate-verified.test.js +925 -0
- package/dist/src/generate.d.ts +11 -6
- package/dist/src/generate.js +4 -7
- package/dist/src/main.js +65 -12
- package/dist/src/pipeline/steps/download.d.ts +1 -17
- package/dist/src/pipeline/steps/download.js +20 -31
- package/dist/src/pipeline/steps/intercept.d.ts +1 -1
- package/dist/src/pipeline/steps/intercept.js +1 -1
- package/dist/src/pipeline/steps/tap.d.ts +1 -1
- package/dist/src/pipeline/steps/tap.js +1 -1
- package/dist/src/plugin-scaffold.d.ts +2 -2
- package/dist/src/plugin-scaffold.js +24 -21
- package/dist/src/plugin-scaffold.test.js +1 -1
- package/dist/src/plugin.d.ts +3 -2
- package/dist/src/plugin.js +29 -14
- package/dist/src/plugin.test.js +47 -32
- package/dist/src/record.js +26 -25
- package/dist/src/runtime-detect.js +3 -7
- package/dist/src/scripts/framework.d.ts +3 -0
- package/dist/src/scripts/framework.js +8 -4
- package/dist/src/scripts/store.d.ts +5 -1
- package/dist/src/scripts/store.js +5 -1
- package/dist/src/skill-generate.d.ts +30 -0
- package/dist/src/skill-generate.js +75 -0
- package/dist/src/skill-generate.test.d.ts +1 -0
- package/dist/src/skill-generate.test.js +173 -0
- package/dist/src/synthesize.d.ts +1 -1
- package/dist/src/synthesize.js +7 -8
- package/dist/src/types.d.ts +3 -1
- package/package.json +5 -5
- package/dist/clis/bilibili/hot.yaml +0 -38
- package/dist/clis/bluesky/feeds.yaml +0 -29
- package/dist/clis/bluesky/followers.yaml +0 -33
- package/dist/clis/bluesky/following.yaml +0 -33
- package/dist/clis/bluesky/profile.yaml +0 -27
- package/dist/clis/bluesky/search.yaml +0 -34
- package/dist/clis/bluesky/starter-packs.yaml +0 -34
- package/dist/clis/bluesky/thread.yaml +0 -32
- package/dist/clis/bluesky/trending.yaml +0 -27
- package/dist/clis/bluesky/user.yaml +0 -34
- package/dist/clis/devto/tag.yaml +0 -34
- package/dist/clis/devto/top.yaml +0 -29
- package/dist/clis/devto/user.yaml +0 -33
- package/dist/clis/dictionary/examples.yaml +0 -25
- package/dist/clis/dictionary/search.yaml +0 -27
- package/dist/clis/dictionary/synonyms.yaml +0 -25
- package/dist/clis/douban/subject.yaml +0 -107
- package/dist/clis/douban/top250.yaml +0 -70
- package/dist/clis/facebook/add-friend.yaml +0 -43
- package/dist/clis/facebook/events.yaml +0 -44
- package/dist/clis/facebook/feed.yaml +0 -63
- package/dist/clis/facebook/friends.yaml +0 -42
- package/dist/clis/facebook/groups.yaml +0 -50
- package/dist/clis/facebook/join-group.yaml +0 -44
- package/dist/clis/facebook/memories.yaml +0 -39
- package/dist/clis/facebook/notifications.yaml +0 -40
- package/dist/clis/facebook/profile.yaml +0 -37
- package/dist/clis/facebook/search.yaml +0 -47
- package/dist/clis/hackernews/ask.yaml +0 -38
- package/dist/clis/hackernews/best.yaml +0 -38
- package/dist/clis/hackernews/jobs.yaml +0 -36
- package/dist/clis/hackernews/new.yaml +0 -38
- package/dist/clis/hackernews/search.yaml +0 -44
- package/dist/clis/hackernews/show.yaml +0 -38
- package/dist/clis/hackernews/top.yaml +0 -38
- package/dist/clis/hackernews/user.yaml +0 -25
- package/dist/clis/hupu/hot.yaml +0 -43
- package/dist/clis/instagram/comment.yaml +0 -52
- package/dist/clis/instagram/explore.yaml +0 -43
- package/dist/clis/instagram/follow.yaml +0 -41
- package/dist/clis/instagram/followers.yaml +0 -51
- package/dist/clis/instagram/following.yaml +0 -51
- package/dist/clis/instagram/like.yaml +0 -46
- package/dist/clis/instagram/profile.yaml +0 -42
- package/dist/clis/instagram/save.yaml +0 -46
- package/dist/clis/instagram/saved.yaml +0 -40
- package/dist/clis/instagram/search.yaml +0 -44
- package/dist/clis/instagram/unfollow.yaml +0 -38
- package/dist/clis/instagram/unlike.yaml +0 -46
- package/dist/clis/instagram/unsave.yaml +0 -46
- package/dist/clis/instagram/user.yaml +0 -54
- package/dist/clis/jike/post.yaml +0 -59
- package/dist/clis/jike/topic.yaml +0 -53
- package/dist/clis/jike/user.yaml +0 -52
- package/dist/clis/jimeng/generate.yaml +0 -85
- package/dist/clis/jimeng/history.yaml +0 -46
- package/dist/clis/linux-do/categories.yaml +0 -70
- package/dist/clis/linux-do/search.yaml +0 -48
- package/dist/clis/linux-do/tags.yaml +0 -41
- package/dist/clis/linux-do/topic.yaml +0 -62
- package/dist/clis/linux-do/user-posts.yaml +0 -67
- package/dist/clis/linux-do/user-topics.yaml +0 -54
- package/dist/clis/lobsters/active.yaml +0 -29
- package/dist/clis/lobsters/hot.yaml +0 -29
- package/dist/clis/lobsters/newest.yaml +0 -29
- package/dist/clis/lobsters/tag.yaml +0 -34
- package/dist/clis/pixiv/detail.yaml +0 -49
- package/dist/clis/pixiv/ranking.yaml +0 -53
- package/dist/clis/pixiv/user.yaml +0 -46
- package/dist/clis/reddit/frontpage.yaml +0 -30
- package/dist/clis/reddit/hot.yaml +0 -47
- package/dist/clis/reddit/popular.yaml +0 -40
- package/dist/clis/reddit/search.yaml +0 -61
- package/dist/clis/reddit/subreddit.yaml +0 -50
- package/dist/clis/reddit/user-comments.yaml +0 -46
- package/dist/clis/reddit/user-posts.yaml +0 -44
- package/dist/clis/reddit/user.yaml +0 -40
- package/dist/clis/stackoverflow/bounties.yaml +0 -29
- package/dist/clis/stackoverflow/hot.yaml +0 -28
- package/dist/clis/stackoverflow/search.yaml +0 -33
- package/dist/clis/stackoverflow/unanswered.yaml +0 -28
- package/dist/clis/steam/top-sellers.yaml +0 -29
- package/dist/clis/tiktok/comment.yaml +0 -66
- package/dist/clis/tiktok/explore.yaml +0 -39
- package/dist/clis/tiktok/follow.yaml +0 -39
- package/dist/clis/tiktok/following.yaml +0 -46
- package/dist/clis/tiktok/friends.yaml +0 -47
- package/dist/clis/tiktok/like.yaml +0 -38
- package/dist/clis/tiktok/live.yaml +0 -51
- package/dist/clis/tiktok/notifications.yaml +0 -52
- package/dist/clis/tiktok/profile.yaml +0 -45
- package/dist/clis/tiktok/save.yaml +0 -34
- package/dist/clis/tiktok/search.yaml +0 -47
- package/dist/clis/tiktok/unfollow.yaml +0 -44
- package/dist/clis/tiktok/unlike.yaml +0 -38
- package/dist/clis/tiktok/unsave.yaml +0 -36
- package/dist/clis/tiktok/user.yaml +0 -44
- package/dist/clis/v2ex/hot.yaml +0 -28
- package/dist/clis/v2ex/latest.yaml +0 -28
- package/dist/clis/v2ex/member.yaml +0 -29
- package/dist/clis/v2ex/node.yaml +0 -34
- package/dist/clis/v2ex/nodes.yaml +0 -31
- package/dist/clis/v2ex/replies.yaml +0 -32
- package/dist/clis/v2ex/topic.yaml +0 -33
- package/dist/clis/v2ex/user.yaml +0 -34
- package/dist/clis/xiaoe/catalog.yaml +0 -129
- package/dist/clis/xiaoe/content.yaml +0 -43
- package/dist/clis/xiaoe/courses.yaml +0 -73
- package/dist/clis/xiaoe/detail.yaml +0 -39
- package/dist/clis/xiaoe/play-url.yaml +0 -124
- package/dist/clis/xiaohongshu/feed.yaml +0 -31
- package/dist/clis/xiaohongshu/notifications.yaml +0 -37
- package/dist/clis/xueqiu/earnings-date.yaml +0 -69
- package/dist/clis/xueqiu/feed.yaml +0 -53
- package/dist/clis/xueqiu/groups.yaml +0 -23
- package/dist/clis/xueqiu/hot-stock.yaml +0 -49
- package/dist/clis/xueqiu/hot.yaml +0 -46
- package/dist/clis/xueqiu/kline.yaml +0 -65
- package/dist/clis/xueqiu/search.yaml +0 -55
- package/dist/clis/xueqiu/stock.yaml +0 -69
- package/dist/clis/xueqiu/watchlist.yaml +0 -46
- package/dist/clis/zhihu/hot.yaml +0 -46
- package/dist/clis/zhihu/search.yaml +0 -59
- package/dist/src/browser/discover.d.ts +0 -15
- package/dist/src/browser/discover.js +0 -19
- package/dist/src/yaml-schema.d.ts +0 -29
- package/dist/src/yaml-schema.js +0 -22
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AuthRequiredError } from '@jackwener/opencli/errors';
|
|
2
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
3
|
+
import { clampInt, normalizeNumericId } from '../_shared/common.js';
|
|
4
|
+
cli({
|
|
5
|
+
site: 'jd',
|
|
6
|
+
name: 'add-cart',
|
|
7
|
+
description: '京东加入购物车',
|
|
8
|
+
domain: 'item.jd.com',
|
|
9
|
+
strategy: Strategy.COOKIE,
|
|
10
|
+
args: [
|
|
11
|
+
{ name: 'sku', positional: true, required: true, help: '商品 SKU ID' },
|
|
12
|
+
{ name: 'num', type: 'int', default: 1, help: '数量' },
|
|
13
|
+
{ name: 'dry-run', type: 'bool', default: false, help: '仅预览,不实际加入购物车' },
|
|
14
|
+
],
|
|
15
|
+
columns: ['status', 'title', 'price', 'sku'],
|
|
16
|
+
navigateBefore: false,
|
|
17
|
+
func: async (page, kwargs) => {
|
|
18
|
+
const sku = normalizeNumericId(kwargs.sku, 'sku', '100291143898');
|
|
19
|
+
const num = clampInt(kwargs.num, 1, 1, 99);
|
|
20
|
+
const dryRun = !!kwargs['dry-run'];
|
|
21
|
+
await page.goto(`https://item.jd.com/${sku}.html`);
|
|
22
|
+
await page.wait(4);
|
|
23
|
+
const info = await page.evaluate(`
|
|
24
|
+
(() => {
|
|
25
|
+
const text = document.body?.innerText || '';
|
|
26
|
+
const titleMatch = document.title.match(/^【[^】]*】(.+?)【/);
|
|
27
|
+
const title = titleMatch ? titleMatch[1].trim() : document.title.split('-')[0].trim();
|
|
28
|
+
const priceMatch = text.match(/¥([\\d,.]+)/);
|
|
29
|
+
const price = priceMatch ? '¥' + priceMatch[1] : '';
|
|
30
|
+
return { title, price };
|
|
31
|
+
})()
|
|
32
|
+
`);
|
|
33
|
+
if (dryRun) {
|
|
34
|
+
return [{
|
|
35
|
+
status: 'dry-run',
|
|
36
|
+
title: (info?.title || '').slice(0, 80),
|
|
37
|
+
price: info?.price || '',
|
|
38
|
+
sku,
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
41
|
+
await page.goto(`https://cart.jd.com/gate.action?pid=${sku}&pcount=${num}&ptype=1`);
|
|
42
|
+
await page.wait(4);
|
|
43
|
+
const result = await page.evaluate(`
|
|
44
|
+
(() => {
|
|
45
|
+
const url = location.href;
|
|
46
|
+
const text = document.body?.innerText || '';
|
|
47
|
+
if (text.includes('已成功加入') || text.includes('商品已成功') || url.includes('addtocart')) {
|
|
48
|
+
return 'success';
|
|
49
|
+
}
|
|
50
|
+
if (text.includes('请登录') || text.includes('login') || url.includes('login')) {
|
|
51
|
+
return 'login_required';
|
|
52
|
+
}
|
|
53
|
+
return 'page:' + url.substring(0, 60) + ' | ' + text.substring(0, 100);
|
|
54
|
+
})()
|
|
55
|
+
`);
|
|
56
|
+
if (result === 'login_required') {
|
|
57
|
+
throw new AuthRequiredError('jd add-cart requires a logged-in JD session');
|
|
58
|
+
}
|
|
59
|
+
let status = '? 未知';
|
|
60
|
+
if (result === 'success')
|
|
61
|
+
status = '✓ 已加入购物车';
|
|
62
|
+
else
|
|
63
|
+
status = '? ' + result;
|
|
64
|
+
return [{
|
|
65
|
+
status,
|
|
66
|
+
title: (info?.title || '').slice(0, 80),
|
|
67
|
+
price: info?.price || '',
|
|
68
|
+
sku,
|
|
69
|
+
}];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AuthRequiredError } from '@jackwener/opencli/errors';
|
|
2
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
3
|
+
cli({
|
|
4
|
+
site: 'jd',
|
|
5
|
+
name: 'cart',
|
|
6
|
+
description: '查看京东购物车',
|
|
7
|
+
domain: 'cart.jd.com',
|
|
8
|
+
strategy: Strategy.COOKIE,
|
|
9
|
+
args: [],
|
|
10
|
+
columns: ['index', 'title', 'price', 'quantity', 'sku'],
|
|
11
|
+
navigateBefore: false,
|
|
12
|
+
func: async (page) => {
|
|
13
|
+
await page.goto('https://cart.jd.com/cart_index');
|
|
14
|
+
await page.wait(5);
|
|
15
|
+
const data = await page.evaluate(`
|
|
16
|
+
(async () => {
|
|
17
|
+
const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
|
|
18
|
+
for (let i = 0; i < 20; i++) {
|
|
19
|
+
if (document.body?.innerText?.length > 500) break;
|
|
20
|
+
await new Promise(r => setTimeout(r, 500));
|
|
21
|
+
}
|
|
22
|
+
const text = document.body?.innerText || '';
|
|
23
|
+
const url = location.href;
|
|
24
|
+
if (text.includes('请登录') || url.includes('passport.jd.com')) {
|
|
25
|
+
return { error: 'auth-required' };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const resp = await fetch('https://api.m.jd.com/api?appid=JDC_mall_cart&functionId=pcCart_jc_getCurrentCart&body=%7B%22serInfo%22%3A%7B%22area%22%3A%2222_1930_50948_52157%22%7D%7D', {
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
headers: { referer: 'https://cart.jd.com/' },
|
|
32
|
+
});
|
|
33
|
+
const json = await resp.json();
|
|
34
|
+
const cartData = json?.resultData?.cartInfo?.vendors || [];
|
|
35
|
+
const items = [];
|
|
36
|
+
for (const vendor of cartData) {
|
|
37
|
+
const sorted = vendor.sorted || [];
|
|
38
|
+
for (const item of sorted) {
|
|
39
|
+
const product = item.item || item;
|
|
40
|
+
if (!product.Id && !product.skuId) continue;
|
|
41
|
+
items.push({
|
|
42
|
+
index: items.length + 1,
|
|
43
|
+
title: normalize(product.name || product.Name || '').slice(0, 80),
|
|
44
|
+
price: product.price ? '¥' + product.price : '',
|
|
45
|
+
quantity: String(product.num || product.Num || 1),
|
|
46
|
+
sku: String(product.Id || product.skuId || ''),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (items.length > 0) return { items };
|
|
51
|
+
} catch {}
|
|
52
|
+
|
|
53
|
+
const lines = text.split('\\n').map(l => l.trim()).filter(Boolean);
|
|
54
|
+
const items = [];
|
|
55
|
+
for (let i = 0; i < lines.length; i++) {
|
|
56
|
+
const line = lines[i];
|
|
57
|
+
const priceMatch = line.match(/¥([\\d,.]+)/);
|
|
58
|
+
if (priceMatch && i > 0) {
|
|
59
|
+
const title = lines[i - 1];
|
|
60
|
+
if (title && title.length > 5 && title.length < 200 && !title.startsWith('¥')) {
|
|
61
|
+
items.push({
|
|
62
|
+
index: items.length + 1,
|
|
63
|
+
title: title.slice(0, 80),
|
|
64
|
+
price: '¥' + priceMatch[1],
|
|
65
|
+
quantity: '',
|
|
66
|
+
sku: '',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { items };
|
|
72
|
+
})()
|
|
73
|
+
`);
|
|
74
|
+
if (data?.error === 'auth-required') {
|
|
75
|
+
throw new AuthRequiredError('jd cart requires a logged-in JD session');
|
|
76
|
+
}
|
|
77
|
+
return Array.isArray(data?.items) ? data.items : [];
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { getRegistry } from '@jackwener/opencli/registry';
|
|
3
|
+
import './search.js';
|
|
4
|
+
import './detail.js';
|
|
5
|
+
import './reviews.js';
|
|
6
|
+
import './cart.js';
|
|
7
|
+
import './add-cart.js';
|
|
8
|
+
function createPageMock() {
|
|
9
|
+
return {
|
|
10
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
11
|
+
evaluate: vi.fn().mockResolvedValue({ title: 'Demo', price: '¥99' }),
|
|
12
|
+
snapshot: vi.fn().mockResolvedValue(undefined),
|
|
13
|
+
click: vi.fn().mockResolvedValue(undefined),
|
|
14
|
+
typeText: vi.fn().mockResolvedValue(undefined),
|
|
15
|
+
pressKey: vi.fn().mockResolvedValue(undefined),
|
|
16
|
+
scrollTo: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
getFormState: vi.fn().mockResolvedValue({ forms: [], orphanFields: [] }),
|
|
18
|
+
wait: vi.fn().mockResolvedValue(undefined),
|
|
19
|
+
tabs: vi.fn().mockResolvedValue([]),
|
|
20
|
+
selectTab: vi.fn().mockResolvedValue(undefined),
|
|
21
|
+
networkRequests: vi.fn().mockResolvedValue([]),
|
|
22
|
+
consoleMessages: vi.fn().mockResolvedValue([]),
|
|
23
|
+
scroll: vi.fn().mockResolvedValue(undefined),
|
|
24
|
+
autoScroll: vi.fn().mockResolvedValue(undefined),
|
|
25
|
+
installInterceptor: vi.fn().mockResolvedValue(undefined),
|
|
26
|
+
getInterceptedRequests: vi.fn().mockResolvedValue([]),
|
|
27
|
+
getCookies: vi.fn().mockResolvedValue([]),
|
|
28
|
+
screenshot: vi.fn().mockResolvedValue(''),
|
|
29
|
+
waitForCapture: vi.fn().mockResolvedValue(undefined),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
describe('jd command registration', () => {
|
|
33
|
+
it('registers all jd shopping commands', () => {
|
|
34
|
+
for (const name of ['search', 'detail', 'reviews', 'cart', 'add-cart']) {
|
|
35
|
+
expect(getRegistry().get(`jd/${name}`)).toBeDefined();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('jd command safety', () => {
|
|
40
|
+
it('rejects invalid numeric sku before evaluating page scripts', async () => {
|
|
41
|
+
const page = createPageMock();
|
|
42
|
+
const detail = getRegistry().get('jd/detail');
|
|
43
|
+
await expect(detail.func(page, { sku: 'abc' })).rejects.toMatchObject({
|
|
44
|
+
name: 'ArgumentError',
|
|
45
|
+
code: 'ARGUMENT',
|
|
46
|
+
});
|
|
47
|
+
expect(page.goto).not.toHaveBeenCalled();
|
|
48
|
+
expect(page.evaluate).not.toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
it('supports dry-run for add-cart without mutating the cart', async () => {
|
|
51
|
+
const page = createPageMock();
|
|
52
|
+
const addCart = getRegistry().get('jd/add-cart');
|
|
53
|
+
const result = await addCart.func(page, { sku: '100291143898', 'dry-run': true });
|
|
54
|
+
expect(result).toEqual([
|
|
55
|
+
expect.objectContaining({
|
|
56
|
+
status: 'dry-run',
|
|
57
|
+
sku: '100291143898',
|
|
58
|
+
}),
|
|
59
|
+
]);
|
|
60
|
+
expect(page.goto).toHaveBeenCalledTimes(1);
|
|
61
|
+
expect(page.goto).toHaveBeenCalledWith('https://item.jd.com/100291143898.html');
|
|
62
|
+
expect(page.evaluate).toHaveBeenCalledTimes(1);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
import { normalizeNumericId } from '../_shared/common.js';
|
|
3
|
+
cli({
|
|
4
|
+
site: 'jd',
|
|
5
|
+
name: 'detail',
|
|
6
|
+
description: '京东商品详情',
|
|
7
|
+
domain: 'item.jd.com',
|
|
8
|
+
strategy: Strategy.COOKIE,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'sku', positional: true, required: true, help: '商品 SKU ID' },
|
|
11
|
+
],
|
|
12
|
+
columns: ['field', 'value'],
|
|
13
|
+
navigateBefore: false,
|
|
14
|
+
func: async (page, kwargs) => {
|
|
15
|
+
const sku = normalizeNumericId(kwargs.sku, 'sku', '100291143898');
|
|
16
|
+
await page.goto(`https://item.jd.com/${sku}.html`);
|
|
17
|
+
await page.wait(5);
|
|
18
|
+
const data = await page.evaluate(`
|
|
19
|
+
(() => {
|
|
20
|
+
const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
|
|
21
|
+
const text = document.body?.innerText || '';
|
|
22
|
+
|
|
23
|
+
const titleMatch = document.title.match(/^【[^】]*】(.+?)【/);
|
|
24
|
+
const title = titleMatch ? titleMatch[1].trim() : normalize(document.title.split('【')[0]);
|
|
25
|
+
|
|
26
|
+
const priceMatch = text.match(/¥([\\d,.]+)/);
|
|
27
|
+
const price = priceMatch ? '¥' + priceMatch[1] : '';
|
|
28
|
+
|
|
29
|
+
const ratingMatch = text.match(/(超\\d+%[^\\n]{2,20})/);
|
|
30
|
+
const rating = ratingMatch ? ratingMatch[1] : '';
|
|
31
|
+
|
|
32
|
+
const reviewMatch = text.match(/买家评价\\(([\\d万+]+)\\)/);
|
|
33
|
+
const reviews = reviewMatch ? reviewMatch[1] : '';
|
|
34
|
+
|
|
35
|
+
const shopMatch = text.match(/(\\S{2,15}(?:京东自营旗舰店|旗舰店|专卖店|自营店))/);
|
|
36
|
+
const shop = shopMatch ? shopMatch[1] : '';
|
|
37
|
+
|
|
38
|
+
const tagPattern = /([\u4e00-\u9fa5]{2,8})\\s+(\\d+)/g;
|
|
39
|
+
const tags = [];
|
|
40
|
+
let m;
|
|
41
|
+
const tagStart = text.indexOf('买家评价');
|
|
42
|
+
const tagSection = tagStart >= 0 ? text.substring(tagStart, tagStart + 500) : '';
|
|
43
|
+
while ((m = tagPattern.exec(tagSection)) && tags.length < 6) {
|
|
44
|
+
if (parseInt(m[2], 10) > 1) tags.push(m[1] + '(' + m[2] + ')');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const results = [
|
|
48
|
+
{ field: '商品名称', value: title },
|
|
49
|
+
{ field: '价格', value: price },
|
|
50
|
+
{ field: 'SKU', value: ${JSON.stringify(sku)} },
|
|
51
|
+
{ field: '店铺', value: shop },
|
|
52
|
+
{ field: '评价数量', value: reviews },
|
|
53
|
+
{ field: '好评率', value: rating },
|
|
54
|
+
{ field: '评价标签', value: tags.join(' | ') },
|
|
55
|
+
{ field: '链接', value: location.href },
|
|
56
|
+
];
|
|
57
|
+
return results.filter(r => r.value);
|
|
58
|
+
})()
|
|
59
|
+
`);
|
|
60
|
+
return Array.isArray(data) ? data : [];
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
import { clampInt, normalizeNumericId } from '../_shared/common.js';
|
|
3
|
+
cli({
|
|
4
|
+
site: 'jd',
|
|
5
|
+
name: 'reviews',
|
|
6
|
+
description: '京东商品评价',
|
|
7
|
+
domain: 'item.jd.com',
|
|
8
|
+
strategy: Strategy.COOKIE,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'sku', positional: true, required: true, help: '商品 SKU ID' },
|
|
11
|
+
{ name: 'limit', type: 'int', default: 10, help: '返回评价数量 (max 20)' },
|
|
12
|
+
],
|
|
13
|
+
columns: ['rank', 'user', 'content', 'date'],
|
|
14
|
+
navigateBefore: false,
|
|
15
|
+
func: async (page, kwargs) => {
|
|
16
|
+
const sku = normalizeNumericId(kwargs.sku, 'sku', '100291143898');
|
|
17
|
+
const limit = clampInt(kwargs.limit, 10, 1, 20);
|
|
18
|
+
await page.goto(`https://item.jd.com/${sku}.html`);
|
|
19
|
+
await page.wait(5);
|
|
20
|
+
await page.autoScroll({ times: 2, delayMs: 1500 });
|
|
21
|
+
const data = await page.evaluate(`
|
|
22
|
+
(async () => {
|
|
23
|
+
const text = document.body?.innerText || '';
|
|
24
|
+
const reviewStart = text.indexOf('买家评价');
|
|
25
|
+
const reviewEnd = text.indexOf('全部评价');
|
|
26
|
+
if (reviewStart < 0) return [];
|
|
27
|
+
|
|
28
|
+
const reviewSection = text.substring(reviewStart, reviewEnd > reviewStart ? reviewEnd : reviewStart + 3000);
|
|
29
|
+
const lines = reviewSection.split('\\n').map(l => l.trim()).filter(Boolean);
|
|
30
|
+
|
|
31
|
+
const results = [];
|
|
32
|
+
const userPattern = /^[a-zA-Z0-9*_]{3,15}$/;
|
|
33
|
+
for (let i = 0; i < lines.length; i++) {
|
|
34
|
+
const line = lines[i];
|
|
35
|
+
if (userPattern.test(line) && line.includes('*') && i + 1 < lines.length) {
|
|
36
|
+
const user = line;
|
|
37
|
+
const content = lines[i + 1];
|
|
38
|
+
if (content.length < 5 || content.match(/^(全部评价|问大家|查看更多)/)) continue;
|
|
39
|
+
results.push({
|
|
40
|
+
rank: results.length + 1,
|
|
41
|
+
user,
|
|
42
|
+
content: content.slice(0, 150),
|
|
43
|
+
date: '',
|
|
44
|
+
});
|
|
45
|
+
i++;
|
|
46
|
+
if (results.length >= ${limit}) break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
50
|
+
})()
|
|
51
|
+
`);
|
|
52
|
+
return Array.isArray(data) ? data : [];
|
|
53
|
+
},
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
import { clampInt, requireNonEmptyQuery } from '../_shared/common.js';
|
|
3
|
+
cli({
|
|
4
|
+
site: 'jd',
|
|
5
|
+
name: 'search',
|
|
6
|
+
description: '京东商品搜索',
|
|
7
|
+
domain: 'search.jd.com',
|
|
8
|
+
strategy: Strategy.COOKIE,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'query', positional: true, required: true, help: '搜索关键词' },
|
|
11
|
+
{ name: 'limit', type: 'int', default: 10, help: '返回结果数量 (max 30)' },
|
|
12
|
+
],
|
|
13
|
+
columns: ['rank', 'title', 'price', 'shop', 'sku', 'url'],
|
|
14
|
+
navigateBefore: false,
|
|
15
|
+
func: async (page, kwargs) => {
|
|
16
|
+
const limit = clampInt(kwargs.limit, 10, 1, 30);
|
|
17
|
+
const query = requireNonEmptyQuery(kwargs.query);
|
|
18
|
+
await page.goto(`https://search.jd.com/Search?keyword=${encodeURIComponent(query)}&enc=utf-8`);
|
|
19
|
+
await page.wait(5);
|
|
20
|
+
await page.autoScroll({ times: 2, delayMs: 1500 });
|
|
21
|
+
const data = await page.evaluate(`
|
|
22
|
+
(async () => {
|
|
23
|
+
const normalize = v => (v || '').replace(/\\s+/g, ' ').trim();
|
|
24
|
+
for (let i = 0; i < 20; i++) {
|
|
25
|
+
if (document.querySelectorAll('div[data-sku]').length > 0) break;
|
|
26
|
+
await new Promise(r => setTimeout(r, 500));
|
|
27
|
+
}
|
|
28
|
+
const items = document.querySelectorAll('div[data-sku]');
|
|
29
|
+
const results = [];
|
|
30
|
+
for (const el of items) {
|
|
31
|
+
const sku = el.getAttribute('data-sku') || '';
|
|
32
|
+
if (!sku) continue;
|
|
33
|
+
const text = normalize(el.textContent);
|
|
34
|
+
if (text.length < 10) continue;
|
|
35
|
+
|
|
36
|
+
const priceMatch = text.match(/¥([\\d,.]+)/);
|
|
37
|
+
const price = priceMatch ? '¥' + priceMatch[1] : '';
|
|
38
|
+
|
|
39
|
+
let title = '';
|
|
40
|
+
if (priceMatch) {
|
|
41
|
+
const beforePrice = text.substring(0, text.indexOf('¥'));
|
|
42
|
+
title = beforePrice.replace(/^(海外无货|京东超市|自营|秒杀|新品|预售|PLUS)/, '').trim();
|
|
43
|
+
}
|
|
44
|
+
if (!title || title.length < 4) continue;
|
|
45
|
+
|
|
46
|
+
let shop = '';
|
|
47
|
+
const shopMatch = text.match(/(\\S{2,15}(?:旗舰店|专卖店|自营店|官方旗舰店|京东自营旗舰店|京东自营))/);
|
|
48
|
+
if (shopMatch) shop = shopMatch[1];
|
|
49
|
+
|
|
50
|
+
results.push({
|
|
51
|
+
rank: results.length + 1,
|
|
52
|
+
title: title.slice(0, 80),
|
|
53
|
+
price,
|
|
54
|
+
shop,
|
|
55
|
+
sku,
|
|
56
|
+
url: 'https://item.jd.com/' + sku + '.html',
|
|
57
|
+
});
|
|
58
|
+
if (results.length >= ${limit}) break;
|
|
59
|
+
}
|
|
60
|
+
return results;
|
|
61
|
+
})()
|
|
62
|
+
`);
|
|
63
|
+
return Array.isArray(data) ? data : [];
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface JianyuCandidate {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
date: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildSearchUrl(query: string): string;
|
|
7
|
+
export declare function normalizeDate(raw: string): string;
|
|
8
|
+
declare function dedupeCandidates(items: JianyuCandidate[]): JianyuCandidate[];
|
|
9
|
+
export declare const __test__: {
|
|
10
|
+
buildSearchUrl: typeof buildSearchUrl;
|
|
11
|
+
normalizeDate: typeof normalizeDate;
|
|
12
|
+
dedupeCandidates: typeof dedupeCandidates;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jianyu search — browser DOM extraction from Jianyu bid search page.
|
|
3
|
+
*/
|
|
4
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
5
|
+
import { AuthRequiredError } from '@jackwener/opencli/errors';
|
|
6
|
+
const SEARCH_ENTRY = 'https://www.jianyu360.cn/jylab/supsearch/index.html';
|
|
7
|
+
function cleanText(value) {
|
|
8
|
+
return typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
|
|
9
|
+
}
|
|
10
|
+
export function buildSearchUrl(query) {
|
|
11
|
+
const url = new URL(SEARCH_ENTRY);
|
|
12
|
+
url.searchParams.set('keywords', query.trim());
|
|
13
|
+
url.searchParams.set('selectType', 'title');
|
|
14
|
+
url.searchParams.set('searchGroup', '1');
|
|
15
|
+
return url.toString();
|
|
16
|
+
}
|
|
17
|
+
export function normalizeDate(raw) {
|
|
18
|
+
const normalized = cleanText(raw);
|
|
19
|
+
const match = normalized.match(/(20\d{2})[.\-/年](\d{1,2})[.\-/月](\d{1,2})/);
|
|
20
|
+
if (!match)
|
|
21
|
+
return '';
|
|
22
|
+
const year = match[1];
|
|
23
|
+
const month = match[2].padStart(2, '0');
|
|
24
|
+
const day = match[3].padStart(2, '0');
|
|
25
|
+
return `${year}-${month}-${day}`;
|
|
26
|
+
}
|
|
27
|
+
function dedupeCandidates(items) {
|
|
28
|
+
const deduped = [];
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
for (const item of items) {
|
|
31
|
+
const key = `${item.title}\t${item.url}`;
|
|
32
|
+
if (seen.has(key))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(key);
|
|
35
|
+
deduped.push(item);
|
|
36
|
+
}
|
|
37
|
+
return deduped;
|
|
38
|
+
}
|
|
39
|
+
cli({
|
|
40
|
+
site: 'jianyu',
|
|
41
|
+
name: 'search',
|
|
42
|
+
description: '搜索剑鱼标讯公告',
|
|
43
|
+
domain: 'www.jianyu360.cn',
|
|
44
|
+
strategy: Strategy.COOKIE,
|
|
45
|
+
browser: true,
|
|
46
|
+
args: [
|
|
47
|
+
{ name: 'query', required: true, positional: true, help: 'Search keyword, e.g. "procurement"' },
|
|
48
|
+
{ name: 'limit', type: 'int', default: 20, help: 'Number of results (max 50)' },
|
|
49
|
+
],
|
|
50
|
+
columns: ['rank', 'title', 'date', 'url'],
|
|
51
|
+
func: async (page, kwargs) => {
|
|
52
|
+
const query = cleanText(kwargs.query);
|
|
53
|
+
const limit = Math.max(1, Math.min(Number(kwargs.limit) || 20, 50));
|
|
54
|
+
const searchUrl = buildSearchUrl(query);
|
|
55
|
+
await page.goto(searchUrl);
|
|
56
|
+
await page.wait(2);
|
|
57
|
+
const payload = await page.evaluate(`
|
|
58
|
+
(() => {
|
|
59
|
+
const clean = (value) => (value || '').replace(/\\s+/g, ' ').trim();
|
|
60
|
+
const toAbsolute = (href) => {
|
|
61
|
+
if (!href) return '';
|
|
62
|
+
if (href.startsWith('http://') || href.startsWith('https://')) return href;
|
|
63
|
+
if (href.startsWith('/')) return new URL(href, window.location.origin).toString();
|
|
64
|
+
return '';
|
|
65
|
+
};
|
|
66
|
+
const parseDate = (text) => {
|
|
67
|
+
const normalized = clean(text);
|
|
68
|
+
const match = normalized.match(/(20\\d{2})[.\\-/年](\\d{1,2})[.\\-/月](\\d{1,2})/);
|
|
69
|
+
if (!match) return '';
|
|
70
|
+
const month = String(match[2]).padStart(2, '0');
|
|
71
|
+
const day = String(match[3]).padStart(2, '0');
|
|
72
|
+
return match[1] + '-' + month + '-' + day;
|
|
73
|
+
};
|
|
74
|
+
const pickDateText = (node) => {
|
|
75
|
+
let cursor = node;
|
|
76
|
+
for (let i = 0; i < 4 && cursor; i++) {
|
|
77
|
+
const text = clean(cursor.innerText || cursor.textContent || '');
|
|
78
|
+
const date = parseDate(text);
|
|
79
|
+
if (date) return date;
|
|
80
|
+
cursor = cursor.parentElement;
|
|
81
|
+
}
|
|
82
|
+
return '';
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const anchors = Array.from(
|
|
86
|
+
document.querySelectorAll('a[href*="/nologin/content/"], a[href*="/content/"]'),
|
|
87
|
+
);
|
|
88
|
+
const rows = [];
|
|
89
|
+
const seen = new Set();
|
|
90
|
+
for (const anchor of anchors) {
|
|
91
|
+
const url = toAbsolute(anchor.getAttribute('href') || anchor.href || '');
|
|
92
|
+
const title = clean(anchor.textContent || '');
|
|
93
|
+
if (!url || !title || title.length < 4) continue;
|
|
94
|
+
const key = title + '\\t' + url;
|
|
95
|
+
if (seen.has(key)) continue;
|
|
96
|
+
seen.add(key);
|
|
97
|
+
rows.push({
|
|
98
|
+
title,
|
|
99
|
+
url,
|
|
100
|
+
date: pickDateText(anchor),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return rows;
|
|
104
|
+
})()
|
|
105
|
+
`);
|
|
106
|
+
const pageText = cleanText(await page.evaluate('document.body ? document.body.innerText : ""'));
|
|
107
|
+
if (!Array.isArray(payload)
|
|
108
|
+
&& /(请先登录|登录后|未登录|验证码)/.test(pageText)) {
|
|
109
|
+
throw new AuthRequiredError('www.jianyu360.cn', 'Jianyu search results require login or human verification');
|
|
110
|
+
}
|
|
111
|
+
const rows = Array.isArray(payload)
|
|
112
|
+
? payload
|
|
113
|
+
.filter((item) => !!item && typeof item === 'object')
|
|
114
|
+
.map((item) => ({
|
|
115
|
+
title: cleanText(item.title),
|
|
116
|
+
url: cleanText(item.url),
|
|
117
|
+
date: normalizeDate(cleanText(item.date)),
|
|
118
|
+
}))
|
|
119
|
+
.filter((item) => item.title && item.url)
|
|
120
|
+
: [];
|
|
121
|
+
return dedupeCandidates(rows)
|
|
122
|
+
.slice(0, limit)
|
|
123
|
+
.map((item, index) => ({
|
|
124
|
+
rank: index + 1,
|
|
125
|
+
title: item.title,
|
|
126
|
+
date: item.date,
|
|
127
|
+
url: item.url,
|
|
128
|
+
}));
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
export const __test__ = {
|
|
132
|
+
buildSearchUrl,
|
|
133
|
+
normalizeDate,
|
|
134
|
+
dedupeCandidates,
|
|
135
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { __test__ } from './search.js';
|
|
3
|
+
describe('jianyu search helpers', () => {
|
|
4
|
+
it('builds supsearch URL with required query params', () => {
|
|
5
|
+
const url = __test__.buildSearchUrl('procurement');
|
|
6
|
+
expect(url).toContain('keywords=procurement');
|
|
7
|
+
expect(url).toContain('selectType=title');
|
|
8
|
+
expect(url).toContain('searchGroup=1');
|
|
9
|
+
});
|
|
10
|
+
it('normalizes common date formats', () => {
|
|
11
|
+
expect(__test__.normalizeDate('2026-4-7')).toBe('2026-04-07');
|
|
12
|
+
expect(__test__.normalizeDate('2026年4月7日')).toBe('2026-04-07');
|
|
13
|
+
expect(__test__.normalizeDate('发布时间: 2026/04/07 09:00')).toBe('2026-04-07');
|
|
14
|
+
});
|
|
15
|
+
it('deduplicates by title and url', () => {
|
|
16
|
+
const deduped = __test__.dedupeCandidates([
|
|
17
|
+
{ title: 'A', url: 'https://example.com/1', date: '2026-04-07' },
|
|
18
|
+
{ title: 'A', url: 'https://example.com/1', date: '2026-04-07' },
|
|
19
|
+
{ title: 'A', url: 'https://example.com/2', date: '2026-04-07' },
|
|
20
|
+
]);
|
|
21
|
+
expect(deduped).toHaveLength(2);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { cli } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'jike',
|
|
4
|
+
name: 'post',
|
|
5
|
+
description: '即刻帖子详情及评论',
|
|
6
|
+
domain: 'm.okjike.com',
|
|
7
|
+
browser: true,
|
|
8
|
+
args: [
|
|
9
|
+
{
|
|
10
|
+
name: 'id',
|
|
11
|
+
type: 'string',
|
|
12
|
+
required: true,
|
|
13
|
+
positional: true,
|
|
14
|
+
help: 'Post ID (from post URL)',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
columns: ['type', 'author', 'content', 'likes', 'time'],
|
|
18
|
+
pipeline: [
|
|
19
|
+
{ navigate: 'https://m.okjike.com/originalPosts/${{ args.id }}' },
|
|
20
|
+
{ evaluate: `(() => {
|
|
21
|
+
try {
|
|
22
|
+
const el = document.querySelector('script[type="application/json"]');
|
|
23
|
+
if (!el) return [];
|
|
24
|
+
const data = JSON.parse(el.textContent);
|
|
25
|
+
const pageProps = data?.props?.pageProps || {};
|
|
26
|
+
const post = pageProps.post || {};
|
|
27
|
+
const comments = pageProps.comments || [];
|
|
28
|
+
|
|
29
|
+
const result = [{
|
|
30
|
+
type: 'post',
|
|
31
|
+
author: post.user?.screenName || '',
|
|
32
|
+
content: post.content || '',
|
|
33
|
+
likes: post.likeCount || 0,
|
|
34
|
+
time: post.createdAt || '',
|
|
35
|
+
}];
|
|
36
|
+
|
|
37
|
+
for (const c of comments) {
|
|
38
|
+
result.push({
|
|
39
|
+
type: 'comment',
|
|
40
|
+
author: c.user?.screenName || '',
|
|
41
|
+
content: (c.content || '').replace(/\\n/g, ' '),
|
|
42
|
+
likes: c.likeCount || 0,
|
|
43
|
+
time: c.createdAt || '',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
})()
|
|
52
|
+
` },
|
|
53
|
+
{ map: {
|
|
54
|
+
type: '${{ item.type }}',
|
|
55
|
+
author: '${{ item.author }}',
|
|
56
|
+
content: '${{ item.content }}',
|
|
57
|
+
likes: '${{ item.likes }}',
|
|
58
|
+
time: '${{ item.time }}',
|
|
59
|
+
} },
|
|
60
|
+
],
|
|
61
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|