@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,49 @@
|
|
|
1
|
+
import { cli } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'xueqiu',
|
|
4
|
+
name: 'search',
|
|
5
|
+
description: '搜索雪球股票(代码或名称)',
|
|
6
|
+
domain: 'xueqiu.com',
|
|
7
|
+
browser: true,
|
|
8
|
+
args: [
|
|
9
|
+
{ name: 'query', required: true, positional: true, help: '搜索关键词,如 茅台、AAPL、腾讯' },
|
|
10
|
+
{ name: 'limit', type: 'int', default: 10, help: '返回数量,默认 10' },
|
|
11
|
+
],
|
|
12
|
+
columns: ['symbol', 'name', 'exchange', 'price', 'changePercent', 'url'],
|
|
13
|
+
pipeline: [
|
|
14
|
+
{ navigate: 'https://xueqiu.com' },
|
|
15
|
+
{ evaluate: `(async () => {
|
|
16
|
+
const query = \${{ args.query | json }};
|
|
17
|
+
const count = \${{ args.limit }};
|
|
18
|
+
const resp = await fetch(\`https://xueqiu.com/stock/search.json?code=\${encodeURIComponent(query)}&size=\${count}\`, {credentials: 'include'});
|
|
19
|
+
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' Hint: Not logged in?');
|
|
20
|
+
const d = await resp.json();
|
|
21
|
+
return (d.stocks || []).map(s => {
|
|
22
|
+
let symbol = '';
|
|
23
|
+
if (s.exchange === 'SH' || s.exchange === 'SZ' || s.exchange === 'BJ') {
|
|
24
|
+
symbol = s.code.startsWith(s.exchange) ? s.code : s.exchange + s.code;
|
|
25
|
+
} else {
|
|
26
|
+
symbol = s.code;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
symbol: symbol,
|
|
30
|
+
name: s.name,
|
|
31
|
+
exchange: s.exchange,
|
|
32
|
+
price: s.current,
|
|
33
|
+
changePercent: s.percentage != null ? s.percentage.toFixed(2) + '%' : null,
|
|
34
|
+
url: 'https://xueqiu.com/S/' + symbol
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
})()
|
|
38
|
+
` },
|
|
39
|
+
{ map: {
|
|
40
|
+
symbol: '${{ item.symbol }}',
|
|
41
|
+
name: '${{ item.name }}',
|
|
42
|
+
exchange: '${{ item.exchange }}',
|
|
43
|
+
price: '${{ item.price }}',
|
|
44
|
+
changePercent: '${{ item.changePercent }}',
|
|
45
|
+
url: '${{ item.url }}',
|
|
46
|
+
} },
|
|
47
|
+
{ limit: '${{ args.limit }}' },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { cli } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'xueqiu',
|
|
4
|
+
name: 'stock',
|
|
5
|
+
description: '获取雪球股票实时行情',
|
|
6
|
+
domain: 'xueqiu.com',
|
|
7
|
+
browser: true,
|
|
8
|
+
args: [
|
|
9
|
+
{
|
|
10
|
+
name: 'symbol',
|
|
11
|
+
required: true,
|
|
12
|
+
positional: true,
|
|
13
|
+
help: '股票代码,如 SH600519、SZ000858、AAPL、00700',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
columns: ['name', 'symbol', 'price', 'changePercent', 'marketCap'],
|
|
17
|
+
pipeline: [
|
|
18
|
+
{ navigate: 'https://xueqiu.com' },
|
|
19
|
+
{ evaluate: `(async () => {
|
|
20
|
+
const symbol = (\${{ args.symbol | json }} || '').toUpperCase();
|
|
21
|
+
if (!symbol) throw new Error('Missing argument: symbol');
|
|
22
|
+
const resp = await fetch(\`https://stock.xueqiu.com/v5/stock/batch/quote.json?symbol=\${encodeURIComponent(symbol)}\`, {credentials: 'include'});
|
|
23
|
+
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' Hint: Not logged in?');
|
|
24
|
+
const d = await resp.json();
|
|
25
|
+
if (!d.data || !d.data.items || d.data.items.length === 0) throw new Error('未找到股票: ' + symbol);
|
|
26
|
+
|
|
27
|
+
function fmtAmount(v) {
|
|
28
|
+
if (v == null) return null;
|
|
29
|
+
if (Math.abs(v) >= 1e12) return (v / 1e12).toFixed(2) + '万亿';
|
|
30
|
+
if (Math.abs(v) >= 1e8) return (v / 1e8).toFixed(2) + '亿';
|
|
31
|
+
if (Math.abs(v) >= 1e4) return (v / 1e4).toFixed(2) + '万';
|
|
32
|
+
return v.toString();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const item = d.data.items[0];
|
|
36
|
+
const q = item.quote || {};
|
|
37
|
+
const m = item.market || {};
|
|
38
|
+
|
|
39
|
+
return [{
|
|
40
|
+
name: q.name,
|
|
41
|
+
symbol: q.symbol,
|
|
42
|
+
exchange: q.exchange,
|
|
43
|
+
currency: q.currency,
|
|
44
|
+
price: q.current,
|
|
45
|
+
change: q.chg,
|
|
46
|
+
changePercent: q.percent != null ? q.percent.toFixed(2) + '%' : null,
|
|
47
|
+
open: q.open,
|
|
48
|
+
high: q.high,
|
|
49
|
+
low: q.low,
|
|
50
|
+
prevClose: q.last_close,
|
|
51
|
+
amplitude: q.amplitude != null ? q.amplitude.toFixed(2) + '%' : null,
|
|
52
|
+
volume: q.volume,
|
|
53
|
+
amount: fmtAmount(q.amount),
|
|
54
|
+
turnover_rate: q.turnover_rate != null ? q.turnover_rate.toFixed(2) + '%' : null,
|
|
55
|
+
marketCap: fmtAmount(q.market_capital),
|
|
56
|
+
floatMarketCap: fmtAmount(q.float_market_capital),
|
|
57
|
+
ytdPercent: q.current_year_percent != null ? q.current_year_percent.toFixed(2) + '%' : null,
|
|
58
|
+
market_status: m.status || null,
|
|
59
|
+
time: q.timestamp ? new Date(q.timestamp).toISOString() : null,
|
|
60
|
+
url: 'https://xueqiu.com/S/' + q.symbol
|
|
61
|
+
}];
|
|
62
|
+
})()
|
|
63
|
+
` },
|
|
64
|
+
{ map: {
|
|
65
|
+
name: '${{ item.name }}',
|
|
66
|
+
symbol: '${{ item.symbol }}',
|
|
67
|
+
price: '${{ item.price }}',
|
|
68
|
+
changePercent: '${{ item.changePercent }}',
|
|
69
|
+
marketCap: '${{ item.marketCap }}',
|
|
70
|
+
} },
|
|
71
|
+
],
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cli } from '@jackwener/opencli/registry';
|
|
2
|
+
cli({
|
|
3
|
+
site: 'xueqiu',
|
|
4
|
+
name: 'watchlist',
|
|
5
|
+
description: '获取雪球自选股/模拟组合股票列表',
|
|
6
|
+
domain: 'xueqiu.com',
|
|
7
|
+
browser: true,
|
|
8
|
+
args: [
|
|
9
|
+
{
|
|
10
|
+
name: 'pid',
|
|
11
|
+
default: '-1',
|
|
12
|
+
help: '分组ID:-1=全部(默认) -4=模拟 -5=沪深 -6=美股 -7=港股 -10=实盘 0=持仓(通过 xueqiu groups 获取)',
|
|
13
|
+
},
|
|
14
|
+
{ name: 'limit', type: 'int', default: 100, help: '默认 100' },
|
|
15
|
+
],
|
|
16
|
+
columns: ['symbol', 'name', 'price', 'changePercent'],
|
|
17
|
+
pipeline: [
|
|
18
|
+
{ navigate: 'https://xueqiu.com' },
|
|
19
|
+
{ evaluate: `(async () => {
|
|
20
|
+
const pid = \${{ args.pid | json }} || '-1';
|
|
21
|
+
const resp = await fetch(\`https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?size=100&category=1&pid=\${encodeURIComponent(pid)}\`, {credentials: 'include'});
|
|
22
|
+
if (!resp.ok) throw new Error('HTTP ' + resp.status + ' Hint: Not logged in?');
|
|
23
|
+
const d = await resp.json();
|
|
24
|
+
if (!d.data || !d.data.stocks) throw new Error('获取失败,可能未登录');
|
|
25
|
+
|
|
26
|
+
return d.data.stocks.map(s => ({
|
|
27
|
+
symbol: s.symbol,
|
|
28
|
+
name: s.name,
|
|
29
|
+
price: s.current,
|
|
30
|
+
change: s.chg,
|
|
31
|
+
changePercent: s.percent != null ? s.percent.toFixed(2) + '%' : null,
|
|
32
|
+
volume: s.volume,
|
|
33
|
+
url: 'https://xueqiu.com/S/' + s.symbol
|
|
34
|
+
}));
|
|
35
|
+
})()
|
|
36
|
+
` },
|
|
37
|
+
{ map: {
|
|
38
|
+
symbol: '${{ item.symbol }}',
|
|
39
|
+
name: '${{ item.name }}',
|
|
40
|
+
price: '${{ item.price }}',
|
|
41
|
+
changePercent: '${{ item.changePercent }}',
|
|
42
|
+
} },
|
|
43
|
+
{ limit: '${{ args.limit }}' },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { CliError, CommandExecutionError } from '@jackwener/opencli/errors';
|
|
2
|
+
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
3
|
+
import { assertAllowedKinds, parseTarget } from './target.js';
|
|
4
|
+
import { buildResultRow, requireExecute, resolveCurrentUserIdentity, resolvePayload } from './write-shared.js';
|
|
5
|
+
const ANSWER_AUTHOR_SCOPE_SELECTOR = '.AuthorInfo, .AnswerItem-authorInfo, .ContentItem-meta, [itemprop="author"]';
|
|
6
|
+
cli({
|
|
7
|
+
site: 'zhihu',
|
|
8
|
+
name: 'answer',
|
|
9
|
+
description: 'Answer a Zhihu question',
|
|
10
|
+
domain: 'www.zhihu.com',
|
|
11
|
+
strategy: Strategy.UI,
|
|
12
|
+
browser: true,
|
|
13
|
+
args: [
|
|
14
|
+
{ name: 'target', positional: true, required: true, help: 'Zhihu question URL or typed target' },
|
|
15
|
+
{ name: 'text', positional: true, help: 'Answer text' },
|
|
16
|
+
{ name: 'file', help: 'Answer text file path' },
|
|
17
|
+
{ name: 'execute', type: 'boolean', help: 'Actually perform the write action' },
|
|
18
|
+
],
|
|
19
|
+
columns: ['status', 'outcome', 'message', 'target_type', 'target', 'created_target', 'created_url', 'author_identity'],
|
|
20
|
+
func: async (page, kwargs) => {
|
|
21
|
+
if (!page)
|
|
22
|
+
throw new CommandExecutionError('Browser session required for zhihu answer');
|
|
23
|
+
requireExecute(kwargs);
|
|
24
|
+
const rawTarget = String(kwargs.target);
|
|
25
|
+
const target = assertAllowedKinds('answer', parseTarget(rawTarget));
|
|
26
|
+
const questionTarget = target;
|
|
27
|
+
const payload = await resolvePayload(kwargs);
|
|
28
|
+
await page.goto(target.url);
|
|
29
|
+
const authorIdentity = await resolveCurrentUserIdentity(page);
|
|
30
|
+
const entryPath = await page.evaluate(`(() => {
|
|
31
|
+
const currentUserSlug = ${JSON.stringify(authorIdentity)};
|
|
32
|
+
const answerAuthorScopeSelector = ${JSON.stringify(ANSWER_AUTHOR_SCOPE_SELECTOR)};
|
|
33
|
+
const readAnswerAuthorSlug = (node) => {
|
|
34
|
+
const authorScopes = Array.from(node.querySelectorAll(answerAuthorScopeSelector));
|
|
35
|
+
const slugs = Array.from(new Set(authorScopes
|
|
36
|
+
.flatMap((scope) => Array.from(scope.querySelectorAll('a[href^="/people/"]')))
|
|
37
|
+
.map((link) => (link.getAttribute('href') || '').match(/^\\/people\\/([A-Za-z0-9_-]+)/)?.[1] || null)
|
|
38
|
+
.filter(Boolean)));
|
|
39
|
+
return slugs.length === 1 ? slugs[0] : null;
|
|
40
|
+
};
|
|
41
|
+
const restoredDraft = !!document.querySelector('[contenteditable="true"][data-draft-restored], textarea[data-draft-restored]');
|
|
42
|
+
const composerCandidates = Array.from(document.querySelectorAll('[contenteditable="true"], textarea')).map((editor) => {
|
|
43
|
+
const container = editor.closest('form, .AnswerForm, .DraftEditor-root, [data-za-module*="Answer"]') || editor.parentElement;
|
|
44
|
+
const text = 'value' in editor ? editor.value || '' : (editor.textContent || '');
|
|
45
|
+
const submitButton = Array.from((container || document).querySelectorAll('button')).find((node) => /发布|提交/.test(node.textContent || ''));
|
|
46
|
+
const nestedComment = Boolean(container?.closest('[data-comment-id], .CommentItem'));
|
|
47
|
+
return { editor, container, text, submitButton, nestedComment };
|
|
48
|
+
}).filter((candidate) => candidate.container && candidate.submitButton && !candidate.nestedComment);
|
|
49
|
+
const hasExistingAnswerByCurrentUser = Array.from(document.querySelectorAll('[data-zop-question-answer], article')).some((node) => {
|
|
50
|
+
return readAnswerAuthorSlug(node) === currentUserSlug;
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
entryPathSafe: composerCandidates.length === 1
|
|
54
|
+
&& !String(composerCandidates[0].text || '').trim()
|
|
55
|
+
&& !restoredDraft
|
|
56
|
+
&& !hasExistingAnswerByCurrentUser,
|
|
57
|
+
hasExistingAnswerByCurrentUser,
|
|
58
|
+
};
|
|
59
|
+
})()`);
|
|
60
|
+
if (entryPath.hasExistingAnswerByCurrentUser) {
|
|
61
|
+
throw new CliError('ACTION_NOT_AVAILABLE', 'zhihu answer only supports creating a new answer when the current user has not already answered this question');
|
|
62
|
+
}
|
|
63
|
+
if (!entryPath.entryPathSafe) {
|
|
64
|
+
throw new CliError('ACTION_NOT_AVAILABLE', 'Answer editor entry path was not proven side-effect free');
|
|
65
|
+
}
|
|
66
|
+
const editorState = await page.evaluate(`(async () => {
|
|
67
|
+
const composerCandidates = Array.from(document.querySelectorAll('[contenteditable="true"], textarea')).map((editor) => {
|
|
68
|
+
const container = editor.closest('form, .AnswerForm, .DraftEditor-root, [data-za-module*="Answer"]') || editor.parentElement;
|
|
69
|
+
const text = 'value' in editor ? editor.value || '' : (editor.textContent || '');
|
|
70
|
+
const submitButton = Array.from((container || document).querySelectorAll('button')).find((node) => /发布|提交/.test(node.textContent || ''));
|
|
71
|
+
const nestedComment = Boolean(container?.closest('[data-comment-id], .CommentItem'));
|
|
72
|
+
return { editor, container, text, submitButton, nestedComment };
|
|
73
|
+
}).filter((candidate) => candidate.container && candidate.submitButton && !candidate.nestedComment);
|
|
74
|
+
if (composerCandidates.length !== 1) return { editorState: 'unsafe', anonymousMode: 'unknown' };
|
|
75
|
+
const { editor, text } = composerCandidates[0];
|
|
76
|
+
const anonymousLabeledControl =
|
|
77
|
+
(composerCandidates[0].container && composerCandidates[0].container.querySelector('[aria-label*="匿名"], [title*="匿名"]'))
|
|
78
|
+
|| Array.from((composerCandidates[0].container || document).querySelectorAll('label, button, [role="switch"], [role="checkbox"]')).find((node) => /匿名/.test(node.textContent || ''))
|
|
79
|
+
|| null;
|
|
80
|
+
const anonymousToggle =
|
|
81
|
+
anonymousLabeledControl?.matches?.('input[type="checkbox"], [role="switch"], [role="checkbox"], button')
|
|
82
|
+
? anonymousLabeledControl
|
|
83
|
+
: anonymousLabeledControl?.querySelector?.('input[type="checkbox"], [role="switch"], [role="checkbox"], button')
|
|
84
|
+
|| null;
|
|
85
|
+
let anonymousMode = 'unknown';
|
|
86
|
+
if (anonymousToggle) {
|
|
87
|
+
const ariaChecked = anonymousToggle.getAttribute && anonymousToggle.getAttribute('aria-checked');
|
|
88
|
+
const checked = 'checked' in anonymousToggle ? anonymousToggle.checked === true : false;
|
|
89
|
+
if (ariaChecked === 'true' || checked) anonymousMode = 'on';
|
|
90
|
+
else if (ariaChecked === 'false' || ('checked' in anonymousToggle && anonymousToggle.checked === false)) anonymousMode = 'off';
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
editorState: editor && !text.trim() ? 'fresh_empty' : 'unsafe',
|
|
94
|
+
anonymousMode,
|
|
95
|
+
};
|
|
96
|
+
})()`);
|
|
97
|
+
if (editorState.editorState !== 'fresh_empty') {
|
|
98
|
+
throw new CliError('ACTION_NOT_AVAILABLE', 'Answer editor was not fresh and empty');
|
|
99
|
+
}
|
|
100
|
+
if (editorState.anonymousMode !== 'off') {
|
|
101
|
+
throw new CliError('ACTION_NOT_AVAILABLE', 'Anonymous answer mode could not be proven off for zhihu answer');
|
|
102
|
+
}
|
|
103
|
+
const editorCheck = await page.evaluate(`(async () => {
|
|
104
|
+
const textToInsert = ${JSON.stringify(payload)};
|
|
105
|
+
const composerCandidates = Array.from(document.querySelectorAll('[contenteditable="true"], textarea')).map((editor) => {
|
|
106
|
+
const container = editor.closest('form, .AnswerForm, .DraftEditor-root, [data-za-module*="Answer"]') || editor.parentElement;
|
|
107
|
+
const submitButton = Array.from((container || document).querySelectorAll('button')).find((node) => /发布|提交/.test(node.textContent || ''));
|
|
108
|
+
const nestedComment = Boolean(container?.closest('[data-comment-id], .CommentItem'));
|
|
109
|
+
return { editor, container, submitButton, nestedComment };
|
|
110
|
+
}).filter((candidate) => candidate.container && candidate.submitButton && !candidate.nestedComment);
|
|
111
|
+
if (composerCandidates.length !== 1) return { editorContent: '', bodyMatches: false };
|
|
112
|
+
const { editor } = composerCandidates[0];
|
|
113
|
+
editor.focus();
|
|
114
|
+
if ('value' in editor) {
|
|
115
|
+
editor.value = '';
|
|
116
|
+
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
117
|
+
editor.value = textToInsert;
|
|
118
|
+
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
119
|
+
} else {
|
|
120
|
+
editor.textContent = '';
|
|
121
|
+
document.execCommand('insertText', false, textToInsert);
|
|
122
|
+
editor.dispatchEvent(new InputEvent('input', { bubbles: true, data: textToInsert, inputType: 'insertText' }));
|
|
123
|
+
}
|
|
124
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
125
|
+
const content = 'value' in editor ? editor.value : (editor.textContent || '');
|
|
126
|
+
return { editorContent: content, bodyMatches: content === textToInsert };
|
|
127
|
+
})()`);
|
|
128
|
+
if (editorCheck.editorContent !== payload || !editorCheck.bodyMatches) {
|
|
129
|
+
throw new CliError('OUTCOME_UNKNOWN', 'Answer editor content did not exactly match the requested payload before publish');
|
|
130
|
+
}
|
|
131
|
+
const proof = await page.evaluate(`(async () => {
|
|
132
|
+
const normalize = (value) => value.replace(/\\s+/g, ' ').trim();
|
|
133
|
+
const answerAuthorScopeSelector = ${JSON.stringify(ANSWER_AUTHOR_SCOPE_SELECTOR)};
|
|
134
|
+
const readAnswerAuthorSlug = (node) => {
|
|
135
|
+
const authorScopes = Array.from(node.querySelectorAll(answerAuthorScopeSelector));
|
|
136
|
+
const slugs = Array.from(new Set(authorScopes
|
|
137
|
+
.flatMap((scope) => Array.from(scope.querySelectorAll('a[href^="/people/"]')))
|
|
138
|
+
.map((link) => (link.getAttribute('href') || '').match(/^\\/people\\/([A-Za-z0-9_-]+)/)?.[1] || null)
|
|
139
|
+
.filter(Boolean)));
|
|
140
|
+
return slugs.length === 1 ? slugs[0] : null;
|
|
141
|
+
};
|
|
142
|
+
const composerCandidates = Array.from(document.querySelectorAll('[contenteditable="true"], textarea')).map((editor) => {
|
|
143
|
+
const container = editor.closest('form, [role="dialog"], .AnswerForm, .DraftEditor-root, [data-za-module*="Answer"]') || editor.parentElement;
|
|
144
|
+
const submitButton = Array.from((container || document).querySelectorAll('button')).find((node) => /发布|提交/.test(node.textContent || ''));
|
|
145
|
+
const nestedComment = Boolean(container?.closest('[data-comment-id], .CommentItem'));
|
|
146
|
+
return { editor, container, submitButton, nestedComment };
|
|
147
|
+
}).filter((candidate) => candidate.container && candidate.submitButton && !candidate.nestedComment);
|
|
148
|
+
if (composerCandidates.length !== 1) return { createdTarget: null, createdUrl: null, authorIdentity: null, bodyMatches: false };
|
|
149
|
+
const submitScope = composerCandidates[0].container || document;
|
|
150
|
+
const submit = Array.from(submitScope.querySelectorAll('button')).find((node) => /发布|提交/.test(node.textContent || ''));
|
|
151
|
+
submit && submit.click();
|
|
152
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
153
|
+
const href = location.href;
|
|
154
|
+
const match = href.match(/question\\/(\\d+)\\/answer\\/(\\d+)/);
|
|
155
|
+
const targetHref = match ? '/question/' + match[1] + '/answer/' + match[2] : null;
|
|
156
|
+
const answerContainer = targetHref
|
|
157
|
+
? Array.from(document.querySelectorAll('[data-zop-question-answer], article')).find((node) => {
|
|
158
|
+
const dataAnswerId = node.getAttribute('data-answerid') || node.getAttribute('data-zop-question-answer') || '';
|
|
159
|
+
if (dataAnswerId && dataAnswerId.includes(match[2])) return true;
|
|
160
|
+
return Array.from(node.querySelectorAll('a[href*="/answer/"]')).some((link) => {
|
|
161
|
+
const hrefValue = link.getAttribute('href') || '';
|
|
162
|
+
return hrefValue.includes(targetHref);
|
|
163
|
+
});
|
|
164
|
+
})
|
|
165
|
+
: null;
|
|
166
|
+
const authorSlug = answerContainer ? readAnswerAuthorSlug(answerContainer) : null;
|
|
167
|
+
const bodyNode =
|
|
168
|
+
answerContainer?.querySelector('[itemprop="text"]')
|
|
169
|
+
|| answerContainer?.querySelector('.RichContent-inner')
|
|
170
|
+
|| answerContainer?.querySelector('.RichText')
|
|
171
|
+
|| answerContainer;
|
|
172
|
+
const bodyText = normalize(bodyNode?.textContent || '');
|
|
173
|
+
return match
|
|
174
|
+
? {
|
|
175
|
+
createdTarget: 'answer:' + match[1] + ':' + match[2],
|
|
176
|
+
createdUrl: href,
|
|
177
|
+
authorIdentity: authorSlug,
|
|
178
|
+
bodyMatches: bodyText === normalize(${JSON.stringify(payload)}),
|
|
179
|
+
}
|
|
180
|
+
: { createdTarget: null, createdUrl: null, authorIdentity: authorSlug, bodyMatches: false };
|
|
181
|
+
})()`);
|
|
182
|
+
if (proof.authorIdentity !== authorIdentity) {
|
|
183
|
+
throw new CliError('OUTCOME_UNKNOWN', 'Answer was created but authorship could not be proven for the frozen current user');
|
|
184
|
+
}
|
|
185
|
+
if (!proof.createdTarget || !proof.bodyMatches || proof.createdTarget.split(':')[1] !== questionTarget.id) {
|
|
186
|
+
throw new CliError('OUTCOME_UNKNOWN', 'Created answer proof did not match the requested question or payload');
|
|
187
|
+
}
|
|
188
|
+
return buildResultRow(`Answered question ${questionTarget.id}`, target.kind, rawTarget, 'created', {
|
|
189
|
+
created_target: proof.createdTarget,
|
|
190
|
+
created_url: proof.createdUrl,
|
|
191
|
+
author_identity: authorIdentity,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './answer.js';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { getRegistry } from '@jackwener/opencli/registry';
|
|
3
|
+
import './answer.js';
|
|
4
|
+
describe('zhihu answer', () => {
|
|
5
|
+
it('rejects create mode when the current user already answered the question', async () => {
|
|
6
|
+
const cmd = getRegistry().get('zhihu/answer');
|
|
7
|
+
expect(cmd?.func).toBeTypeOf('function');
|
|
8
|
+
const page = {
|
|
9
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
evaluate: vi.fn()
|
|
11
|
+
.mockResolvedValueOnce({ slug: 'alice' })
|
|
12
|
+
.mockResolvedValueOnce({ entryPathSafe: false, hasExistingAnswerByCurrentUser: true }),
|
|
13
|
+
};
|
|
14
|
+
await expect(cmd.func(page, { target: 'question:1', text: 'hello', execute: true })).rejects.toMatchObject({ code: 'ACTION_NOT_AVAILABLE' });
|
|
15
|
+
});
|
|
16
|
+
it('rejects anonymous mode instead of toggling it', async () => {
|
|
17
|
+
const cmd = getRegistry().get('zhihu/answer');
|
|
18
|
+
const page = {
|
|
19
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
20
|
+
evaluate: vi.fn()
|
|
21
|
+
.mockResolvedValueOnce({ slug: 'alice' })
|
|
22
|
+
.mockResolvedValueOnce({ entryPathSafe: true, hasExistingAnswerByCurrentUser: false })
|
|
23
|
+
.mockResolvedValueOnce({ editorState: 'fresh_empty', anonymousMode: 'on' }),
|
|
24
|
+
};
|
|
25
|
+
await expect(cmd.func(page, { target: 'question:1', text: 'hello', execute: true })).rejects.toMatchObject({ code: 'ACTION_NOT_AVAILABLE' });
|
|
26
|
+
});
|
|
27
|
+
it('rejects when a unique safe answer composer cannot be proven', async () => {
|
|
28
|
+
const cmd = getRegistry().get('zhihu/answer');
|
|
29
|
+
const page = {
|
|
30
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
31
|
+
evaluate: vi.fn()
|
|
32
|
+
.mockResolvedValueOnce({ slug: 'alice' })
|
|
33
|
+
.mockResolvedValueOnce({ entryPathSafe: false, hasExistingAnswerByCurrentUser: false }),
|
|
34
|
+
};
|
|
35
|
+
await expect(cmd.func(page, { target: 'question:1', text: 'hello', execute: true })).rejects.toMatchObject({ code: 'ACTION_NOT_AVAILABLE' });
|
|
36
|
+
});
|
|
37
|
+
it('rejects when anonymous mode cannot be proven off', async () => {
|
|
38
|
+
const cmd = getRegistry().get('zhihu/answer');
|
|
39
|
+
const page = {
|
|
40
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
41
|
+
evaluate: vi.fn()
|
|
42
|
+
.mockResolvedValueOnce({ slug: 'alice' })
|
|
43
|
+
.mockResolvedValueOnce({ entryPathSafe: true, hasExistingAnswerByCurrentUser: false })
|
|
44
|
+
.mockResolvedValueOnce({ editorState: 'fresh_empty', anonymousMode: 'unknown' }),
|
|
45
|
+
};
|
|
46
|
+
await expect(cmd.func(page, { target: 'question:1', text: 'hello', execute: true })).rejects.toMatchObject({ code: 'ACTION_NOT_AVAILABLE' });
|
|
47
|
+
});
|
|
48
|
+
it('requires a side-effect-free entry path and exact editor content before publish', async () => {
|
|
49
|
+
const cmd = getRegistry().get('zhihu/answer');
|
|
50
|
+
const page = {
|
|
51
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
52
|
+
evaluate: vi.fn()
|
|
53
|
+
.mockResolvedValueOnce({ slug: 'alice' })
|
|
54
|
+
.mockResolvedValueOnce({ entryPathSafe: true })
|
|
55
|
+
.mockResolvedValueOnce({ editorState: 'fresh_empty', anonymousMode: 'off' })
|
|
56
|
+
.mockResolvedValueOnce({ editorContent: 'hello', bodyMatches: true })
|
|
57
|
+
.mockResolvedValueOnce({
|
|
58
|
+
createdTarget: 'answer:1:2',
|
|
59
|
+
createdUrl: 'https://www.zhihu.com/question/1/answer/2',
|
|
60
|
+
authorIdentity: 'alice',
|
|
61
|
+
bodyMatches: true,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
await expect(cmd.func(page, { target: 'question:1', text: 'hello', execute: true })).resolves.toEqual([
|
|
65
|
+
expect.objectContaining({
|
|
66
|
+
outcome: 'created',
|
|
67
|
+
created_target: 'answer:1:2',
|
|
68
|
+
created_url: 'https://www.zhihu.com/question/1/answer/2',
|
|
69
|
+
author_identity: 'alice',
|
|
70
|
+
}),
|
|
71
|
+
]);
|
|
72
|
+
expect(page.evaluate.mock.calls[1][0]).toContain('composerCandidates.length === 1');
|
|
73
|
+
expect(page.evaluate.mock.calls[1][0]).not.toContain('writeAnswerButton');
|
|
74
|
+
expect(page.evaluate.mock.calls[1][0]).toContain('const readAnswerAuthorSlug = (node) =>');
|
|
75
|
+
expect(page.evaluate.mock.calls[1][0]).toContain('const answerAuthorScopeSelector = ".AuthorInfo, .AnswerItem-authorInfo, .ContentItem-meta, [itemprop=\\"author\\"]"');
|
|
76
|
+
expect(page.evaluate.mock.calls[1][0]).not.toContain("node.querySelector('a[href^=\"/people/\"]')");
|
|
77
|
+
expect(page.evaluate.mock.calls[3][0]).toContain('composerCandidates.length !== 1');
|
|
78
|
+
expect(page.evaluate.mock.calls[4][0]).toContain('const readAnswerAuthorSlug = (node) =>');
|
|
79
|
+
expect(page.evaluate.mock.calls[4][0]).not.toContain("answerContainer?.querySelector('a[href^=\"/people/\"]')");
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|