@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,45 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
import { extractPwdId, formatDate, getShareList, getToken, } from './utils.js';
|
|
3
|
+
async function buildTree(page, pwdId, stoken, pdirFid, depth, maxDepth) {
|
|
4
|
+
if (depth > maxDepth)
|
|
5
|
+
return [];
|
|
6
|
+
const files = await getShareList(page, pwdId, stoken, pdirFid, { sort: 'file_type:asc,file_name:asc' });
|
|
7
|
+
const nodes = [];
|
|
8
|
+
for (const file of files) {
|
|
9
|
+
const node = {
|
|
10
|
+
fid: file.fid,
|
|
11
|
+
name: file.file_name,
|
|
12
|
+
size: file.size,
|
|
13
|
+
is_dir: file.dir,
|
|
14
|
+
created_at: formatDate(file.created_at),
|
|
15
|
+
updated_at: formatDate(file.updated_at),
|
|
16
|
+
};
|
|
17
|
+
if (file.dir && depth < maxDepth) {
|
|
18
|
+
node.children = await buildTree(page, pwdId, stoken, file.fid, depth + 1, maxDepth);
|
|
19
|
+
}
|
|
20
|
+
nodes.push(node);
|
|
21
|
+
}
|
|
22
|
+
return nodes;
|
|
23
|
+
}
|
|
24
|
+
cli({
|
|
25
|
+
site: 'quark',
|
|
26
|
+
name: 'share-tree',
|
|
27
|
+
description: 'Get directory tree from Quark Drive share link as nested JSON',
|
|
28
|
+
domain: 'pan.quark.cn',
|
|
29
|
+
strategy: Strategy.COOKIE,
|
|
30
|
+
defaultFormat: 'json',
|
|
31
|
+
args: [
|
|
32
|
+
{ name: 'url', required: true, positional: true, help: 'Quark share URL or pwd_id' },
|
|
33
|
+
{ name: 'passcode', default: '', help: 'Share passcode (if required)' },
|
|
34
|
+
{ name: 'depth', type: 'int', default: 10, help: 'Max directory depth' },
|
|
35
|
+
],
|
|
36
|
+
func: async (page, kwargs) => {
|
|
37
|
+
const url = kwargs.url;
|
|
38
|
+
const passcode = kwargs.passcode || '';
|
|
39
|
+
const depth = kwargs.depth ?? 10;
|
|
40
|
+
const pwdId = extractPwdId(url);
|
|
41
|
+
const stoken = await getToken(page, pwdId, passcode);
|
|
42
|
+
const tree = await buildTree(page, pwdId, stoken, '0', 0, depth);
|
|
43
|
+
return { pwd_id: pwdId, stoken, tree };
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IPage } from '@jackwener/opencli/types';
|
|
2
|
+
export declare const SHARE_API = "https://drive-h.quark.cn/1/clouddrive/share/sharepage";
|
|
3
|
+
export declare const DRIVE_API = "https://drive-pc.quark.cn/1/clouddrive/file";
|
|
4
|
+
export declare const TASK_API = "https://drive-pc.quark.cn/1/clouddrive/task";
|
|
5
|
+
export interface ApiResponse<T = unknown> {
|
|
6
|
+
status: number;
|
|
7
|
+
code: number;
|
|
8
|
+
message: string;
|
|
9
|
+
data: T;
|
|
10
|
+
metadata?: {
|
|
11
|
+
_total?: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ShareFile {
|
|
15
|
+
fid: string;
|
|
16
|
+
file_name: string;
|
|
17
|
+
size: number;
|
|
18
|
+
dir: boolean;
|
|
19
|
+
created_at: number;
|
|
20
|
+
updated_at: number;
|
|
21
|
+
}
|
|
22
|
+
export interface DriveFile {
|
|
23
|
+
fid: string;
|
|
24
|
+
file_name: string;
|
|
25
|
+
size: number;
|
|
26
|
+
dir: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function extractPwdId(url: string): string;
|
|
29
|
+
export declare function fetchJson<T = unknown>(page: IPage, url: string, options?: {
|
|
30
|
+
method?: string;
|
|
31
|
+
body?: object;
|
|
32
|
+
}): Promise<ApiResponse<T>>;
|
|
33
|
+
export declare function apiGet<T = unknown>(page: IPage, url: string): Promise<T>;
|
|
34
|
+
export declare function apiPost<T = unknown>(page: IPage, url: string, body: object): Promise<T>;
|
|
35
|
+
export declare function getToken(page: IPage, pwdId: string, passcode?: string): Promise<string>;
|
|
36
|
+
export declare function getShareList(page: IPage, pwdId: string, stoken: string, pdirFid?: string, options?: {
|
|
37
|
+
sort?: string;
|
|
38
|
+
}): Promise<ShareFile[]>;
|
|
39
|
+
export declare function listMyDrive(page: IPage, pdirFid: string): Promise<DriveFile[]>;
|
|
40
|
+
export declare function findFolder(page: IPage, path: string): Promise<string>;
|
|
41
|
+
export declare function formatDate(ts: number): string;
|
|
42
|
+
export declare function formatSize(bytes: number): string;
|
|
43
|
+
export interface TaskStatus {
|
|
44
|
+
status: number;
|
|
45
|
+
save_as?: {
|
|
46
|
+
save_as_sum_num: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare function getTaskStatus(page: IPage, taskId: string): Promise<TaskStatus | null>;
|
|
50
|
+
export declare function pollTask(page: IPage, taskId: string, onDone?: (task: TaskStatus) => void, maxAttempts?: number, intervalMs?: number): Promise<boolean>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ArgumentError, AuthRequiredError, CommandExecutionError, getErrorMessage } from '@jackwener/opencli/errors';
|
|
2
|
+
export const SHARE_API = 'https://drive-h.quark.cn/1/clouddrive/share/sharepage';
|
|
3
|
+
export const DRIVE_API = 'https://drive-pc.quark.cn/1/clouddrive/file';
|
|
4
|
+
export const TASK_API = 'https://drive-pc.quark.cn/1/clouddrive/task';
|
|
5
|
+
const QUARK_DOMAIN = 'pan.quark.cn';
|
|
6
|
+
const AUTH_HINT = 'Quark Drive requires a logged-in browser session';
|
|
7
|
+
function isAuthFailure(message, status) {
|
|
8
|
+
if (status === 401 || status === 403)
|
|
9
|
+
return true;
|
|
10
|
+
return /not logged in|login required|please log in|authentication required|unauthorized|forbidden|未登录|请先登录|需要登录|登录/.test(message.toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
function getErrorStatus(error) {
|
|
13
|
+
if (!error || typeof error !== 'object' || !('status' in error))
|
|
14
|
+
return undefined;
|
|
15
|
+
const status = error.status;
|
|
16
|
+
return typeof status === 'number' ? status : undefined;
|
|
17
|
+
}
|
|
18
|
+
function unwrapApiData(resp, action) {
|
|
19
|
+
if (resp.status === 200)
|
|
20
|
+
return resp.data;
|
|
21
|
+
if (isAuthFailure(resp.message, resp.status)) {
|
|
22
|
+
throw new AuthRequiredError(QUARK_DOMAIN, AUTH_HINT);
|
|
23
|
+
}
|
|
24
|
+
throw new CommandExecutionError(`quark: ${action}: ${resp.message}`);
|
|
25
|
+
}
|
|
26
|
+
export function extractPwdId(url) {
|
|
27
|
+
const m = url.match(/\/s\/([a-zA-Z0-9]+)/);
|
|
28
|
+
if (m)
|
|
29
|
+
return m[1];
|
|
30
|
+
if (/^[a-zA-Z0-9]+$/.test(url))
|
|
31
|
+
return url;
|
|
32
|
+
throw new ArgumentError(`Invalid Quark share URL: ${url}`);
|
|
33
|
+
}
|
|
34
|
+
export async function fetchJson(page, url, options) {
|
|
35
|
+
const method = options?.method || 'GET';
|
|
36
|
+
const body = options?.body ? JSON.stringify(options.body) : undefined;
|
|
37
|
+
const js = `fetch(${JSON.stringify(url)}, {
|
|
38
|
+
method: ${JSON.stringify(method)},
|
|
39
|
+
headers: { 'Content-Type': 'application/json' },
|
|
40
|
+
credentials: 'include',
|
|
41
|
+
${body ? `body: ${JSON.stringify(body)},` : ''}
|
|
42
|
+
}).then(async r => {
|
|
43
|
+
const ct = r.headers.get('content-type') || '';
|
|
44
|
+
if (!ct.includes('json')) {
|
|
45
|
+
const text = await r.text().catch(() => '');
|
|
46
|
+
throw Object.assign(new Error('Non-JSON response: ' + text.slice(0, 200)), { status: r.status });
|
|
47
|
+
}
|
|
48
|
+
return r.json();
|
|
49
|
+
})`;
|
|
50
|
+
try {
|
|
51
|
+
return await page.evaluate(js);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (isAuthFailure(getErrorMessage(error), getErrorStatus(error))) {
|
|
55
|
+
throw new AuthRequiredError(QUARK_DOMAIN, AUTH_HINT);
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function apiGet(page, url) {
|
|
61
|
+
const resp = await fetchJson(page, url);
|
|
62
|
+
return unwrapApiData(resp, 'API error');
|
|
63
|
+
}
|
|
64
|
+
export async function apiPost(page, url, body) {
|
|
65
|
+
const resp = await fetchJson(page, url, { method: 'POST', body });
|
|
66
|
+
return unwrapApiData(resp, 'API error');
|
|
67
|
+
}
|
|
68
|
+
export async function getToken(page, pwdId, passcode = '') {
|
|
69
|
+
const data = await fetchJson(page, `${SHARE_API}/token?pr=ucpro&fr=pc`, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
body: { pwd_id: pwdId, passcode, support_visit_limit_private_share: true },
|
|
72
|
+
});
|
|
73
|
+
return unwrapApiData(data, 'Failed to get token').stoken;
|
|
74
|
+
}
|
|
75
|
+
export async function getShareList(page, pwdId, stoken, pdirFid = '0', options) {
|
|
76
|
+
const allFiles = [];
|
|
77
|
+
let pageNum = 1;
|
|
78
|
+
let total = 0;
|
|
79
|
+
do {
|
|
80
|
+
const sortParam = options?.sort ? `&_sort=${options.sort}` : '';
|
|
81
|
+
const url = `${SHARE_API}/detail?pr=ucpro&fr=pc&ver=2&pwd_id=${pwdId}&stoken=${encodeURIComponent(stoken)}&pdir_fid=${pdirFid}&force=0&_page=${pageNum}&_size=200&_fetch_total=1${sortParam}`;
|
|
82
|
+
const data = await fetchJson(page, url);
|
|
83
|
+
const files = unwrapApiData(data, 'Failed to get share list')?.list || [];
|
|
84
|
+
allFiles.push(...files);
|
|
85
|
+
total = data.metadata?._total || 0;
|
|
86
|
+
pageNum++;
|
|
87
|
+
} while (allFiles.length < total);
|
|
88
|
+
return allFiles;
|
|
89
|
+
}
|
|
90
|
+
export async function listMyDrive(page, pdirFid) {
|
|
91
|
+
const allFiles = [];
|
|
92
|
+
let pageNum = 1;
|
|
93
|
+
let total = 0;
|
|
94
|
+
do {
|
|
95
|
+
const url = `${DRIVE_API}/sort?pr=ucpro&fr=pc&pdir_fid=${pdirFid}&_page=${pageNum}&_size=200&_fetch_total=1&_sort=file_type:asc,file_name:asc`;
|
|
96
|
+
const data = await fetchJson(page, url);
|
|
97
|
+
const files = unwrapApiData(data, 'Failed to list drive')?.list || [];
|
|
98
|
+
allFiles.push(...files);
|
|
99
|
+
total = data.metadata?._total || 0;
|
|
100
|
+
pageNum++;
|
|
101
|
+
} while (allFiles.length < total);
|
|
102
|
+
return allFiles;
|
|
103
|
+
}
|
|
104
|
+
export async function findFolder(page, path) {
|
|
105
|
+
const parts = path.split('/').filter(Boolean);
|
|
106
|
+
let currentFid = '0';
|
|
107
|
+
for (const part of parts) {
|
|
108
|
+
const files = await listMyDrive(page, currentFid);
|
|
109
|
+
const existing = files.find(f => f.dir && f.file_name === part);
|
|
110
|
+
if (existing) {
|
|
111
|
+
currentFid = existing.fid;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
throw new CommandExecutionError(`quark: Folder "${part}" not found in "${path}"`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return currentFid;
|
|
118
|
+
}
|
|
119
|
+
export function formatDate(ts) {
|
|
120
|
+
if (!ts)
|
|
121
|
+
return '';
|
|
122
|
+
const d = new Date(ts);
|
|
123
|
+
return d.toISOString().replace('T', ' ').slice(0, 19);
|
|
124
|
+
}
|
|
125
|
+
export function formatSize(bytes) {
|
|
126
|
+
if (bytes <= 0)
|
|
127
|
+
return '0 B';
|
|
128
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
129
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
130
|
+
return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${units[i]}`;
|
|
131
|
+
}
|
|
132
|
+
export async function getTaskStatus(page, taskId) {
|
|
133
|
+
const url = `${TASK_API}?pr=ucpro&fr=pc&task_id=${taskId}&retry_index=0`;
|
|
134
|
+
return apiGet(page, url);
|
|
135
|
+
}
|
|
136
|
+
export async function pollTask(page, taskId, onDone, maxAttempts = 30, intervalMs = 500) {
|
|
137
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
138
|
+
await new Promise(r => setTimeout(r, intervalMs));
|
|
139
|
+
const task = await getTaskStatus(page, taskId);
|
|
140
|
+
if (task?.status === 2) {
|
|
141
|
+
onDone?.(task);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
|
|
3
|
+
import { apiGet, apiPost, extractPwdId, getShareList, getToken } from './utils.js';
|
|
4
|
+
function makePage(evaluateImpl) {
|
|
5
|
+
return {
|
|
6
|
+
evaluate: vi.fn(evaluateImpl),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
describe('quark utils', () => {
|
|
10
|
+
it('extractPwdId accepts share URLs and raw ids', () => {
|
|
11
|
+
expect(extractPwdId('https://pan.quark.cn/s/abc123')).toBe('abc123');
|
|
12
|
+
expect(extractPwdId('abc123')).toBe('abc123');
|
|
13
|
+
});
|
|
14
|
+
it('maps JSON auth failures to AuthRequiredError', async () => {
|
|
15
|
+
const page = makePage(async () => ({
|
|
16
|
+
status: 401,
|
|
17
|
+
code: 401,
|
|
18
|
+
message: '未登录',
|
|
19
|
+
data: null,
|
|
20
|
+
}));
|
|
21
|
+
await expect(apiGet(page, 'https://drive-pc.quark.cn/test')).rejects.toBeInstanceOf(AuthRequiredError);
|
|
22
|
+
});
|
|
23
|
+
it('maps non-JSON auth pages to AuthRequiredError', async () => {
|
|
24
|
+
const page = makePage(async () => {
|
|
25
|
+
const error = Object.assign(new Error('Non-JSON response: <html><title>登录</title></html>'), { status: 401 });
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
await expect(apiPost(page, 'https://drive-pc.quark.cn/test', {})).rejects.toBeInstanceOf(AuthRequiredError);
|
|
29
|
+
});
|
|
30
|
+
it('keeps generic API failures as CommandExecutionError', async () => {
|
|
31
|
+
const page = makePage(async () => ({
|
|
32
|
+
status: 500,
|
|
33
|
+
code: 500,
|
|
34
|
+
message: 'server busy',
|
|
35
|
+
data: null,
|
|
36
|
+
}));
|
|
37
|
+
await expect(apiGet(page, 'https://drive-pc.quark.cn/test')).rejects.toBeInstanceOf(CommandExecutionError);
|
|
38
|
+
});
|
|
39
|
+
it('unwraps successful token responses', async () => {
|
|
40
|
+
const page = makePage(async () => ({
|
|
41
|
+
status: 200,
|
|
42
|
+
code: 0,
|
|
43
|
+
message: 'ok',
|
|
44
|
+
data: { stoken: 'token123' },
|
|
45
|
+
}));
|
|
46
|
+
await expect(getToken(page, 'abc123')).resolves.toBe('token123');
|
|
47
|
+
});
|
|
48
|
+
it('maps share-tree detail auth failures to AuthRequiredError', async () => {
|
|
49
|
+
const page = makePage(async () => ({
|
|
50
|
+
status: 401,
|
|
51
|
+
code: 401,
|
|
52
|
+
message: '请先登录',
|
|
53
|
+
data: null,
|
|
54
|
+
metadata: { _total: 0 },
|
|
55
|
+
}));
|
|
56
|
+
await expect(getShareList(page, 'abc123', 'token123')).rejects.toBeInstanceOf(AuthRequiredError);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'frontpage',
|
|
5
|
+
description: 'Reddit Frontpage / r/all',
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'limit', type: 'int', default: 15 },
|
|
11
|
+
],
|
|
12
|
+
columns: ['title', 'subreddit', 'author', 'upvotes', 'comments', 'url'],
|
|
13
|
+
pipeline: [
|
|
14
|
+
{ navigate: 'https://www.reddit.com' },
|
|
15
|
+
{ evaluate: `(async () => {
|
|
16
|
+
const res = await fetch('/r/all.json?limit=\${{ args.limit }}', { credentials: 'include' });
|
|
17
|
+
const j = await res.json();
|
|
18
|
+
return j?.data?.children || [];
|
|
19
|
+
})()
|
|
20
|
+
` },
|
|
21
|
+
{ map: {
|
|
22
|
+
title: '${{ item.data.title }}',
|
|
23
|
+
subreddit: '${{ item.data.subreddit_name_prefixed }}',
|
|
24
|
+
author: '${{ item.data.author }}',
|
|
25
|
+
upvotes: '${{ item.data.score }}',
|
|
26
|
+
comments: '${{ item.data.num_comments }}',
|
|
27
|
+
url: 'https://www.reddit.com${{ item.data.permalink }}',
|
|
28
|
+
} },
|
|
29
|
+
{ limit: '${{ args.limit }}' },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cli } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'hot',
|
|
5
|
+
description: 'Reddit 热门帖子',
|
|
6
|
+
domain: 'www.reddit.com',
|
|
7
|
+
args: [
|
|
8
|
+
{
|
|
9
|
+
name: 'subreddit',
|
|
10
|
+
default: '',
|
|
11
|
+
help: 'Subreddit name (e.g. programming). Empty for frontpage',
|
|
12
|
+
},
|
|
13
|
+
{ name: 'limit', type: 'int', default: 20, help: 'Number of posts' },
|
|
14
|
+
],
|
|
15
|
+
columns: ['rank', 'title', 'subreddit', 'score', 'comments'],
|
|
16
|
+
pipeline: [
|
|
17
|
+
{ navigate: 'https://www.reddit.com' },
|
|
18
|
+
{ evaluate: `(async () => {
|
|
19
|
+
const sub = \${{ args.subreddit | json }};
|
|
20
|
+
const path = sub ? '/r/' + sub + '/hot.json' : '/hot.json';
|
|
21
|
+
const limit = \${{ args.limit }};
|
|
22
|
+
const res = await fetch(path + '?limit=' + limit + '&raw_json=1', {
|
|
23
|
+
credentials: 'include'
|
|
24
|
+
});
|
|
25
|
+
const d = await res.json();
|
|
26
|
+
return (d?.data?.children || []).map(c => ({
|
|
27
|
+
title: c.data.title,
|
|
28
|
+
subreddit: c.data.subreddit_name_prefixed,
|
|
29
|
+
score: c.data.score,
|
|
30
|
+
comments: c.data.num_comments,
|
|
31
|
+
author: c.data.author,
|
|
32
|
+
url: 'https://www.reddit.com' + c.data.permalink,
|
|
33
|
+
}));
|
|
34
|
+
})()
|
|
35
|
+
` },
|
|
36
|
+
{ map: {
|
|
37
|
+
rank: '${{ index + 1 }}',
|
|
38
|
+
title: '${{ item.title }}',
|
|
39
|
+
subreddit: '${{ item.subreddit }}',
|
|
40
|
+
score: '${{ item.score }}',
|
|
41
|
+
comments: '${{ item.comments }}',
|
|
42
|
+
} },
|
|
43
|
+
{ limit: '${{ args.limit }}' },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'popular',
|
|
5
|
+
description: 'Reddit Popular posts (/r/popular)',
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'limit', type: 'int', default: 20 },
|
|
11
|
+
],
|
|
12
|
+
columns: ['rank', 'title', 'subreddit', 'score', 'comments', 'url'],
|
|
13
|
+
pipeline: [
|
|
14
|
+
{ navigate: 'https://www.reddit.com' },
|
|
15
|
+
{ evaluate: `(async () => {
|
|
16
|
+
const limit = \${{ args.limit }};
|
|
17
|
+
const res = await fetch('/r/popular.json?limit=' + limit + '&raw_json=1', {
|
|
18
|
+
credentials: 'include'
|
|
19
|
+
});
|
|
20
|
+
const d = await res.json();
|
|
21
|
+
return (d?.data?.children || []).map(c => ({
|
|
22
|
+
title: c.data.title,
|
|
23
|
+
subreddit: c.data.subreddit_name_prefixed,
|
|
24
|
+
score: c.data.score,
|
|
25
|
+
comments: c.data.num_comments,
|
|
26
|
+
author: c.data.author,
|
|
27
|
+
url: 'https://www.reddit.com' + c.data.permalink,
|
|
28
|
+
}));
|
|
29
|
+
})()
|
|
30
|
+
` },
|
|
31
|
+
{ map: {
|
|
32
|
+
rank: '${{ index + 1 }}',
|
|
33
|
+
title: '${{ item.title }}',
|
|
34
|
+
subreddit: '${{ item.subreddit }}',
|
|
35
|
+
score: '${{ item.score }}',
|
|
36
|
+
comments: '${{ item.comments }}',
|
|
37
|
+
url: '${{ item.url }}',
|
|
38
|
+
} },
|
|
39
|
+
{ limit: '${{ args.limit }}' },
|
|
40
|
+
],
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'search',
|
|
5
|
+
description: 'Search Reddit Posts',
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'query', type: 'string', required: true, positional: true },
|
|
11
|
+
{
|
|
12
|
+
name: 'subreddit',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: '',
|
|
15
|
+
help: 'Search within a specific subreddit',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'sort',
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: 'relevance',
|
|
21
|
+
help: 'Sort order: relevance, hot, top, new, comments',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'time',
|
|
25
|
+
type: 'string',
|
|
26
|
+
default: 'all',
|
|
27
|
+
help: 'Time filter: hour, day, week, month, year, all',
|
|
28
|
+
},
|
|
29
|
+
{ name: 'limit', type: 'int', default: 15 },
|
|
30
|
+
],
|
|
31
|
+
columns: ['title', 'subreddit', 'author', 'score', 'comments', 'url'],
|
|
32
|
+
pipeline: [
|
|
33
|
+
{ navigate: 'https://www.reddit.com' },
|
|
34
|
+
{ evaluate: `(async () => {
|
|
35
|
+
const q = encodeURIComponent(\${{ args.query | json }});
|
|
36
|
+
const sub = \${{ args.subreddit | json }};
|
|
37
|
+
const sort = \${{ args.sort | json }};
|
|
38
|
+
const time = \${{ args.time | json }};
|
|
39
|
+
const limit = \${{ args.limit }};
|
|
40
|
+
const basePath = sub ? '/r/' + sub + '/search.json' : '/search.json';
|
|
41
|
+
const params = 'q=' + q + '&sort=' + sort + '&t=' + time + '&limit=' + limit
|
|
42
|
+
+ '&restrict_sr=' + (sub ? 'on' : 'off') + '&raw_json=1';
|
|
43
|
+
const res = await fetch(basePath + '?' + params, { credentials: 'include' });
|
|
44
|
+
const d = await res.json();
|
|
45
|
+
return (d?.data?.children || []).map(c => ({
|
|
46
|
+
title: c.data.title,
|
|
47
|
+
subreddit: c.data.subreddit_name_prefixed,
|
|
48
|
+
author: c.data.author,
|
|
49
|
+
score: c.data.score,
|
|
50
|
+
comments: c.data.num_comments,
|
|
51
|
+
url: 'https://www.reddit.com' + c.data.permalink,
|
|
52
|
+
}));
|
|
53
|
+
})()
|
|
54
|
+
` },
|
|
55
|
+
{ map: {
|
|
56
|
+
title: '${{ item.title }}',
|
|
57
|
+
subreddit: '${{ item.subreddit }}',
|
|
58
|
+
author: '${{ item.author }}',
|
|
59
|
+
score: '${{ item.score }}',
|
|
60
|
+
comments: '${{ item.comments }}',
|
|
61
|
+
url: '${{ item.url }}',
|
|
62
|
+
} },
|
|
63
|
+
{ limit: '${{ args.limit }}' },
|
|
64
|
+
],
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'subreddit',
|
|
5
|
+
description: 'Get posts from a specific Subreddit',
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'name', type: 'string', required: true, positional: true },
|
|
11
|
+
{
|
|
12
|
+
name: 'sort',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: 'hot',
|
|
15
|
+
help: 'Sorting method: hot, new, top, rising, controversial',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'time',
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: 'all',
|
|
21
|
+
help: 'Time filter for top/controversial: hour, day, week, month, year, all',
|
|
22
|
+
},
|
|
23
|
+
{ name: 'limit', type: 'int', default: 15 },
|
|
24
|
+
],
|
|
25
|
+
columns: ['title', 'author', 'upvotes', 'comments', 'url'],
|
|
26
|
+
pipeline: [
|
|
27
|
+
{ navigate: 'https://www.reddit.com' },
|
|
28
|
+
{ evaluate: `(async () => {
|
|
29
|
+
let sub = \${{ args.name | json }};
|
|
30
|
+
if (sub.startsWith('r/')) sub = sub.slice(2);
|
|
31
|
+
const sort = \${{ args.sort | json }};
|
|
32
|
+
const time = \${{ args.time | json }};
|
|
33
|
+
const limit = \${{ args.limit }};
|
|
34
|
+
let url = '/r/' + sub + '/' + sort + '.json?limit=' + limit + '&raw_json=1';
|
|
35
|
+
if ((sort === 'top' || sort === 'controversial') && time) {
|
|
36
|
+
url += '&t=' + time;
|
|
37
|
+
}
|
|
38
|
+
const res = await fetch(url, { credentials: 'include' });
|
|
39
|
+
const j = await res.json();
|
|
40
|
+
return j?.data?.children || [];
|
|
41
|
+
})()
|
|
42
|
+
` },
|
|
43
|
+
{ map: {
|
|
44
|
+
title: '${{ item.data.title }}',
|
|
45
|
+
author: '${{ item.data.author }}',
|
|
46
|
+
upvotes: '${{ item.data.score }}',
|
|
47
|
+
comments: '${{ item.data.num_comments }}',
|
|
48
|
+
url: 'https://www.reddit.com${{ item.data.permalink }}',
|
|
49
|
+
} },
|
|
50
|
+
{ limit: '${{ args.limit }}' },
|
|
51
|
+
],
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'user-comments',
|
|
5
|
+
description: `View a Reddit user's comment history`,
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'username', type: 'string', required: true, positional: true },
|
|
11
|
+
{ name: 'limit', type: 'int', default: 15 },
|
|
12
|
+
],
|
|
13
|
+
columns: ['subreddit', 'score', 'body', 'url'],
|
|
14
|
+
pipeline: [
|
|
15
|
+
{ navigate: 'https://www.reddit.com' },
|
|
16
|
+
{ evaluate: `(async () => {
|
|
17
|
+
const username = \${{ args.username | json }};
|
|
18
|
+
const name = username.startsWith('u/') ? username.slice(2) : username;
|
|
19
|
+
const limit = \${{ args.limit }};
|
|
20
|
+
const res = await fetch('/user/' + name + '/comments.json?limit=' + limit + '&raw_json=1', {
|
|
21
|
+
credentials: 'include'
|
|
22
|
+
});
|
|
23
|
+
const d = await res.json();
|
|
24
|
+
return (d?.data?.children || []).map(c => {
|
|
25
|
+
let body = c.data.body || '';
|
|
26
|
+
if (body.length > 300) body = body.slice(0, 300) + '...';
|
|
27
|
+
return {
|
|
28
|
+
subreddit: c.data.subreddit_name_prefixed,
|
|
29
|
+
score: c.data.score,
|
|
30
|
+
body: body,
|
|
31
|
+
url: 'https://www.reddit.com' + c.data.permalink,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
})()
|
|
35
|
+
` },
|
|
36
|
+
{ map: {
|
|
37
|
+
subreddit: '${{ item.subreddit }}',
|
|
38
|
+
score: '${{ item.score }}',
|
|
39
|
+
body: '${{ item.body }}',
|
|
40
|
+
url: '${{ item.url }}',
|
|
41
|
+
} },
|
|
42
|
+
{ limit: '${{ args.limit }}' },
|
|
43
|
+
],
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'reddit',
|
|
4
|
+
name: 'user-posts',
|
|
5
|
+
description: `View a Reddit user's submitted posts`,
|
|
6
|
+
domain: 'reddit.com',
|
|
7
|
+
strategy: Strategy.COOKIE,
|
|
8
|
+
browser: true,
|
|
9
|
+
args: [
|
|
10
|
+
{ name: 'username', type: 'string', required: true, positional: true },
|
|
11
|
+
{ name: 'limit', type: 'int', default: 15 },
|
|
12
|
+
],
|
|
13
|
+
columns: ['title', 'subreddit', 'score', 'comments', 'url'],
|
|
14
|
+
pipeline: [
|
|
15
|
+
{ navigate: 'https://www.reddit.com' },
|
|
16
|
+
{ evaluate: `(async () => {
|
|
17
|
+
const username = \${{ args.username | json }};
|
|
18
|
+
const name = username.startsWith('u/') ? username.slice(2) : username;
|
|
19
|
+
const limit = \${{ args.limit }};
|
|
20
|
+
const res = await fetch('/user/' + name + '/submitted.json?limit=' + limit + '&raw_json=1', {
|
|
21
|
+
credentials: 'include'
|
|
22
|
+
});
|
|
23
|
+
const d = await res.json();
|
|
24
|
+
return (d?.data?.children || []).map(c => ({
|
|
25
|
+
title: c.data.title,
|
|
26
|
+
subreddit: c.data.subreddit_name_prefixed,
|
|
27
|
+
score: c.data.score,
|
|
28
|
+
comments: c.data.num_comments,
|
|
29
|
+
url: 'https://www.reddit.com' + c.data.permalink,
|
|
30
|
+
}));
|
|
31
|
+
})()
|
|
32
|
+
` },
|
|
33
|
+
{ map: {
|
|
34
|
+
title: '${{ item.title }}',
|
|
35
|
+
subreddit: '${{ item.subreddit }}',
|
|
36
|
+
score: '${{ item.score }}',
|
|
37
|
+
comments: '${{ item.comments }}',
|
|
38
|
+
url: '${{ item.url }}',
|
|
39
|
+
} },
|
|
40
|
+
{ limit: '${{ args.limit }}' },
|
|
41
|
+
],
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|