diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..00a9d7e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,79 @@ +--- +name: Bug 反馈 +about: 运行js脚本时出现bug +title: '' +labels: '' +assignees: '' + +--- + + + + + + + + + + + + +## 1.关于你要提交的问题 + +Q:是否搜索了issue(包括已关闭的issue) +- [ ] 没有类似的issue + +Q:是否仔细阅读了教程 +- [ ] 已仔细阅读教程 + +## 2. 你使用的哪种部署方法 + + + + + + +- [ ] 方法一:本地安装Node.js +- [ ] 方法二:腾讯云函数 +- [ ] 方法三:Docker办法一 +- [ ] 方法三:Docker办法二 +- [ ] 方法三:Docker办法三 +- [ ] 方法四:iOS系统的代理软件 + + +## 3. 详细叙述 +### (1) 具体问题 +A: + +### (2) 详细日志 +A: + + + + + +## 4.软件版本和 npm install 结果 +### (1) Node.js版本 + +A: + +### (2) npm版本 + +A: + +### (3)npm install的日志 + +A: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..d741913 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,44 @@ +--- +name: 功能建议 +about: 请求实现新功能或改进已有功能 +title: '' +labels: '' +assignees: '' + +--- + + + + + + + + + + + + +## 期望增加的功能 + +A: + + + + + +## 入口 + +A: diff --git a/.github/pull.yml b/.github/pull.yml deleted file mode 100644 index bbadc61..0000000 --- a/.github/pull.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: "1" -rules: # Array of rules - - base: master # Required. Target branch - upstream: lxk0301:master # Required. Must be in the same fork network. - mergeMethod: hardreset # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. - mergeUnstable: true # Optional, merge pull request even when the mergeable_state is not clean. Default: false diff --git a/.github/workflows/deploy_tencent_scf.yml b/.github/workflows/deploy_tencent_scf.yml new file mode 100644 index 0000000..245675f --- /dev/null +++ b/.github/workflows/deploy_tencent_scf.yml @@ -0,0 +1,116 @@ +name: 部署到腾讯云函数 + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + if: github.event.repository.owner.id == github.event.sender.id + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + repository: ${{ github.repository }} + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: "安装依赖和serverless工具" + run: | + npm install + sudo npm install serverless -g + + - name: "将Secrets里面配置的变量添加到severless.yml里面作为环境变量" + run: | + if [ $JD_COOKIE ]; then sed -i "/variables/a\ JD_COOKIE: $JD_COOKIE" serverless.yml; fi; + if [ $JD_USER_AGENT ]; then sed -i "/variables/a\ JD_USER_AGENT: $JD_USER_AGENT" serverless.yml; fi; + if [ $JD_BEAN_STOP ]; then sed -i "/variables/a\ JD_BEAN_STOP: $JD_BEAN_STOP" serverless.yml; fi; + if [ $JD_BEAN_SIGN_STOP_NOTIFY ]; then sed -i "/variables/a\ JD_BEAN_SIGN_STOP_NOTIFY: $JD_BEAN_SIGN_STOP_NOTIFY" serverless.yml; fi; + if [ $JD_BEAN_SIGN_NOTIFY_SIMPLE ]; then sed -i "/variables/a\ JD_BEAN_SIGN_NOTIFY_SIMPLE: $JD_BEAN_SIGN_NOTIFY_SIMPLE" serverless.yml; fi; + if [ $PUSH_KEY ]; then sed -i "/variables/a\ PUSH_KEY: $PUSH_KEY" serverless.yml; fi; + if [ $BARK_PUSH ]; then sed -i "/variables/a\ BARK_PUSH: $BARK_PUSH" serverless.yml; fi; + if [ $BARK_SOUND ]; then sed -i "/variables/a\ BARK_SOUND: $BARK_SOUND" serverless.yml; fi; + if [ $TG_BOT_TOKEN ]; then sed -i "/variables/a\ TG_BOT_TOKEN: $TG_BOT_TOKEN" serverless.yml; fi; + if [ $TG_USER_ID ]; then sed -i "/variables/a\ TG_USER_ID: $TG_USER_ID" serverless.yml; fi; + if [ $DD_BOT_TOKEN ]; then sed -i "/variables/a\ DD_BOT_TOKEN: $DD_BOT_TOKEN" serverless.yml; fi; + if [ $DD_BOT_SECRET ]; then sed -i "/variables/a\ DD_BOT_SECRET: $DD_BOT_SECRET" serverless.yml; fi; + if [ $IGOT_PUSH_KEY ]; then sed -i "/variables/a\ IGOT_PUSH_KEY: $IGOT_PUSH_KEY" serverless.yml; fi; + if [ $PET_NOTIFY_CONTROL ]; then sed -i "/variables/a\ PET_NOTIFY_CONTROL: $PET_NOTIFY_CONTROL" serverless.yml; fi; + if [ $FRUIT_NOTIFY_CONTROL ]; then sed -i "/variables/a\ FRUIT_NOTIFY_CONTROL: $FRUIT_NOTIFY_CONTROL" serverless.yml; fi; + if [ $JD_JOY_REWARD_NOTIFY ]; then sed -i "/variables/a\ JD_JOY_REWARD_NOTIFY: $JD_JOY_REWARD_NOTIFY" serverless.yml; fi; + if [ $JD_818_SHAREID_NOTIFY ]; then sed -i "/variables/a\ JD_818_SHAREID_NOTIFY: $JD_818_SHAREID_NOTIFY" serverless.yml; fi; + if [ $JOY_FEED_COUNT ]; then sed -i "/variables/a\ JOY_FEED_COUNT: $JOY_FEED_COUNT" serverless.yml; fi; + if [ $JOY_HELP_FEED ]; then sed -i "/variables/a\ JOY_HELP_FEED: $JOY_HELP_FEED" serverless.yml; fi; + if [ $JOY_RUN_FLAG ]; then sed -i "/variables/a\ JOY_RUN_FLAG: $JOY_RUN_FLAG" serverless.yml; fi; + if [ $JOY_TEAM_LEVEL ]; then sed -i "/variables/a\ JOY_TEAM_LEVEL: $JOY_TEAM_LEVEL" serverless.yml; fi; + if [ $JD_JOY_REWARD_NAME ]; then sed -i "/variables/a\ JD_JOY_REWARD_NAME: $JD_JOY_REWARD_NAME" serverless.yml; fi; + if [ $MARKET_COIN_TO_BEANS ]; then sed -i "/variables/a\ MARKET_COIN_TO_BEANS: $MARKET_COIN_TO_BEANS" serverless.yml; fi; + if [ $MARKET_REWARD_NOTIFY ]; then sed -i "/variables/a\ MARKET_REWARD_NOTIFY: $MARKET_REWARD_NOTIFY" serverless.yml; fi; + if [ $SUPERMARKET_UPGRADE ]; then sed -i "/variables/a\ SUPERMARKET_UPGRADE: $SUPERMARKET_UPGRADE" serverless.yml; fi; + if [ $BUSINESS_CIRCLE_JUMP ]; then sed -i "/variables/a\ BUSINESS_CIRCLE_JUMP: $BUSINESS_CIRCLE_JUMP" serverless.yml; fi; + if [ $SUPERMARKET_LOTTERY ]; then sed -i "/variables/a\ SUPERMARKET_LOTTERY: $SUPERMARKET_LOTTERY" serverless.yml; fi; + if [ $FRUIT_BEAN_CARD ]; then sed -i "/variables/a\ FRUIT_BEAN_CARD: $FRUIT_BEAN_CARD" serverless.yml; fi; + if [ $UN_SUBSCRIBES ]; then sed -i "/variables/a\ UN_SUBSCRIBES: $UN_SUBSCRIBES" serverless.yml; fi; + if [ $FRUITSHARECODES ]; then sed -i "/variables/a\ FRUITSHARECODES: $FRUITSHARECODES" serverless.yml; fi; + if [ $PETSHARECODES ]; then sed -i "/variables/a\ PETSHARECODES: $PETSHARECODES" serverless.yml; fi; + if [ $PLANT_BEAN_SHARECODES ]; then sed -i "/variables/a\ PLANT_BEAN_SHARECODES: $PLANT_BEAN_SHARECODES" serverless.yml; fi; + if [ $SUPERMARKET_SHARECODES ]; then sed -i "/variables/a\ SUPERMARKET_SHARECODES: $SUPERMARKET_SHARECODES" serverless.yml; fi; + if [ $DDFACTORY_SHARECODES ]; then sed -i "/variables/a\ DDFACTORY_SHARECODES: $DDFACTORY_SHARECODES" serverless.yml; fi; + if [ $DREAM_FACTORY_SHARE_CODES ]; then sed -i "/variables/a\ DREAM_FACTORY_SHARE_CODES: $DREAM_FACTORY_SHARE_CODES" serverless.yml; fi; + if [ $TG_PROXY_HOST ]; then sed -i "/variables/a\ TG_PROXY_HOST: $TG_PROXY_HOST" serverless.yml; fi; + if [ $TG_PROXY_PORT ]; then sed -i "/variables/a\ TG_PROXY_PORT: $TG_PROXY_PORT" serverless.yml; fi; + if [ $MONEY_TREE_SELL_FRUIT ]; then sed -i "/variables/a\ MONEY_TREE_SELL_FRUIT: $MONEY_TREE_SELL_FRUIT" serverless.yml; fi; + if [ $FACTORAY_WANTPRODUCT_NAME ]; then sed -i "/variables/a\ FACTORAY_WANTPRODUCT_NAME: $FACTORAY_WANTPRODUCT_NAME" serverless.yml; fi; + cat serverless.yml + env + env: #因为直接读取secrets里面的值很多字符不会自动转译,导致写入serverless.yml异常,所以设置到环境变量,在读取环境变量转译过的值 + JD_COOKIE: ${{ secrets.JD_COOKIE}} + JD_USER_AGENT: ${{ secrets.JD_USER_AGENT}} + JD_BEAN_STOP: ${{ secrets.JD_BEAN_STOP}} + JD_BEAN_SIGN_STOP_NOTIFY: ${{ secrets.JD_BEAN_SIGN_STOP_NOTIFY}} + JD_BEAN_SIGN_NOTIFY_SIMPLE: ${{ secrets.JD_BEAN_SIGN_NOTIFY_SIMPLE}} + PUSH_KEY: ${{ secrets.PUSH_KEY}} + BARK_PUSH: ${{ secrets.BARK_PUSH}} + BARK_SOUND: ${{ secrets.BARK_SOUND}} + TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN}} + TG_USER_ID: ${{ secrets.TG_USER_ID}} + DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN}} + DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET}} + IGOT_PUSH_KEY: ${{ secrets.IGOT_PUSH_KEY}} + PET_NOTIFY_CONTROL: ${{ secrets.PET_NOTIFY_CONTROL}} + FRUIT_NOTIFY_CONTROL: ${{ secrets.FRUIT_NOTIFY_CONTROL}} + JD_JOY_REWARD_NOTIFY: ${{ secrets.JD_JOY_REWARD_NOTIFY}} + JD_818_SHAREID_NOTIFY: ${{ secrets.JD_818_SHAREID_NOTIFY}} + JOY_FEED_COUNT: ${{ secrets.JOY_FEED_COUNT}} + JOY_HELP_FEED: ${{ secrets.JOY_HELP_FEED}} + JOY_RUN_FLAG: ${{ secrets.JOY_RUN_FLAG}} + JOY_TEAM_LEVEL: ${{ secrets.JOY_TEAM_LEVEL}} + JD_JOY_REWARD_NAME: ${{ secrets.JD_JOY_REWARD_NAME}} + MARKET_COIN_TO_BEANS: ${{ secrets.MARKET_COIN_TO_BEANS}} + MARKET_REWARD_NOTIFY: ${{ secrets.MARKET_REWARD_NOTIFY}} + SUPERMARKET_UPGRADE: ${{ secrets.SUPERMARKET_UPGRADE}} + BUSINESS_CIRCLE_JUMP: ${{ secrets.BUSINESS_CIRCLE_JUMP}} + SUPERMARKET_LOTTERY: ${{ secrets.SUPERMARKET_LOTTERY}} + FRUIT_BEAN_CARD: ${{ secrets.FRUIT_BEAN_CARD}} + UN_SUBSCRIBES: ${{ secrets.UN_SUBSCRIBES}} + FRUITSHARECODES: ${{ secrets.FRUITSHARECODES}} + PETSHARECODES: ${{ secrets.PETSHARECODES}} + PLANT_BEAN_SHARECODES: ${{ secrets.PLANT_BEAN_SHARECODES}} + SUPERMARKET_SHARECODES: ${{ secrets.SUPERMARKET_SHARECODES}} + DDFACTORY_SHARECODES: ${{ secrets.DDFACTORY_SHARECODES}} + DREAM_FACTORY_SHARE_CODES: ${{ secrets.DREAM_FACTORY_SHARE_CODES}} + TG_PROXY_HOST: ${{ secrets.TG_PROXY_HOST}} + TG_PROXY_PORT: ${{ secrets.TG_PROXY_PORT}} + MONEY_TREE_SELL_FRUIT: ${{ secrets.MONEY_TREE_SELL_FRUIT}} + FACTORAY_WANTPRODUCT_NAME: ${{ secrets.FACTORAY_WANTPRODUCT_NAME}} + + - name: "部署到腾讯云函数" + run: serverless deploy + env: + STAGE: dev + SERVERLESS_PLATFORM_VENDOR: tencent + TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} + TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }} diff --git a/.gitignore b/.gitignore index a8ffa8b..3b50818 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /node_modules/ /.idea -/index.js /.history /box.dat /CookieSet.json +/jdCookie.js diff --git a/JD_extra_cookie.js b/JD_extra_cookie.js index 10fbcae..f1eed49 100644 --- a/JD_extra_cookie.js +++ b/JD_extra_cookie.js @@ -3,7 +3,7 @@ Author: 2Ya -Github: https://github.com/domping +Github: https://github.com/dompling =================== 特别说明: diff --git a/Loon/lxk0301_LoonTask.conf b/Loon/lxk0301_LoonTask.conf index 678fa1f..b3d8a57 100644 --- a/Loon/lxk0301_LoonTask.conf +++ b/Loon/lxk0301_LoonTask.conf @@ -60,24 +60,42 @@ cron "1 1 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script #京豆变动通知 cron "2 9 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.js, tag=京豆变动通知 +#点点券 +cron "20 0,20 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js, tag=点点券 + +#十元街 +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, tag=十元街 + +#东东小窝 +cron "16 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, tag=东东小窝 + +#京喜工厂 +cron "26 * * * *" script-path= https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js, tag=京喜工厂 + +#东东工厂 +cron "10 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js,tag=东东工厂 + + #京东全民营业领金币 cron "20 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_collectProduceScore.js, tag=京东全民营业领金币 #宠汪汪邀请助力与赛跑助力 cron "15 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, tag=宠汪汪邀请助力与赛跑助力 -#宠汪汪助力更新Token -http-response ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/api\/user\/addUser\?code=\w+& script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力更新Token - -#宠汪汪助力获取Token -http-request ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/api\/user\/user\/detail\?openId=\w+& script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力获取Token - -# 宠汪汪强制为别人助力 -http-request ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js, requires-body=true, timeout=10, tag=宠汪汪强制为别人助力 - -#聚宝盆投狗粮辅助(github@Zero-S1搬的) -http-response ^https:\/\/jdjoy\.jd\.com\/pet\/getPetTreasureBox|^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/getPetTreasureBox script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_petTreasureBox.js, requires-body=true, timeout=10, tag=聚宝盆投狗粮辅助 - #小米运动 cron "25 17 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/xmSports.js, tag=小米运动 + +#宠汪汪助力更新Token +http-response ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力更新Token + +#宠汪汪助力获取Token +http-request ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力获取Token + +# 宠汪汪强制为别人助力 +http-request ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js, requires-body=true, timeout=10, tag=宠汪汪强制为别人助力 + +#聚宝盆投狗粮辅助(github@Zero-S1搬的) +http-response ^https:\/\/jdjoy\.jd\.com\/pet\/getPetTreasureBox|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/getPetTreasureBox script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_petTreasureBox.js, requires-body=true, timeout=10, tag=聚宝盆投狗粮辅助 + +# 小米运动获取Token http-response ^https:\/\/account\.huami\.com\/v2\/client\/login script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/xmSports.js, requires-body=true, timeout=10, tag=小米运动获取Token \ No newline at end of file diff --git a/README.md b/README.md index ab39d7b..3fa86f5 100644 --- a/README.md +++ b/README.md @@ -34,38 +34,57 @@ 11. 宠汪汪赛跑助力([jd_joy_run.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js)) 12. 宠汪汪聚宝盆辅助脚本([jd_petTreasureBox.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_petTreasureBox.js)) 13. 取关京东店铺和商品([jd_unsubscribe.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js)) -14. 京小超([jd_superMarket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js)) -15. 京小超兑换奖品([jd_blueCoin.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js)) +14. 东东超市([jd_superMarket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js)) +15. 东东超市兑换奖品([jd_blueCoin.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js)) 16. 进店领豆([jd_shop.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_shop.js)) 17. 摇京豆([jd_club_lottery.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_club_lottery.js)) 18. 全名开红包([jd_redPacket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_redPacket.js)) -19. 京东多合一签到([jd_bean_sign.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_sign.js)) 【可N个京东账号,Node.js专用,核心脚本是JD_DailyBonus.js, IOS软件用户请使用NobyDa的 [JD_DailyBonus.js](https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js) 】 +19. 京东多合一签到([jd_bean_sign.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_sign.js)) 【可N个京东账号,Node.js专用,核心脚本是JD_DailyBonus.js,iOS软件用户请使用NobyDa的 [JD_DailyBonus.js](https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js) 】 20. 京豆变动通知([jd_bean_change.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.js)) -21. 以及其他一部分在特定时间可用的薅京豆脚本,如 [手机狂欢城](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_818.js) 、[星推官](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_xtg.js) 等。 +21. 京喜工厂([jd_dreamFactory.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js)) +22. 东东小窝([jd_small_home.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js)) +23. 东东工厂([jd_jdfactory.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js)) +24. 点点券([jd_necklace.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js)) +25. 十元街([jd_syj.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js)) +26. 京东金融-天天提鹅([jd_daily_egg.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_daily_egg.js)) +27. 京东金融-养猪猪([jd_pigPet.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pigPet.js)) +28. 以及其他一部分在特定时间可用的薅京豆脚本:[手机狂欢城](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_818.js) 、[星推官](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_xtg.js) 、[双十一活动领金币](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_collectProduceScore.js) 、[热8超级盲盒](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_mohe.js) +29. Webhook触发Action([webhook.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/webhook.js)) + +搬运脚本 +1. 【[@yangtingxiao](https://github.com/yangtingxiao)】京东抽奖机([jd_lotteryMachine.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_lotteryMachine.js)) +2. 【[@yangtingxiao](https://github.com/yangtingxiao)】京东排行榜([jd_rankingList.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_rankingList.js)) **脚本兼容: [QuantumultX](https://apps.apple.com/us/app/quantumult-x/id1443988620), [Surge](https://apps.apple.com/us/app/surge-4/id1442620678), [Loon](https://apps.apple.com/us/app/loon/id1373567447), 小火箭, JSBox, Node.js** **TODO** -- [x] 完善京小超脚本[jd_superMarket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js) -- [x] 京小超商圈助力功能[jd_superMarket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js) +- [ ] 东东工厂相互助力 +- [ ] 京喜工厂相互助力 ## 食用方法 ### 方法一:本地安装Node.js,下载本库脚本 - - 教程请见:[EvineDeng/jd-base](https://github.com/EvineDeng/jd-base) + - 教程请见:[EvineDeng/jd-base](https://github.com/EvineDeng/jd-base),适用于以下系统: + + 1. Armbian/OpenWrt/Debian/Ubuntu/CentOS/Fedora/RedHat等Linux系统 + + 2. Android + + 3. MacOS ### 方法二:云服务器、腾讯云函数等等 - 需自行有云服务器,云函数等 - - - 腾云云函数使用 [教程说明](iCloud.md) + - 腾讯云云函数 [快速部署教程](tencentscf.md)(免费) + - 腾讯云云函数控制台使用 [教程说明](iCloud.md) + - 腾讯云云函数 [GitHub Action部署教程](tencentscf.md#github-action-部署) ### 方法三:Docker(NAS或VPS用户) - - 可以精确控制任务运行时间,有三种办法:[docker办法一](https://github.com/lxk0301/jd_scripts/tree/master/docker)、[docker办法二(和本地安装Node.js有点类似)](https://github.com/EvineDeng/jd-base)、[docker办法三](https://github.com/chinnkarahoi/jd-scripts-docker) + - 可以精确控制任务运行时间,有二种办法:[docker办法一](https://github.com/lxk0301/jd_scripts/tree/master/docker)、[docker办法二(和本地安装Node.js类似)](https://github.com/EvineDeng/jd-base) - [环境变量](https://github.com/lxk0301/jd_scripts/blob/master/githubAction.md#%E4%B8%8B%E6%96%B9%E6%8F%90%E4%BE%9B%E4%BD%BF%E7%94%A8%E5%88%B0%E7%9A%84-secrets%E5%85%A8%E9%9B%86%E5%90%88) #### 注:以上三种运行机制都是Node.js,故您需仔细阅读下面几点 diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index 2f46768..68fbcc7 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -1,4 +1,4 @@ -#!name=lxk0301 iOS Tasks Module +#!name=lxk0301 iOS Tasks&Cookies Module #!desc=iOS Tasks 模块配置 #!system=ios @@ -29,5 +29,5 @@ cron "15 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scri cron "1 1 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_redPacket.js, wake-system=1, tag=京东全民开红包 # cron "0 0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_xtg.js, timeout=550, wake-system=1, tag=京东星推官 cron "2 9 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.js, timeout=650, wake-system=1, tag=京豆变动通知 +cron "20 0,20 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js, timeout=650, wake-system=1, tag=点点券 # cron "20 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_collectProduceScore.js, wake-system=1, tag=京东全民营业领金币 - diff --git a/backUp/TG_PUSH.md b/backUp/TG_PUSH.md new file mode 100644 index 0000000..4004b29 --- /dev/null +++ b/backUp/TG_PUSH.md @@ -0,0 +1,17 @@ +**TG_PUSH教程** + +利用Telegram机器人推送通知,需要在环境变量填入正确的```TG_BOT_TOKEN```以及```TG_USER_ID```,以下教程简明阐述如何获取token以及UserID + +Ⅰ.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人
+ +![TG_PUSH1](../icon/TG_PUSH1.png) + +Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。填入```TG_BOT_TOKEN```
+ +![TG_PUSH2](../icon/TG_PUSH2.png) + +Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。填入```TG_USER_ID```
+ +![TG_PUSH3](../icon/TG_PUSH3.png) + +至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束 diff --git a/backUp/jd_Goods.js b/backUp/jd_Goods.js new file mode 100644 index 0000000..9c6e2ba --- /dev/null +++ b/backUp/jd_Goods.js @@ -0,0 +1,11 @@ +// 半自动提醒心愿单50京豆。 +// 15 */4 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/jd_Goods.js + +const $ = new Env('心愿单50京豆'); + +$.msg($.name, "领50京豆啦", "https://h5.m.jd.com/babelDiy/Zeus/3mTNcpWt5JYh3aUCyo6gqKuF4pnx/index.html", {"open-url": "openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3mTNcpWt5JYh3aUCyo6gqKuF4pnx/index.html%22%20%7D"}); + +$.done(); + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/backUp/jd_joy_help2.js b/backUp/jd_joy_help2.js index e908adf..67f67bc 100644 --- a/backUp/jd_joy_help2.js +++ b/backUp/jd_joy_help2.js @@ -1,38 +1,9 @@ /** 宠汪汪强制为别人助力(助力一个好友你自己可以获得30积分,一天上限是帮助3个好友,自己获得90积分,不管助力是否成功,对方都会成为你的好友) -更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js -更新时间:2020-08-28 -目前提供了304位好友的friendPin供使用。脚本随机从里面获取一个,助力成功后,退出小程序重新点击进去开始助力新的好友 -欢迎大家使用 https://jdjoy.jd.com/pet/getFriends?itemsPerPage=20¤tPage=1 (currentPage=1表示第一页好友,=2表示第二页好友) -提供各自账号列表的friendPin给我 -如果想设置固定好友,那下载下来放到本地使用,可以修改friendPin换好友(助力一好友后,更换一次friendPin里面的内容) -感谢github @Zero-S1提供 -使用方法: -①设置好相应软件的重写 -②从京东APP宠汪汪->领狗粮->邀请好友助力,分享给你小号微信或者微信的文件传输助手。 自己再打开刚才的分享,助力成功后,退出小程序重新进去刚才分享的小程序即可 -③如提示好友人气旺,说明此好友已满了三人助力,需重新进出小程序,重新进入来客有礼-宠汪汪。 -[MITM] -hostname = draw.jdfcloud.com -surge -[Script] -宠汪汪强制为别人助力= type=http-request,pattern=(^https:\/\/draw\.jdfcloud\.com\/\/pet\/enterRoom\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/\/pet\/helpFriend\?friendPin),requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js - -圈x -[rewrite_local] -^https:\/\/draw\.jdfcloud\.com\/\/pet\/enterRoom\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/\/pet\/helpFriend\?friendPin url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js - - LOON: -[Script] -http-request ^https:\/\/draw\.jdfcloud\.com\/\/pet\/enterRoom\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js -, requires-body=true, timeout=10, tag=宠汪汪强制为别人助力 - - -你也可从下面链接拿好友的friendPin(复制链接到有京东ck的浏览器打开即可) - -https://jdjoy.jd.com/pet/getFriends?itemsPerPage=20¤tPage=1 +自用 **/ let url = $request.url -const friendsArr = ["jd_136833sjn","jd_131335rbv","jd_4f044bdd67a3f","jd_176968gwf","jd_136744uks","jd_139559isq","jd_151698nhe","jd_182775ekl","jd_139643ldl","jd_159166edm","jd_157100apb","jd_131843tvo","jd_152554vhs","jd_134283prpb","jd_139988mgfo","jd_133590dtg","jd_63636969e55cb","jd_135565fsg","jd_189071npd","jd_138430zvw","jd_139582hlp","jd_815411720","jd_157642zjc","jd_177753pzb","jd_137918wwl","jd_188675alaf","jd_186718otu","jd_139139bew","jd_180436ggd","jd_52315d900a88a","jd_137689rjx","jd_151106nxb","jd_153879dzp","jd_185840vwq","jd_6194e9ae2cebf","jd_186221rph","jd_153810ylu","jd_189288egp","jd_158791okv","jd_139132erd","jd_159304acn","jd_138899zum","jd_187182akf","jd_136324bjqi","jd_131616wdo","jd_155384iof","jd_186326vtm","jd_zoezhu","jd_135075ahc","jd_138141ill","jd_139773zbm","jd_158416jwas","jd_182328ujc","jd_135999wrw","jd_181325tmk","jd_188254zgv","jd_3712425","jd_153711hhx","jd_176020ylg","jd_136436iuk","jd_180430yxp","jd_159958jmr","jd_155382wjy","jd_135819ueh","jd_132125ish","jd_181196mrhz","jd_138403wnm","jd_181568lrk","jd_155785zic","jd_150712koi","jd_137012gwu","jd_137638siy","jd_183011sph","jd_158224asm","jd_1652541161","jd_137332lgt","jd_181991fgs","jd_189347opuc","jd_181898rlw","jd_136526chs","jd_152616rsg","jd_151410rti","jd_139657jxa","jd_187978fdq","jd_136039csx","jd_186029urn","jd_138681pjy","jd_138204hpd","jd_138246wgz","jd_131177aol","jd_182100ofj","jd_282335851","jd_180210xwj","jd_139400bou","jd_189751xfv","jd_133781olg","jd_155229qbl","jd_dady_a","jd_183890opj","jd_136830xsh","jd_138731rkth","jd_135476kin","jd_3302023","jd_suns932","jd_158958xju","jd_688050784","jd_177467uaf","jd_138950cao","jd_181726mer","jd_138194nvx","jd_2010wwk","jd_139295gxw","jd_173931eeb","jd_189713iss","jd_139894msf","jd_158767vct","jd_159210nml","jd_133230bpy","jd_150771igh","jd_4c9dced2ff301","jd_133025pjb","jd_184751jlf","jd_139379bhj","jd_4900071","jd_137188nnv","jd_153678kxr","jd_6b04334c27336","jd_185217cfd","jd_155892hhe","jd_gxq721","jd_duqing821","jd_185087idh","jd_181528ojs","jd_136778wigm","jd_137903zfgq","jd_134785qjj","jd_159536nii","jd_188492aqx","jd_152226ypk","jd_183815eio","jd_139250pva","jd_151739nli","jd_135202pbl","jd_138201yhi","jd_137642nzw","jd_136600ysr","jd_138220eom","jd_178595cqf","jd_186682kjk","jd_136205srq","jd_138820xtj","jd_152322tkj","jd_150225ipi","jd_133287tje","jd_guba01","jd_187568qui","jd_158753hfl","jd_159816boe","jd_139297psw","jd_138564ibo","jd_188105wjm","jd_180199ekd","jd_134164zgp","jd_181547miy","jd_137030gdm","jd_183197ekf","jd_155187jhm","jd_158363nbzh","jd_151335bxo","jd_139616ywb","jd_156600kfm","jd_352215391","jd_620475312","jd_137997ole","jd_186060jol","jd_7824770b3d748","jd_6b8ba51989353","jd_152712oax","jd_177413lgq","jd_134172lqw","jd_135035dya","jd_135388arv","jd_135013mbs","jd_150897xln","jd_133827ois","jd_133307ffi","jd_138326tzrx","jd_186639utz","jd_Thin779","jd_137173yni","jd_159843fjq","jd_152590bui","jd_180225wpx","jd_187579piq","jd_156758shb","jd_139960nex","jd_138817fsp","jd_181696mtg","jd_137911aamo","jd_135891nxk","jd_177761izc","jd_153337fyq","jd_114559761","jd_Xsgfsj","jd_139965zpe","jd_185459vvx","jd_189214its","jd_151615dmb","jd_138460bsc","jd_138618yqc","jd_187290mur","jd_151318bht","jd_155344pmg","jd_137302fjz","jd_182505eyw","jd_136416nan","jd_151651ncw","jd_137131dya","jd_133471mru","jd_181116wrh","jd_139819ahg","jd_138219eja","jd_136695iqb","jd_158215wjb","jd_107071797","jd_155664eni","jd_182384yok","jd_139611sco","jd_157652hlh","jd_137036vhs","jd_188476ctf","jd_178651ldby","jd_158107bvn","jd_150342aox","jd_150283rncu","jd_131367qhs","jd_133052bem","jd_189317gau","jd_134186sbh","jd_138637pbp","jd_glwang2","jd_189557iiq","jd_138906xlbm","jd_152360yuk","jd_134551yla","jd_135832apl","jd_155448yab","jd_138388paz","jd_1352513187","jd_135464sqz","jd_153298yxo","jd_139208nicz","jd_136608wyr","jd_133053kbn","jd_135034bbx","jd_2133952","jd_187382exm","jd_135063kvb","jd_130844lme","jd_137295ajrg","jd_136810xds","jd_182771zcmi","jd_qwertag13568370gf","jd_189200fiu","jd_159871grf","jd_q105946","jd_182028tnj","jd_153718opj","jd_136850dhv","jd_159162dxb","jd_155267dkh","jd_152763ghe","jd_137104jyuf","jd_136426poa","jd_153920qlg","jd_159715spj","jd_135772nxy","jd_321051","jd_fanm537","jd_137104vuum","jd_177212uid","jd_150312pgc","jd_152569xgz","jd_136994ddl","jd_186223kew","jd_139779ovt","jd_181193dok","jd_189461sem","jd_138245yum","jd_134136kgip","jd_189543hpt","jd_132180xif","jd_182857oox","jd_186245aal","jd_3555750","jd_188502cqy","jd_186910cwu","jd_182829qbch","jd_182297xcme","jd_159708cng","jd_133330ift","jd_131904zwu","jd_182801xpy","jd_150075wud","jd_156874jup","jd_189964qzl","jd_158132cle","jd_sun723","jd_182176mee","jd_188503acjo","jd_158537jdm","jd_159485zvu","jd_180011ejj","jd_135829xzp","jd_136921jpe","jd_152629pmx","jd_189710eck","jd_189397oeo","jd_189592sul","jd_150576adh","jd_159411rzd","jd_134601izn","jd_180053tsa","jd_138226cmgb","jd_183757gbgp","jd_139289bij","jd_lx_a","jd_138562oek","jd_183691xyg","jd_151429qhv","jd_139804lhb","jd_136042bzg","jd_138102ldq","jd_135986nkf","jd_truman","jd_181700kju","jd_151064dhx","jd_150907ahj","jd_186652jxh","jd_418fef3fab12f","jd_159527gqz","jd_138237dcn","jd_134119thub","jd_wrrr0","jd_180498ozp","jd_138531irs","jd_131136fru","jd_185228tkh","jd_131910jzm","jd_151063mhz","jd_58096918e5234","jd_187187rvl","jd_157537jpe","jd_6cebe25400109","jd_1175189","jd_42a743e0b8651","jd_153063yds","jd_177692lwq","jd_152020gzy","jd_138898puv","jd_155525lpff","jd_151123xea","jd_2672389178","jd_178258cff","jd_158191ansh","jd_153280zoy","jd_hl31450","jd_150416qyl","jd_152315mcm","jd_135648axo","jd_4cfd4439d158f","jd_134815cgd","jd_135087ela","jd_180921pam","jd_135610gth","jd_156973ipc","jd_188112gxw","jd_188110wps","jd_173589vmd","jd_135604ngz","jd_158219erd","jd_158449aru","jd_166312hcv","jd_151360sty","jd_183282vqt","jd_139208bac","jd_139276cex","jd_626010305","jd_158181bbe","jd_134339ytdb","jd_139206mkrh","jd_181579uxd","jd_137015nmi","jd_511064173","jd_182924yvbk","jd_137378axvd","jd_157351ype","jd_135161rmsc","jd_188425wum","jd_135315ofn","jd_131160xix","jd_186339gil","jd_150862gpa","jd_132385iqb","jd_138132znr","jd_384180113","jd_1362103","jd_139409xbn","jd_133146qwv","jd_132661jmj","jd_158676edk","jd_133316lld","jd_188714irz","jd_159103vma","jd_131148pkg","jd_152769boe","jd_138846yad","jd_132036kqj","jd_183813dsf","jd_189617vkq","jd_185715pgz","jd_159905euu","jd_134631ehy","jd_176278mmr","jd_5161d94861016","jd_135466mil","jd_177287yyr","jd_139720epl","jd_132037mat","jd_139830uaz","jd_138988jgl","jd_137222hds","jd_177038fca","jd_137096jyx","jd_189081vhx","jd_189985hzh","jd_151927ufa","jd_135145znf","jd_139306rrn","jd_130650d","jd_134321vtn","jd_151515epa","jd_135137jaia","jd_137164augj","jd_130024lmi","jd_139602byf","jd_183766qfi","jd_139705lek","jd_133834qau","jd_180157euk","jd_139111kud","jd_155116pea","jd_159626fgnc","jd_185154lww","jd_177435tuc","jd_137292pwe","jd_177395xqs","jd_133053jus","jd_151339jhx","jd_135087ljd","jd_53b1c5c35ac9a","jd_qiuche549","jd_158164uel","jd_138107wud","jd_199771clu","jd_186753jcs","jd_187150ylk","jd_138974rxt","jd_103433211","jd_185821hfr","jd_139502ycf","jd_137713uyd","jd_187698feo","jd_136089okg","jd_4352325","jd_139639yoj","jd_979798715","jd_131321aoc","jd_185224kzc","jd_151639rszh","jd_185669lfi","jd_lideguang_2011","jd_138725hyc","jd_qaa011","jd_135928ucx","jd_649f9eae0be6c","jd_155229vlt","jd_139885sgt","jd_136220wqh","jd_130741cki","jd_151611ebv","jd_189756rue","jd_5e95dcfd762f4","jd_6261731","jd_135495gbf","jd_150042iil","jd_137894frb","jd_135873xqmi","jd_138593nkp","jd_175412852","jd_139690dad","jd_43a2e9c6537f8","jd_138175wuk","jd_131716dfh","jd_138556pnn","jd_5020276315","jd_177316iqo","jd_181375rvj","jd_229003983","jd_180789bug","jd_150682yxz","jd_152181wlw","jd_224275759","jd_136102svi","jd_9929897714","jd_139691wvgh","jd_189305xgc","jd_133211nev","jd_138697wdw","jd_189314rid","jd_182520tcmf","jd_184399ypg","jd_156312gqm","jd_183257kbc","jd_8745170","jd_151758sra","jd_136000dfw","jd_138337tbg","jd_xishuwulu","jd_189shijz","jd_182257jvd","jd_156983msp","jd_316882724","jd_135808jxz","jd_135557shtf","jd_233102237","jd_186099qlx","jd_185263tir","jd_406bfe50a3525","jd_180669zge","jd_6402aba2128d9","jd_181335kmh","jd_137378ult","jd_150022yxf","jd_188540les","jd_133774erh","jd_138784rjl","jd_182817gcd","jd_134724ief","jd_132536dsy","jd_136604veq","jd_189715ich","jd_182876ynp","jd_177737trf","jd_186552tmg","jd_152104bbn","jd_136219qpt","jd_138262kmx","jd_176204injl","jd_183772tnk","jd_152150ixc","jd_139291nono","jd_186430qkb","jd_183182ynu","jd_135980gkl","jd_158520qfph","jd_135592ugy","jd_139445whz","jd_151308una","jd_150849jbh","jd_655789303","jd_136906lqt","jd_156206yfx","jd_137619mem","jd_152667dao","jd_138597bto","jd_189315etn","jd_151132kre","jd_239626183","jd_sdwh1","jd_136817uwz","jd_187119rqc","jd_yzztt","jd_157563ywzn","jd_zran012","jd_178280jig","jd_070889622","jd_132865tfs","jd_137098qlp","jd_159314ahj","jd_135530jsi","jd_156985tlp","jd_182109kiy","jd_183501fyv","jd_151668vpv","jd_138155ahi","jd_zwh082","jd_135647kui","jd_139149ipt","jd_186993pyi","jd_159524eku","jd_135392iff","jd_177019dfk","jd_185008kmg","jd_18259236618"]; +const friendsArr = ["jd_136833sjn","jd_131335rbv","jd_4f044bdd67a3f","jd_176968gwf","jd_136744uks","jd_139559isq","jd_151698nhe","jd_182775ekl","jd_139643ldl","jd_159166edm","jd_157100apb","jd_131843tvo","jd_152554vhs","jd_134283prpb","jd_139988mgfo","jd_133590dtg","jd_63636969e55cb","jd_135565fsg","jd_189071npd","jd_138430zvw","jd_139582hlp","jd_815411720","jd_157642zjc","jd_177753pzb","jd_137918wwl","jd_188675alaf","jd_186718otu","jd_139139bew","jd_180436ggd","jd_52315d900a88a","jd_137689rjx","jd_151106nxb","jd_153879dzp","jd_185840vwq","jd_6194e9ae2cebf","jd_186221rph","jd_153810ylu","jd_189288egp","jd_158791okv","jd_139132erd","jd_159304acn","jd_138899zum","jd_187182akf","jd_136324bjqi","jd_131616wdo","jd_155384iof","jd_186326vtm","jd_zoezhu","jd_135075ahc","jd_138141ill","jd_139773zbm","jd_158416jwas","jd_182328ujc","jd_135999wrw","jd_181325tmk","jd_188254zgv","jd_3712425","jd_153711hhx","jd_176020ylg","jd_136436iuk","jd_180430yxp","jd_159958jmr","jd_155382wjy","jd_135819ueh","jd_132125ish","jd_181196mrhz","jd_138403wnm","jd_181568lrk","jd_155785zic","jd_150712koi","jd_137012gwu","jd_137638siy","jd_183011sph","jd_158224asm","jd_1652541161","jd_137332lgt","jd_181991fgs","jd_189347opuc","jd_181898rlw","jd_136526chs","jd_152616rsg","jd_151410rti","jd_139657jxa","jd_187978fdq","jd_136039csx","jd_186029urn","jd_138681pjy","jd_138204hpd","jd_138246wgz","jd_131177aol","jd_182100ofj","jd_282335851","jd_180210xwj","jd_139400bou","jd_189751xfv","jd_133781olg","jd_155229qbl","jd_dady_a","jd_183890opj","jd_136830xsh","jd_138731rkth","jd_135476kin","jd_3302023","jd_suns932","jd_158958xju","jd_688050784","jd_177467uaf","jd_138950cao","jd_181726mer","jd_138194nvx","jd_2010wwk","jd_139295gxw","jd_173931eeb","jd_189713iss","jd_139894msf","jd_158767vct","jd_159210nml","jd_133230bpy","jd_150771igh","jd_4c9dced2ff301","jd_133025pjb","jd_184751jlf","jd_139379bhj","jd_4900071","jd_137188nnv","jd_153678kxr","jd_6b04334c27336","jd_185217cfd","jd_155892hhe","jd_gxq721","jd_duqing821","jd_185087idh","jd_181528ojs","jd_136778wigm","jd_137903zfgq","jd_134785qjj","jd_159536nii","jd_188492aqx","jd_152226ypk","jd_183815eio","jd_139250pva","jd_151739nli","jd_135202pbl","jd_138201yhi","jd_137642nzw","jd_136600ysr","jd_138220eom","jd_178595cqf","jd_186682kjk","jd_136205srq","jd_138820xtj","jd_152322tkj","jd_150225ipi","jd_133287tje","jd_guba01","jd_187568qui","jd_158753hfl","jd_159816boe","jd_139297psw","jd_138564ibo","jd_188105wjm","jd_180199ekd","jd_134164zgp","jd_181547miy","jd_137030gdm","jd_183197ekf","jd_155187jhm","jd_158363nbzh","jd_151335bxo","jd_139616ywb","jd_156600kfm","jd_352215391","jd_620475312","jd_137997ole","jd_186060jol","jd_7824770b3d748","jd_6b8ba51989353","jd_152712oax","jd_177413lgq","jd_134172lqw","jd_135035dya","jd_135388arv","jd_135013mbs","jd_150897xln","jd_133827ois","jd_133307ffi","jd_138326tzrx","jd_186639utz","jd_Thin779","jd_137173yni","jd_159843fjq","jd_152590bui","jd_180225wpx","jd_187579piq","jd_156758shb","jd_139960nex","jd_138817fsp","jd_181696mtg","jd_137911aamo","jd_135891nxk","jd_177761izc","jd_153337fyq","jd_114559761","jd_Xsgfsj","jd_139965zpe","jd_185459vvx","jd_189214its","jd_151615dmb","jd_138460bsc","jd_138618yqc","jd_187290mur","jd_151318bht","jd_155344pmg","jd_137302fjz","jd_182505eyw","jd_136416nan","jd_151651ncw","jd_137131dya","jd_133471mru","jd_181116wrh","jd_139819ahg","jd_138219eja","jd_136695iqb","jd_158215wjb","jd_107071797","jd_155664eni","jd_182384yok","jd_139611sco","jd_157652hlh","jd_137036vhs","jd_188476ctf","jd_178651ldby","jd_158107bvn","jd_150342aox","jd_150283rncu","jd_131367qhs","jd_133052bem","jd_189317gau","jd_134186sbh","jd_138637pbp","jd_glwang2","jd_189557iiq","jd_138906xlbm","jd_152360yuk","jd_134551yla","jd_135832apl","jd_155448yab","jd_138388paz","jd_1352513187","jd_135464sqz","jd_153298yxo","jd_139208nicz","jd_136608wyr","jd_133053kbn","jd_135034bbx","jd_2133952","jd_187382exm","jd_135063kvb","jd_130844lme","jd_137295ajrg","jd_136810xds","jd_182771zcmi","jd_qwertag13568370gf","jd_189200fiu","jd_159871grf","jd_q105946","jd_182028tnj","jd_153718opj","jd_136850dhv","jd_159162dxb","jd_155267dkh","jd_152763ghe","jd_137104jyuf","jd_136426poa","jd_153920qlg","jd_159715spj","jd_135772nxy","jd_321051","jd_fanm537","jd_137104vuum","jd_177212uid","jd_150312pgc","jd_152569xgz","jd_136994ddl","jd_186223kew","jd_139779ovt","jd_181193dok","jd_189461sem","jd_138245yum","jd_134136kgip","jd_189543hpt","jd_132180xif","jd_182857oox","jd_186245aal","jd_3555750","jd_188502cqy","jd_186910cwu","jd_182829qbch","jd_182297xcme","jd_159708cng","jd_133330ift","jd_131904zwu","jd_182801xpy","jd_150075wud","jd_156874jup","jd_189964qzl","jd_158132cle","jd_sun723","jd_182176mee","jd_188503acjo","jd_158537jdm","jd_159485zvu","jd_180011ejj","jd_135829xzp","jd_136921jpe","jd_152629pmx","jd_189710eck","jd_189397oeo","jd_189592sul","jd_150576adh","jd_159411rzd","jd_134601izn","jd_180053tsa","jd_138226cmgb","jd_183757gbgp","jd_139289bij","jd_lx_a","jd_138562oek","jd_183691xyg","jd_151429qhv","jd_139804lhb","jd_136042bzg","jd_138102ldq","jd_135986nkf","jd_truman","jd_181700kju","jd_151064dhx","jd_150907ahj","jd_186652jxh","jd_418fef3fab12f","jd_159527gqz","jd_138237dcn","jd_134119thub","jd_wrrr0","jd_180498ozp","jd_138531irs","jd_131136fru","jd_185228tkh","jd_131910jzm","jd_151063mhz","jd_58096918e5234","jd_187187rvl","jd_157537jpe","jd_6cebe25400109","jd_1175189","jd_42a743e0b8651","jd_153063yds","jd_177692lwq","jd_152020gzy","jd_138898puv","jd_155525lpff","jd_151123xea","jd_2672389178","jd_178258cff","jd_158191ansh","jd_153280zoy","jd_hl31450","jd_150416qyl","jd_152315mcm","jd_135648axo","jd_4cfd4439d158f","jd_134815cgd","jd_135087ela","jd_180921pam","jd_135610gth","jd_156973ipc","jd_188112gxw","jd_188110wps","jd_173589vmd","jd_135604ngz","jd_158219erd","jd_158449aru","jd_166312hcv","jd_151360sty","jd_183282vqt","jd_139208bac","jd_139276cex","jd_626010305","jd_158181bbe","jd_134339ytdb","jd_139206mkrh","jd_181579uxd","jd_137015nmi","jd_511064173","jd_182924yvbk","jd_137378axvd","jd_157351ype","jd_135161rmsc","jd_188425wum","jd_135315ofn","jd_131160xix","jd_186339gil","jd_150862gpa","jd_132385iqb","jd_138132znr","jd_384180113","jd_1362103","jd_139409xbn","jd_133146qwv","jd_132661jmj","jd_158676edk","jd_133316lld","jd_188714irz","jd_159103vma","jd_131148pkg","jd_152769boe","jd_138846yad","jd_132036kqj","jd_183813dsf","jd_189617vkq","jd_185715pgz","jd_159905euu","jd_134631ehy","jd_176278mmr","jd_5161d94861016","jd_135466mil","jd_177287yyr","jd_139720epl","jd_132037mat","jd_139830uaz","jd_138988jgl","jd_137222hds","jd_177038fca","jd_137096jyx","jd_189081vhx","jd_189985hzh","jd_151927ufa","jd_135145znf","jd_139306rrn","jd_130650d","jd_134321vtn","jd_151515epa","jd_135137jaia","jd_137164augj","jd_130024lmi","jd_139602byf","jd_183766qfi","jd_139705lek","jd_133834qau","jd_180157euk","jd_139111kud","jd_155116pea","jd_159626fgnc","jd_185154lww","jd_177435tuc","jd_137292pwe","jd_177395xqs","jd_133053jus","jd_151339jhx","jd_135087ljd","jd_53b1c5c35ac9a","jd_qiuche549","jd_158164uel","jd_138107wud","jd_199771clu","jd_186753jcs","jd_187150ylk","jd_138974rxt","jd_103433211","jd_185821hfr","jd_139502ycf","jd_137713uyd","jd_187698feo","jd_136089okg","jd_4352325","jd_139639yoj","jd_979798715","jd_131321aoc","jd_185224kzc","jd_151639rszh","jd_185669lfi","jd_lideguang_2011","jd_138725hyc","jd_qaa011","jd_135928ucx","jd_649f9eae0be6c","jd_155229vlt","jd_139885sgt","jd_136220wqh","jd_130741cki","jd_151611ebv","jd_189756rue","jd_5e95dcfd762f4","jd_6261731","jd_135495gbf","jd_150042iil","jd_137894frb","jd_135873xqmi","jd_138593nkp","jd_175412852","jd_139690dad","jd_43a2e9c6537f8","jd_138175wuk","jd_131716dfh","jd_138556pnn","jd_5020276315","jd_177316iqo","jd_181375rvj","jd_229003983","jd_180789bug","jd_150682yxz","jd_152181wlw","jd_224275759","jd_136102svi","jd_9929897714","jd_139691wvgh","jd_189305xgc","jd_133211nev","jd_138697wdw","jd_189314rid","jd_182520tcmf","jd_184399ypg","jd_156312gqm","jd_183257kbc","jd_8745170","jd_151758sra","jd_136000dfw","jd_138337tbg","jd_xishuwulu","jd_189shijz","jd_182257jvd","jd_156983msp","jd_316882724","jd_135808jxz","jd_135557shtf","jd_233102237","jd_186099qlx","jd_185263tir","jd_406bfe50a3525","jd_180669zge","jd_6402aba2128d9","jd_181335kmh","jd_137378ult","jd_150022yxf","jd_188540les","jd_133774erh","jd_138784rjl","jd_182817gcd","jd_134724ief","jd_132536dsy","jd_136604veq","jd_189715ich","jd_182876ynp","jd_177737trf","jd_186552tmg","jd_152104bbn","jd_136219qpt","jd_138262kmx","jd_176204injl","jd_183772tnk","jd_152150ixc","jd_139291nono","jd_186430qkb","jd_183182ynu","jd_135980gkl","jd_158520qfph","jd_135592ugy","jd_139445whz","jd_151308una","jd_150849jbh","jd_655789303","jd_136906lqt","jd_156206yfx","jd_137619mem","jd_152667dao","jd_138597bto","jd_189315etn","jd_151132kre","jd_239626183","jd_sdwh1","jd_136817uwz","jd_187119rqc","jd_yzztt","jd_157563ywzn","jd_zran012","jd_178280jig","jd_070889622","jd_132865tfs","jd_137098qlp","jd_159314ahj","jd_135530jsi","jd_156985tlp","jd_182109kiy","jd_183501fyv","jd_151668vpv","jd_138155ahi","jd_zwh082","jd_135647kui","jd_139149ipt","jd_186993pyi","jd_159524eku","jd_135392iff","jd_177019dfk","jd_185008kmg","jd_18259236618","jd_151227rgpa","jd_4b3c0be45543e","jd_158968lou","jd_150389hzqg","jd_136861rdw","jd_155046rli","jd_136773sqft","jd_zgybon","jd_131035lcq","jd_150342zqz","jd_2402232","jd_136718hfu","jd_176455kih","jd_188621xuu","jd_138719eld","jd_150670lziv","jd_135854sbe","jd_135262oos","jd_188161shx","jd_180136kfc","jd_189843kbz","jd_186041eon","jd_134570eqc","jd_180796xlc","jd_136923ucb","jd_182633vxt","jd_nmge","jd_183208ouaf","jd_155310zrn","jd_157188fmac","jd_158257chj","jd_177727lrh","jd_135397spe","jd_185124djb","jd_183860rvq","jd_157059kmd","jd_180922bpt","jd_183309nqe","jd_188510uou","jd_135909yhz","jd_138438ems","jd_136111kka","jd_138178ifs","jd_137646lxd","jd_188091hsj","jd_138226rqe","jd_159780lcxu","jd_139609eib","jd_135855xcw","jd_138531zvu","jd_186653hgl","jd_187269vtx","jd_138651nbt","jd_jwh788","jd_133387vpc","jd_188293qlb","jd_150403hbmm","jd_Yuton","jd_184wdz","jd_wyxgz","jd_186372kcz","jd_151600bmg","jd_151121uvgb","jd_137789qwb","jd_837751791","jd_153201xmi","jd_189562krx","jd_182519hniq","jd_188254mlj","jd_136893llq","jd_181322mkf","jd_132625cpe","jd_139609gwt","jd_188967afm","jd_136128fuyn","jd_153732jlpo","jd_221890978","jd_183184wfpz","jd_158304rms","jd_133010ltt","jd_135162chg","jd_158170msu","jd_135101jzrs","jd_155335qzm","jd_5701f57639cfe","jd_139502lkx","jd_cloi","jd_151948etv","jd_185502ypm","jd_186915dcn","jd_133672hlv"]; //随机生成m(小)到n(大)的数,包含m和n function randomFriendPin(m,n) { return Math.round(Math.random()*(n - m) + m); diff --git a/backUp/mySelf.boxjs.json b/backUp/mySelf.boxjs.json new file mode 100644 index 0000000..0aa942c --- /dev/null +++ b/backUp/mySelf.boxjs.json @@ -0,0 +1,25 @@ +{ + "id": "lxk0301.app.sub2", + "name": "自用", + "author": "@lxk0301", + "icon": "https://avatars0.githubusercontent.com/u/21308593?s=52&v=4", + "repo": "https://github.com/lxk0301/jd_scripts/", + "apps": [ + { + "id": "QQ_READ", + "name": "企鹅阅读(QQ小程序)", + "keys": [ + "qqreadhd", + "qqreadtimeurl", + "qqreadtimehd" + ], + "settings": [], + "author": "@ziye12", + "repo": "https://github.com/ziye12/JavaScript ", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/jd.png", + "https://raw.githubusercontent.com/Orz-3/task/master/jd.png" + ] + } + ] +} diff --git a/backUp/qqread.js b/backUp/qqread.js new file mode 100644 index 0000000..767c34c --- /dev/null +++ b/backUp/qqread.js @@ -0,0 +1,722 @@ +/* +****************************************************************************** + 改用,nodejs云端专用。可N个账号。by;lxk0301 + 一个账号需三个环境变量/secret + 分别为 QQ_READ_HEADER_VAL QQ_READ_TIME_URL_VAL QQ_READ_TIME_HEADER_VAL + 多个账号 对应三个环境变量/secret 使用@符号或者换行隔开 + iOS可使用BoxJs可使用此订阅修改复制所需的环境变量 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/mySelf.boxjs.json + 环境变量与BoxJs里面对应关系 + QQ_READ_HEADER_VAL ------》 qqreadhd + QQ_READ_TIME_URL_VAL ------》 qqreadtimeurl + QQ_READ_TIME_HEADER_VAL ------》 qqreadtimehd + ***************************************************************************************************************** +ziye +本人github地址 https://github.com/ziye12/JavaScript +转载请备注个名字,谢谢 + +11.25 增加 阅读时长上传,阅读金币,阅读随机金币 +11.25 修复翻倍宝箱不同时领取的问题.增加阅读金币判定 +11.25 修复阅读时长问题,阅读金币问题,请重新获取时长cookie +11.26 随机金币只有一次,故去除,调整修复阅读金币问题,增加时长上传限制 +11.26 增加领取周时长奖励 +11.26 增加结束命令 +11.27 调整通知为,成功开启宝箱再通知 +11.28 修复错误 +12.1 调整通知为15次宝箱通知一次 +12.1 优化通知 + +⚠️cookie获取方法: + +进 https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a 点我的 获取cookie + +进一本书 看 10秒以下 然后退出,获取阅读时长cookie,看书一定不能超过10秒 + +可能某些页面会卡住,但是能获取到cookie,再注释cookie重写就行了! + + + +⚠️宝箱奖励为20分钟一次,自己根据情况设置定时,建议设置11分钟一次 + +hostname=mqqapi.reader.qq.com + +############## 圈x + +#企鹅读书获取cookie +https:\/\/mqqapi\.reader\.qq\.com\/mqq\/user\/init url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js + +#企鹅读书获取时长cookie +https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js + + +############## loon + +//企鹅读书获取cookie +http-request https:\/\/mqqapi\.reader\.qq\.com\/mqq\/user\/init script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js,requires-header=true, tag=企鹅读书获取cookie + +//企鹅读书获取时长cookie +http-request https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid? script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js, requires-header=true, tag=企鹅读书获取时长cookie + + +############## surge + +//企鹅读书获取cookie +企鹅读书 = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/mqq\/user\/init,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js, requires-header=true + +//企鹅读书获取时长cookie +企鹅读书 = type=http-request,pattern=https:\/\/mqqapi\.reader\.qq\.com\/mqq\/addReadTimeWithBid?,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/qqread.js, requires-header=true + + +*/ + +const jsname = '企鹅读书' +const $ = Env(jsname) +let task = '', config, ssr2 = '', wktime; +console.log(`\n========= 脚本执行时间(TM):${new Date(new Date().getTime() + 0 * 60 * 60 * 1000).toLocaleString('zh', {hour12: false})} =========\n`) + +const logs = 1; //0为关闭日志,1为开启 +const notifyInterval = 3 +//0为关闭通知,1为所有通知,2为宝箱领取成功通知,3为宝箱每15次通知一次 + +const dd = 1//单次任务延迟,默认1秒 +const TIME = 30//单次时长上传限制,默认5分钟 +const maxtime = 20//每日上传时长限制,默认20小时 +const wktimess = 1200//周奖励领取标准,默认1200分钟 +var tz = '' +const qqreadurlVal = `https://mqqapi.reader.qq.com/mqq/user/init`; +const qqreadurlKey = 'qqreadurl' +// const qqreadurlVal = $.getdata(qqreadurlKey) + +const qqreadheaderKey = 'qqreadhd' +let qqreadheaderVal = $.getdata(qqreadheaderKey) + +const qqreadtimeurlKey = 'qqreadtimeurl' +let qqreadtimeurlVal = $.getdata(qqreadtimeurlKey) + +const qqreadtimeheaderKey = 'qqreadtimehd' +let qqreadtimeheaderVal = $.getdata(qqreadtimeheaderKey) +//云函数使用在下面填写 +let QQ_READ_COOKIES = [ + { + qqreadurlVal, + "qqreadheaderVal": ``, + "qqreadtimeurlVal": ``, + "qqreadtimeheaderVal": `` + } +] +function getNodeCookie() { + if ($.isNode()) { + let QQ_READ_HEADER_VAL = [], QQ_READ_TIME_URL_VAL = [], QQ_READ_TIME_HEADER_VAL = []; + if (process.env.QQ_READ_HEADER_VAL) { + if (process.env.QQ_READ_HEADER_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_HEADER_VAL选择的是用@隔开\n`) + QQ_READ_HEADER_VAL = process.env.QQ_READ_HEADER_VAL.split('@'); + } else if (process.env.QQ_READ_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_HEADER_VAL选择的是用换行隔开\n`) + QQ_READ_HEADER_VAL = process.env.QQ_READ_HEADER_VAL.split('\n'); + } else { + QQ_READ_HEADER_VAL = [process.env.QQ_READ_HEADER_VAL]; + } + // QQ_READ_HEADER_VAL = [...new Set(QQ_READ_HEADER_VAL)] + // $.log(QQ_READ_HEADER_VAL) + } + if (process.env.QQ_READ_TIME_URL_VAL) { + if (process.env.QQ_READ_TIME_URL_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_TIME_URL_VAL选择的是用@隔开\n`) + QQ_READ_TIME_URL_VAL = process.env.QQ_READ_TIME_URL_VAL.split('@'); + } else if (process.env.QQ_READ_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_TIME_URL_VAL选择的是用换行隔开\n`) + QQ_READ_TIME_URL_VAL = process.env.QQ_READ_TIME_URL_VAL.split('\n'); + } else { + QQ_READ_TIME_URL_VAL = [process.env.QQ_READ_TIME_URL_VAL]; + } + // QQ_READ_TIME_URL_VAL = [...new Set(QQ_READ_TIME_URL_VAL)] + } + if (process.env.QQ_READ_TIME_HEADER_VAL) { + if (process.env.QQ_READ_TIME_HEADER_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_TIME_HEADER_VAL选择的是用@隔开\n`) + QQ_READ_TIME_HEADER_VAL = process.env.QQ_READ_TIME_HEADER_VAL.split('@'); + } else if (process.env.QQ_READ_TIME_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_TIME_HEADER_VAL选择的是用换行隔开\n`) + QQ_READ_TIME_HEADER_VAL = process.env.QQ_READ_TIME_HEADER_VAL.split('\n'); + } else { + QQ_READ_TIME_HEADER_VAL = [process.env.QQ_READ_TIME_HEADER_VAL]; + } + // QQ_READ_TIME_HEADER_VAL = [...new Set(QQ_READ_TIME_HEADER_VAL)] + } + if (QQ_READ_HEADER_VAL && QQ_READ_HEADER_VAL.length > 0) QQ_READ_COOKIES = []; + for (let i = 0; i < QQ_READ_HEADER_VAL.length; i ++) { + QQ_READ_COOKIES.push({ + qqreadurlVal, + "qqreadheaderVal": QQ_READ_HEADER_VAL[i] || "", + "qqreadtimeurlVal": QQ_READ_TIME_URL_VAL[i] || "", + "qqreadtimeheaderVal": QQ_READ_TIME_HEADER_VAL[i] || "" + }) + } + // console.log(`${JSON.stringify(QQ_READ_COOKIES)}`) + } +} +//CK运行 +let isGetCookie = typeof $request !== 'undefined' +if (isGetCookie) { + GetCookie() +} else { + !(async () => { + await getNodeCookie(); + await QQ_READ(); + // await all(); + })() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +} + +function GetCookie() { + + if ($request && $request.url.indexOf("init") >= 0) { + + // const qqreadurlVal = $request.url + // if (qqreadurlVal) $.setdata(qqreadurlVal, qqreadurlKey) + // $.log(`[${jsname}] 获取url请求: 成功,qqreadurlVal: ${qqreadurlVal}`) + + // const qqreadbodyVal = $request.body + // if (qqreadbodyVal) $.setdata(qqreadbodyVal, qqreadbodyKey) + // $.log(`[${jsname}] 获取阅读: 成功,qqreadbodyVal: ${qqreadbodyVal}`) + + // $.setdata(qqreadurlVal, qqreadurlKey); + const qqreadheaderVal = JSON.stringify($request.headers) + if (qqreadheaderVal) $.setdata(qqreadheaderVal, qqreadheaderKey) + $.log(`[${jsname}] 获取Cookie: 成功,qqreadheaderVal: ${qqreadheaderVal}`) + $.msg(qqreadheaderKey, `获取cookie: 成功🎉`, ``) + + } else if ($request && $request.url.indexOf("addReadTimeWithBid?") >= 0) { + const qqreadtimeurlVal = $request.url + if (qqreadtimeurlVal) $.setdata(qqreadtimeurlVal, qqreadtimeurlKey) + $.log(`[${jsname}] 获取阅读时长url: 成功,qqreadtimeurlVal: ${qqreadtimeurlVal}`) + + const qqreadtimeheaderVal = JSON.stringify($request.headers) + if (qqreadtimeheaderVal) $.setdata(qqreadtimeheaderVal, qqreadtimeheaderKey) + $.log(`[${jsname}] 获取时长header: 成功,qqreadtimeheaderVal: ${qqreadtimeheaderVal}`) + $.msg(qqreadtimeheaderKey, `获取阅读时长cookie: 成功🎉`, ``) + + } + $.done(); +} +async function QQ_READ() { + for (let i = 0; i < QQ_READ_COOKIES.length; i++) { + $.log(`\n*************开始QQ账号${i + 1}**************\n`); + tz = ''; + if (!QQ_READ_COOKIES[i]["qqreadheaderVal"] || !QQ_READ_COOKIES[i]['qqreadtimeurlVal'] || !QQ_READ_COOKIES[i]['qqreadtimeheaderVal']) { + $.log(`账号${i + 1}暂未提供脚本执行所需的cookie`); + continue + } + qqreadheaderVal = QQ_READ_COOKIES[i]['qqreadheaderVal']; + qqreadtimeurlVal = QQ_READ_COOKIES[i]['qqreadtimeurlVal']; + qqreadtimeheaderVal = QQ_READ_COOKIES[i]['qqreadtimeheaderVal']; + await qqreadinfo();//用户名 + // await $.wait(2000) + await qqreadconfig();//时长查询 + // await $.wait(2000) + await qqreadtask();//任务列表 + + if (task.data.taskList[0].doneFlag == 0) { + // await $.wait(2000) + await qqreaddayread();//阅读任务 + } + if (task.data.taskList[2].doneFlag == 0) { + // await $.wait(2000) + await qqreadsign();//金币签到 + // await $.wait(2000) + await qqreadtake();//阅豆签到 + // await $.wait(2000) + await qqreadsign2();//签到翻倍 + } + + if (task.data.treasureBox.doneFlag == 0) { + // await $.wait(2000) + await qqreadbox();//宝箱 + } + if (task.data.taskList[1].doneFlag == 0) { + // await $.wait(2000) + await qqreadssr1();//阅读金币1 + await $.wait(3000) + await qqreadssr2();//阅读金币2 + await $.wait(5000) + await qqreadssr3();//阅读金币3 + } + if (task.data.taskList[3].doneFlag == 0) { + // await $.wait(2000) + await qqreadvideo();//视频奖励 + } + if (task.data.treasureBox.videoDoneFlag == 0) { + // await $.wait(2000) + await qqreadbox2();//宝箱翻倍 + } + if (config.data.pageParams.todayReadSeconds / 3600 <= maxtime) { + // await $.wait(2000) + await qqreadtime(); + } + + await qqreadwktime();//周时长查询 + await qqreadpick();//领周时长奖励 + await showmsg();//通知 + } +} + +//任务列表 +function qqreadtask() { + return new Promise((resolve, reject) => { + const toqqreadtaskurl = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/page?fromGuid=', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadtaskurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 任务列表: ${data}`) + task = JSON.parse(data) + tz += + '【现金余额】:' + + (task.data.user.amount / 10000).toFixed(2) + + '元\n' + + '【第' + + task.data.invite.issue + + '期】:时间' + + task.data.invite.dayRange + + '\n' + + ' 已邀请' + + task.data.invite.inviteCount + + '人,再邀请' + + task.data.invite.nextInviteConfig.count + + '人获得' + + task.data.invite.nextInviteConfig.amount + + '金币\n' + + '【' + + task.data.taskList[0].title + + '】:' + + task.data.taskList[0].amount + + '金币,' + + task.data.taskList[0].actionText + + '\n' + + '【' + + task.data.taskList[1].title + + '】:' + + task.data.taskList[1].amount + + '金币,' + + task.data.taskList[1].actionText + + '\n' + + '【' + + task.data.taskList[2].title + + '】:' + + task.data.taskList[2].amount + + '金币,' + + task.data.taskList[2].actionText + + '\n' + + '【' + + task.data.taskList[3].title + + '】:' + + task.data.taskList[3].amount + + '金币,' + + task.data.taskList[3].actionText + + '\n' + + '【宝箱任务' + + (task.data.treasureBox.count + 1) + + '】:' + + task.data.treasureBox.tipText + + '\n' + + '【' + task.data.fans.title + + '】:' + + task.data.fans.fansCount + + '个好友,' + + task.data.fans.todayAmount + + '金币\n' + + resolve() + + }) + + }) +} + + +//用户名 +function qqreadinfo() { + return new Promise((resolve, reject) => { + const toqqreadinfourl = { + url: qqreadurlVal, + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadinfourl, (error, response, data) => { + if (logs) $.log(`${jsname}, 用户名: ${data}`) + const info = JSON.parse(data) + tz += + '【用户信息】:' + info.data.user.nickName + '\n' + + resolve() + }) + }) +} + + +//阅豆签到 +function qqreadtake() { + return new Promise((resolve, reject) => { + const toqqreadtakeurl = { + url: 'https://mqqapi.reader.qq.com/mqq/sign_in/user', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.post(toqqreadtakeurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 阅豆签到: ${data}`) + let take = JSON.parse(data) + if (take.data.takeTicket > 0) { + tz += + '【阅豆签到】:获得' + take.data.takeTicket + '豆\n' + } + + resolve() + }) + }) +} + + +//阅读时长任务 +function qqreadconfig() { + return new Promise((resolve, reject) => { + const toqqreadconfigurl = { + url: 'https://mqqapi.reader.qq.com/mqq/page/config?router=%2Fpages%2Fbook-read%2Findex&options=', + headers: JSON.parse(qqreadheaderVal), + }; + $.get(toqqreadconfigurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 阅读时长查询: ${data}`) + config = JSON.parse(data) + if (config.code == 0) + tz += '【时长查询】:今日阅读' + (config.data.pageParams.todayReadSeconds / 60).toFixed(0) + '分钟\n' + + + resolve() + }) + }) +} + + +//阅读时长 +function qqreadtime() { + return new Promise((resolve, reject) => { + const toqqreadtimeurl = { + url: qqreadtimeurlVal.replace(/readTime=/g, `readTime=${TIME}`), + headers: JSON.parse(qqreadtimeheaderVal), + + }; + + $.get(toqqreadtimeurl, (error, response, data) => { + if (logs) $.log(`${jsname}, qqreadtime-阅读时长: ${data}`) + let time = JSON.parse(data) + if (time && time.code == 0) tz += '【阅读时长】:上传' + TIME / 6 + '分钟\n' + resolve() + }) + }) +} + + +//阅读金币1 +function qqreadssr1() { + return new Promise((resolve, reject) => { + const toqqreadssr1url = { + url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=30`, + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + if (config.data.pageParams.todayReadSeconds / 60 >= 1) { + + $.get(toqqreadssr1url, (error, response, data) => { + if (logs) $.log(`${jsname}, 金币奖励1: ${data}`) + let ssr1 = JSON.parse(data) + if (ssr1.data.amount > 0) + tz += '【阅读金币1】获得' + ssr1.data.amount + '金币\n' + + + resolve() + }) + } + resolve() + }) +} + + +//阅读金币2 +function qqreadssr2() { + return new Promise((resolve, reject) => { + const toqqreadssr2url = { + url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=300`, + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + if (config.data.pageParams.todayReadSeconds / 60 >= 5) { + + $.get(toqqreadssr2url, (error, response, data) => { + if (logs) $.log(`${jsname}, 金币奖励2: ${data}`) + ssr2 = JSON.parse(data) + if (ssr2.code === 0) { + if (ssr2.data.amount > 0) tz += '【阅读金币2】获得' + ssr2.data.amount + '金币\n' + } + resolve() + }) + } + resolve() + }) +} + + +//阅读金币3 +function qqreadssr3() { + return new Promise((resolve, reject) => { + const toqqreadssr3url = { + url: `https://mqqapi.reader.qq.com/mqq/red_packet/user/read_time?seconds=1800`, + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + + if (config.data.pageParams.todayReadSeconds / 60 >= 30) { + + $.get(toqqreadssr3url, (error, response, data) => { + if (logs) $.log(`${jsname}, 金币奖励3: ${data}`) + let ssr3 = JSON.parse(data) + if (ssr3.code === 0) { + if (ssr3.data.amount > 0) tz += '【阅读金币3】获得' + ssr3.data.amount + '金币\n' + } + resolve() + }) + } + resolve() + }) +} + + +//金币签到 +function qqreadsign() { + return new Promise((resolve, reject) => { + const toqqreadsignurl = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in/page', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadsignurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 金币签到: ${data}`) + let sign = JSON.parse(data) + + if (sign.data.videoDoneFlag) { + tz += + '【金币签到】:获得' + sign.data.todayAmount + '金币\n' + } + + + resolve() + }) + }) +} + + +//金币签到翻倍 +function qqreadsign2() { + return new Promise((resolve, reject) => { + const toqqreadsign2url = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/clock_in_video', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadsign2url, (error, response, data) => { + if (logs) $.log(`${jsname}, 金币签到翻倍: ${data}`) + let sign2 = JSON.parse(data) + + if (sign2.code == 0) { + tz += + '【签到翻倍】:获得' + sign2.data.amount + '金币\n' + } + + resolve() + }) + }) +} + + +//每日阅读 +function qqreaddayread() { + return new Promise((resolve, reject) => { + const toqqreaddayreadurl = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/read_book', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreaddayreadurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 每日阅读: ${data}`) + let dayread = JSON.parse(data) + if (dayread.code == 0) { + tz += + '【每日阅读】:获得' + dayread.data.amount + '金币\n' + + } + + resolve() + }) + }) +} + + +//视频奖励 +function qqreadvideo() { + return new Promise((resolve, reject) => { + const toqqreadvideourl = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/watch_video', + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadvideourl, (error, response, data) => { + if (logs) $.log(`${jsname}, 视频奖励: ${data}`) + let video = JSON.parse(data) + + if (video.code == 0) { + tz += + '【视频奖励】:获得' + video.data.amount + '金币\n' + + } + + resolve() + }) + }) +} + + +//宝箱奖励 +function qqreadbox() { + return new Promise((resolve, reject) => { + + const toqqreadboxurl = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box', + + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadboxurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 宝箱奖励: ${data}`) + const box = JSON.parse(data) + + if (box.data.count >= 0) { + tz += + '【宝箱奖励' + box.data.count + '】:获得' + box.data.amount + '金币\n' + + } + + resolve() + }) + }) +} + +//宝箱奖励翻倍 +function qqreadbox2() { + return new Promise((resolve, reject) => { + + const toqqreadbox2url = { + url: 'https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box_video', + + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadbox2url, (error, response, data) => { + if (logs) $.log(`${jsname}, 宝箱奖励翻倍: ${data}`) + let box2 = JSON.parse(data) + + if (box2.code == 0) { + tz += + '【宝箱翻倍】:获得' + box2.data.amount + '金币\n' + } + + resolve() + }) + }) +} + +//本周阅读时长 +function qqreadwktime() { + return new Promise((resolve, reject) => { + + const toqqreadwktimeurl = { + + url: `https://mqqapi.reader.qq.com/mqq/v1/bookShelfInit`, + + headers: JSON.parse(qqreadheaderVal), + + }; + + $.get(toqqreadwktimeurl, (error, response, data) => { + if (logs) $.log(`${jsname}, qqreadwktime 阅读时长: ${data}`) + wktime = JSON.parse(data) + if (wktime.code == 0) tz += '【本周阅读时长】:' + wktime.data.readTime + '分钟\n' + resolve() + }) + }) +} + + +//本周阅读时长奖励任务 +function qqreadpick() { + return new Promise((resolve, reject) => { + const toqqreadpickurl = { + url: `https://mqqapi.reader.qq.com/mqq/pickPackageInit`, + headers: JSON.parse(qqreadheaderVal), + }; + + if (wktime.data.readTime >= wktimess) { + $.get(toqqreadpickurl, (error, response, data) => { + if (logs) $.log(`${jsname},周阅读时长奖励任务: ${data}`) + let pick = JSON.parse(data) + if (pick.data[7].isPick == true) + tz += '【周时长奖励】:已全部领取\n' + for (let i = 0; i < pick.data.length; i++) { + setTimeout(() => { + var pickid = pick.data[i].readTime + var Packageid = ['10', '10', '20', '30', '50', '80', '100', '120'] + const toqqreadPackageurl = { + url: `https://mqqapi.reader.qq.com/mqq/pickPackage?readTime=${pickid}`, + headers: JSON.parse(qqreadheaderVal), + timeout: 60000 + }; + $.get(toqqreadPackageurl, (error, response, data) => { + if (logs) $.log(`${jsname}, 领周阅读时长: ${data}`) + let Package = JSON.parse(data) + if (Package.code == 0) + tz += '【周时长奖励' + (i + 1) + '】:领取' + Packageid[i] + '阅豆\n' + }) + + }, i * 100) + } + + }) + resolve() + } + resolve() + }) +} + + +function showmsg() { + return new Promise(async resolve => { + console.log(tz) + + if (notifyInterval == 1) + $.msg(jsname, '', tz)//显示所有通知 + + else if (notifyInterval == 2 && task.data.treasureBox.doneFlag == 0) + $.msg(jsname, '', tz)//宝箱领取成功通知 + + else if (notifyInterval == 3 && task.data.treasureBox.count == 0 || task.data.treasureBox.count == 15 || task.data.treasureBox.count == 30 || task.data.treasureBox.count == 45 || task.data.treasureBox.count == 60) + $.msg(jsname, '', tz)//宝箱每15次通知一次 + resolve() + }) +} + + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/docker/Dockerfile b/docker/Dockerfile index 47d9920..5615cde 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN git clone https://github.com/lxk0301/jd_scripts /scripts \ && cd /scripts \ && mkdir logs \ && npm install \ - && cd ~ \ + && cd /tmp \ && npm install request ENV CRONTAB_LIST_FILE crontab_list_ts.sh @@ -20,4 +20,4 @@ RUN crontab /scripts/docker/crontab_list_ts.sh WORKDIR /scripts -CMD ["node"] \ No newline at end of file +CMD ["node"] diff --git a/docker/Readme.md b/docker/Readme.md index 0e4681f..7b5d824 100644 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -76,10 +76,11 @@ jd_scripts: git -C /scripts/ pull node ``` -- `jd_scripts/my_crontab_list.sh` 参考内容如下(输出日志的最后加上 `|ts` 可在日志每一行前面显示时间): +- `jd_scripts/my_crontab_list.sh` 参考内容如下,自己根据需要调整增加删除,不熟悉用户推荐使用默认配置: + ```shell -0 */1 * * * git -C /scripts/ pull >> /scripts/logs/pull.log 2>&1|ts -2 0 * * * node /scripts/jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 +0 */1 * * * git -C /scripts/ pull |ts >> /scripts/logs/pull.log 2>&1 +2 0 * * * cd /scripts && node jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 2 0 * * * node /scripts/jd_blueCoin.js >> /scripts/logs/jd_blueCoin.log 2>&1 2 0 * * * node /scripts/jd_club_lottery.js >> /scripts/logs/jd_club_lottery.log 2>&1 20 6-18/6 * * * node /scripts/jd_fruit.js >> /scripts/logs/jd_fruit.log 2>&1 @@ -95,6 +96,8 @@ jd_scripts: 15 * * * * node /scripts/jd_superMarket.js >> /scripts/logs/jd_superMarket.log 2>&1 55 23 * * * node /scripts/jd_unsubscribe.js >> /scripts/logs/jd_unsubscribe.log 2>&1 ``` +> 定时任务命之后,也就是 `>>` 符号之前加上 `|ts` 可在日志每一行前面显示时间,如下图: +> ![image](https://user-images.githubusercontent.com/6993269/99031839-09e04b00-25b3-11eb-8e47-0b6515a282bb.png) - 目录文件配置好之后在 `jd_scripts`目录执行 `docker-compose up -d` 启动; `docker-compose logs` 打印日志; diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index 3b2a449..4c656d9 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -1,18 +1,27 @@ -0 */1 * * * git -C /scripts/ pull >> /scripts/logs/pull.log 2>&1 -2 */1 * * * crontab /scripts/docker/${CRONTAB_LIST_FILE} -3 */1 * * * npm install --prefix /scripts >> /scripts/logs/npm_install.log 2>&1 +50 */1 * * * git -C /scripts/ pull >> /scripts/logs/pull.log 2>&1 +52 */1 * * * crontab /scripts/docker/${CRONTAB_LIST_FILE} +53 */1 * * * npm install --prefix /scripts >> /scripts/logs/npm_install.log 2>&1 # 每3天的23:50分清理一次日志 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## -# 暂无 - - +# 京喜故事(2020.12.12活动过期) +10 * * * * node /scripts/jd_jxstory.js >> /scripts/logs/jd_jxstory.log 2>&1 +# 金榜年终奖(2020.12.12活动过期) +10 7 * * * node /scripts/jd_split.js >> /scripts/logs/jd_split.log 2>&1 +# 秒杀红包雨(2020.12.31活动过期) +40 8 * * * node /scripts/jd_ms_redrain.js >> /scripts/logs/jd_ms_redrain.log 2>&1 +# 健康抽奖机(2020.12.31活动过期) +10 0 * * * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 +# 直播红包雨(2020.12.12活动过期) +0 0,9,11,13,15,17,19,20,21,23 * * * node /scripts/jd_live_redrain.js >> /scripts/logs/jd_live_redrain.log 2>&1 +# 数码加购京豆(2020.12.11活动过期) + 8 0 * * * node /scripts/jd_digital_floor.js >> /scripts/logs/jd_digital_floor.log 2>&1 ##############长期活动############## # 签到 -0 0,12,18 * * * node /scripts/jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 +0 0,12,18 * * * cd /scripts && node jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 # 京小超兑换奖品 0 0 * * * node /scripts/jd_blueCoin.js >> /scripts/logs/jd_blueCoin.log 2>&1 # 摇京豆 @@ -44,12 +53,30 @@ # 取关京东店铺商品 55 23 * * * node /scripts/jd_unsubscribe.js >> /scripts/logs/jd_unsubscribe.log 2>&1 # 京豆变动通知 -0 2 * * * node /scripts/jd_bean_change.js >> /scripts/logs/jd_bean_change.log 2>&1 +0 10 * * * node /scripts/jd_bean_change.js >> /scripts/logs/jd_bean_change.log 2>&1 # 京东抽奖机 11 1 * * * node /scripts/jd_lotteryMachine.js >> /scripts/logs/jd_lotteryMachine.log 2>&1 # 京东排行榜 11 9 * * * node /scripts/jd_rankingList.js >> /scripts/logs/jd_rankingList.log 2>&1 # 天天提鹅 -18 */3 * * * node /scripts/jd_daily_egg.js >> /scripts/logs/jd_daily_egg.log 2>&1 +18 * * * * node /scripts/jd_daily_egg.js >> /scripts/logs/jd_daily_egg.log 2>&1 # 金融养猪 -12 13 * * * node /scripts/jd_pigPet.js >> /scripts/logs/jd_pigPet.log 2>&1 +12 * * * * node /scripts/jd_pigPet.js >> /scripts/logs/jd_pigPet.log 2>&1 +# 点点券 +20 0,20 * * * node /scripts/jd_necklace.js >> /scripts/logs/jd_necklace.log 2>&1 +# 京喜工厂 +20 * * * * node /scripts/jd_dreamFactory.js >> /scripts/logs/jd_dreamFactory.log 2>&1 +# 东东小窝 +16 6 * * * node /scripts/jd_small_home.js >> /scripts/logs/jd_small_home.log 2>&1 +# 东东工厂 +36 * * * * node /scripts/jd_jdfactory.js >> /scripts/logs/jd_jdfactory.log 2>&1 +#十元街 +36 8 * * * node /scripts/jd_syj.js >> /scripts/logs/jd_syj.log 2>&1 +# 京东代属(注:限校园用户可使用) +36 9 * * * node /scripts/jd_ds.js >> /scripts/logs/jd_ds.log 2>&1 +# 京东快递签到 +23 1 * * * node /scripts/jd_kd.js >> /scripts/logs/jd_kd.log 2>&1 +# 京东汽车(签到满500赛点可兑换500京豆) +33 2 * * * node /scripts/jd_car.js >> /scripts/logs/jd_car.log 2>&1 +# 领京豆额外奖励(每日可获得3京豆) +33 4 * * * node /scripts/jd_bean_home.js >> /scripts/logs/jd_bean_home.log 2>&1 diff --git a/docker/crontab_list_ts.sh b/docker/crontab_list_ts.sh index 1d0f210..b1dd621 100644 --- a/docker/crontab_list_ts.sh +++ b/docker/crontab_list_ts.sh @@ -1,55 +1,82 @@ -0 */1 * * * git -C /scripts/ pull >> /scripts/logs/pull.log 2>&1|ts -2 */1 * * * crontab /scripts/docker/${CRONTAB_LIST_FILE} -3 */1 * * * npm install --prefix /scripts >> /scripts/logs/npm_install.log 2>&1|ts +50 */1 * * * git -C /scripts/ pull |ts >> /scripts/logs/pull.log 2>&1 +52 */1 * * * crontab /scripts/docker/${CRONTAB_LIST_FILE} +53 */1 * * * npm install --prefix /scripts |ts >> /scripts/logs/npm_install.log 2>&1 # 每3天的23:50分清理一次日志 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## -# 暂无 - - +# 京喜故事(2020.12.12活动过期) +10 * * * * node /scripts/jd_jxstory.js |ts >> /scripts/logs/jd_jxstory.log 2>&1 +# 金榜年终奖(2020.12.12活动过期) +10 7 * * * node /scripts/jd_split.js |ts >> /scripts/logs/jd_split.log 2>&1 +# 秒杀红包雨(2020.12.31活动过期) +40 8 * * * node /scripts/jd_ms_redrain.js |ts >> /scripts/logs/jd_ms_redrain.log 2>&1 +# 健康抽奖机(2020.12.31活动过期) +10 0 * * * node /scripts/jd_health.js |ts >> /scripts/logs/jd_health.log 2>&1 +# 直播红包雨(2020.12.12活动过期) +0 0,9,11,13,15,17,19,20,21,23 * * * node /scripts/jd_live_redrain.js |ts >> /scripts/logs/jd_live_redrain.log 2>&1 +# 数码加购京豆(2020.12.11活动过期) +8 0 * * * node /scripts/jd_digital_floor.js |ts >> /scripts/logs/jd_digital_floor.log 2>&1 ##############长期活动############## # 签到 -0 0,12,18 * * * node /scripts/jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1|ts +0 0,12,18 * * * cd /scripts && node jd_bean_sign.js |ts >> /scripts/logs/jd_bean_sign.log 2>&1 # 京小超兑换奖品 -0 0 * * * node /scripts/jd_blueCoin.js >> /scripts/logs/jd_blueCoin.log 2>&1|ts +0 0 * * * node /scripts/jd_blueCoin.js |ts >> /scripts/logs/jd_blueCoin.log 2>&1 # 摇京豆 -0 0 * * * node /scripts/jd_club_lottery.js >> /scripts/logs/jd_club_lottery.log 2>&1|ts +0 0 * * * node /scripts/jd_club_lottery.js |ts >> /scripts/logs/jd_club_lottery.log 2>&1 # 东东农场 -5 6-18/6 * * * node /scripts/jd_fruit.js >> /scripts/logs/jd_fruit.log 2>&1|ts +5 6-18/6 * * * node /scripts/jd_fruit.js |ts >> /scripts/logs/jd_fruit.log 2>&1 # 宠汪汪 -15 */2 * * * node /scripts/jd_joy.js >> /scripts/logs/jd_joy.log 2>&1|ts +15 */2 * * * node /scripts/jd_joy.js |ts >> /scripts/logs/jd_joy.log 2>&1 # 宠汪汪喂食 -15 */1 * * * node /scripts/jd_joy_feedPets.js >> /scripts/logs/jd_joy_feedPets.log 2>&1|ts +15 */1 * * * node /scripts/jd_joy_feedPets.js |ts >> /scripts/logs/jd_joy_feedPets.log 2>&1 # 宠汪汪积分兑换奖品 -0 0-16/8 * * * node /scripts/jd_joy_reward.js >> /scripts/logs/jd_joy_reward.log 2>&1|ts +0 0-16/8 * * * node /scripts/jd_joy_reward.js |ts >> /scripts/logs/jd_joy_reward.log 2>&1 # 宠汪汪偷好友积分与狗粮 -0 0,6 * * * node /scripts/jd_joy_steal.js >> /scripts/logs/jd_joy_steal.log 2>&1|ts +0 0,6 * * * node /scripts/jd_joy_steal.js |ts >> /scripts/logs/jd_joy_steal.log 2>&1 # 摇钱树 -0 */2 * * * node /scripts/jd_moneyTree.js >> /scripts/logs/jd_moneyTree.log 2>&1|ts +0 */2 * * * node /scripts/jd_moneyTree.js |ts >> /scripts/logs/jd_moneyTree.log 2>&1 # 东东萌宠 -5 6-18/6 * * * node /scripts/jd_pet.js >> /scripts/logs/jd_pet.log 2>&1|ts +5 6-18/6 * * * node /scripts/jd_pet.js |ts >> /scripts/logs/jd_pet.log 2>&1 # 京东种豆得豆 -0 7-22/1 * * * node /scripts/jd_plantBean.js >> /scripts/logs/jd_plantBean.log 2>&1|ts +0 7-22/1 * * * node /scripts/jd_plantBean.js |ts >> /scripts/logs/jd_plantBean.log 2>&1 # 京东全民开红包 -1 1 * * * node /scripts/jd_redPacket.js >> /scripts/logs/jd_redPacket.log 2>&1|ts +1 1 * * * node /scripts/jd_redPacket.js |ts >> /scripts/logs/jd_redPacket.log 2>&1 # 进店领豆 -10 0 * * * node /scripts/jd_shop.js >> /scripts/logs/jd_shop.log 2>&1|ts +10 0 * * * node /scripts/jd_shop.js |ts >> /scripts/logs/jd_shop.log 2>&1 # 京东天天加速 -8 */3 * * * node /scripts/jd_speed.js >> /scripts/logs/jd_speed.log 2>&1|ts +8 */3 * * * node /scripts/jd_speed.js |ts >> /scripts/logs/jd_speed.log 2>&1 # 东东超市 -11 1-23/5 * * * node /scripts/jd_superMarket.js >> /scripts/logs/jd_superMarket.log 2>&1|ts +11 1-23/5 * * * node /scripts/jd_superMarket.js |ts >> /scripts/logs/jd_superMarket.log 2>&1 # 取关京东店铺商品 -55 23 * * * node /scripts/jd_unsubscribe.js >> /scripts/logs/jd_unsubscribe.log 2>&1|ts +55 23 * * * node /scripts/jd_unsubscribe.js |ts >> /scripts/logs/jd_unsubscribe.log 2>&1 # 京豆变动通知 -0 2 * * * node /scripts/jd_bean_change.js >> /scripts/logs/jd_bean_change.log 2>&1|ts +0 10 * * * node /scripts/jd_bean_change.js |ts >> /scripts/logs/jd_bean_change.log 2>&1 # 京东抽奖机 -11 1 * * * node /scripts/jd_lotteryMachine.js >> /scripts/logs/jd_lotteryMachine.log 2>&1|ts +11 1 * * * node /scripts/jd_lotteryMachine.js |ts >> /scripts/logs/jd_lotteryMachine.log 2>&1 # 京东排行榜 -11 9 * * * node /scripts/jd_rankingList.js >> /scripts/logs/jd_rankingList.log 2>&1|ts +11 9 * * * node /scripts/jd_rankingList.js |ts >> /scripts/logs/jd_rankingList.log 2>&1 # 天天提鹅 -18 */3 * * * node /scripts/jd_daily_egg.js >> /scripts/logs/jd_daily_egg.log 2>&1|ts +18 * * * * node /scripts/jd_daily_egg.js |ts >> /scripts/logs/jd_daily_egg.log 2>&1 # 金融养猪 -12 13 * * * node /scripts/jd_pigPet.js >> /scripts/logs/jd_pigPet.log 2>&1|ts +12 * * * * node /scripts/jd_pigPet.js |ts >> /scripts/logs/jd_pigPet.log 2>&1 +# 点点券 +20 0,20 * * * node /scripts/jd_necklace.js |ts >> /scripts/logs/jd_necklace.log 2>&1 +# 京喜工厂 +20 * * * * node /scripts/jd_dreamFactory.js |ts >> /scripts/logs/jd_dreamFactory.log 2>&1 +# 东东小窝 +16 6 * * * node /scripts/jd_small_home.js |ts >> /scripts/logs/jd_small_home.log 2>&1 +# 东东工厂 +36 * * * * node /scripts/jd_jdfactory.js |ts >> /scripts/logs/jd_jdfactory.log 2>&1 +# 十元街 +36 8,18 * * * node /scripts/jd_syj.js |ts >> /scripts/logs/jd_syj.log 2>&1 +# 京东代属(注:限校园用户可使用) +36 9 * * * node /scripts/jd_ds.js |ts >> /scripts/logs/jd_ds.log 2>&1 +# 京东快递签到 +23 1 * * * node /scripts/jd_kd.js |ts >> /scripts/logs/jd_kd.log 2>&1 +# 京东汽车(签到满500赛点可兑换500京豆) +33 2 * * * node /scripts/jd_car.js |ts >> /scripts/logs/jd_car.log 2>&1 +# 领京豆额外奖励(每日可获得3京豆) +33 4 * * * node /scripts/jd_bean_home.js |ts >> /scripts/logs/jd_bean_home.log 2>&1 \ No newline at end of file diff --git a/githubAction.md b/githubAction.md index 45aaa30..acc3bd2 100644 --- a/githubAction.md +++ b/githubAction.md @@ -77,15 +77,16 @@ | Name | 归属 | 属性 | 说明 | | :---------------------: | :----------: | --------- | ------------------------------------------------------------ | | `JD_COOKIE` | 京东 | 必须 | 京东cookie,多个账号的cookie使用`&`隔开或者换行。具体获取参考[浏览器获取京东cookie教程](https://github.com/lxk0301/jd_scripts/blob/master/backUp/GetJdCookie.md) 或者 [插件获取京东cookie教程](https://github.com/lxk0301/jd_scripts/blob/master/backUp/GetJdCookie2.md) | -| `JD_BEAN_STOP` | 京东 | 非必须 | 自定义延迟签到,单位毫秒. 默认分批并发无延迟. 延迟作用于每个签到接口, 如填入延迟则切换顺序签到(耗时较长),如需填写建议输入数字`1` | +| `JD_USER_AGENT` | 京东 | 非必须 | 自定义此库里京东系列脚本的UserAgent,不懂不知不会UserAgent的请不要随意填写内容。具体获取参考此[issue](https://github.com/lxk0301/jd_scripts/issues/127) | +| `JD_BEAN_STOP` | 京东 | 非必须 | jd_bean_sign.js自定义延迟签到,单位毫秒. 默认分批并发无延迟. 延迟作用于每个签到接口, 如填入延迟则切换顺序签到(耗时较长),如需填写建议输入数字`1`,详见[此处说明](https://github.com/NobyDa/Script/blob/master/JD-DailyBonus/JD_DailyBonus.js#L93) | | `JD_BEAN_SIGN_STOP_NOTIFY`| 京东 | 非必须 | `jd_bean_sign.js`脚本运行后不推送签到结果通知,默认推送,填`true`表示不发送通知 | | `JD_BEAN_SIGN_NOTIFY_SIMPLE`| 京东 | 非必须 | `jd_bean_sign.js`脚本运行后推送签到结果简洁版通知,默认推送全部签到结果,填`true`表示推送简洁通知,[效果图](./icon/bean_sign_simple.jpg) | | `JD_DEBUG` | 脚本打印log | 非必须 | 运行脚本时,是否显示log,默认显示。改成false表示不显示,注重隐私的人可以在设置secret -> `Name:JD_DEBUG,Value:false` | | `PUSH_KEY` | 微信推送 | 非必须 | cookie失效推送[server酱的微信通知](http://sc.ftqq.com/3.version) | | `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | cookie失效推送BARK这个APP,填写内容是app提供的`设备码`,例如:https://api.day.app/123 ,那么此处的设备码就是`123`,再不懂看 [这个图](icon/bark.jpg) | | `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` | -| `TG_BOT_TOKEN` | telegram推送 | 非必须 | tg推送,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](https://github.com/lxk0301/jd_scripts/pull/37#issuecomment-692415594) | -| `TG_USER_ID` | telegram推送 | 非必须 | tg推送,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](https://github.com/lxk0301/jd_scripts/pull/37#issuecomment-692415594) | +| `TG_BOT_TOKEN` | telegram推送 | 非必须 | tg推送,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](./backUp/TG_PUSH.md) | +| `TG_USER_ID` | telegram推送 | 非必须 | tg推送,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](./backUp/TG_PUSH.md) | | `DD_BOT_TOKEN` | 钉钉推送 | 非必须 | 钉钉推送[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于符号后面的XXX, 注:如果钉钉推送只填写`DD_BOT_TOKEN`,那么安全设置需勾选`自定义关键词`,内容输入输入`账号`即可,其他安全设置不要勾选 | | `DD_BOT_SECRET` | 钉钉推送 | 非必须 | 密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 , 注:填写了`DD_BOT_TOKEN`和`DD_BOT_SECRET`,钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](icon/DD_bot.png) | | `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) | @@ -95,7 +96,8 @@ | `JD_818_SHAREID_NOTIFY` | 京东818互助码通知开关 | 非必须 | 控制jd_818.js脚本是否在获取互助码后通知,`true`为是(发送推送通知消息),`false`为否(即:不发送推送通知消息) | | `JOY_FEED_COUNT` | 宠汪汪喂食数量 | 非必须 | 控制jd_joy_feedPets.js脚本喂食数量 ,可以填的数字10,20,40,80 , 其他数字不可. | | `JOY_HELP_FEED` | 宠汪汪帮好友喂食 | 非必须 | 控制jd_joy_steal.js脚本是否给好友喂食,`false`为否,`true`为是(给好友喂食) | -| `JOY_RUN_FLAG` | 宠汪汪参加双人赛跑 | 非必须 | 控制jd_joy.js脚本是否参加双人赛跑,`false`为否,`true`为是,脚本默认是`true` | +| `JOY_RUN_FLAG` | 宠汪汪是否赛跑 | 非必须 | 控制jd_joy.js脚本是否参加赛跑(默认参加双人赛跑),`false`为否,`true`为是,脚本默认是`true` | +| `JOY_TEAM_LEVEL` | 宠汪汪参加什么级别的赛跑 | 非必须 | 控制jd_joy.js脚本参加几人的赛跑,可选数字为`2`,`10`,`50`,其中2代表参加双人PK赛,10代表参加10人突围赛,50代表参加50人挑战赛(注:此项功能在`JOY_RUN_FLAG`为true的时候才生效) | | `JD_JOY_REWARD_NAME` | 宠汪汪积分兑换多少京豆 | 非必须 | 目前可填值为`20`或者`500`,脚本默认`20`,`0`表示不兑换京豆 | | `MARKET_COIN_TO_BEANS` | 京小超兑换京豆数量 | 非必须 | 控制jd_blueCoin.js兑换京豆数量,可输入值为`20`或者`1000`的数字或者其他商品的名称,例如`碧浪洗衣凝珠` | | `MARKET_REWARD_NOTIFY` | 京小超兑换奖品推送开关 | 非必须 | 控制jd_blueCoin.js兑换奖品成功后是否静默运行, `false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | @@ -104,13 +106,16 @@ | `SUPERMARKET_LOTTERY` | 京小超抽奖 | 非必须 | 每天运行脚本是否使用金币去抽奖,`true`表示抽奖,`false`表示不抽奖 | | `FRUIT_BEAN_CARD` | 农场使用水滴换豆卡 | 非必须 | 农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),`true`表示换豆(不浇水),`false`表示不换豆(继续浇水),脚本默认是浇水 | | `UN_SUBSCRIBES` | jd_unsubscribe.js | 非必须 | 共四个参数,换行隔开. 四个参数分别表示`取关商品数量`,`取关店铺数量`,`遇到此商品不再进行取关`, `遇到此店铺不再进行取关`,[具体使用往下看](#取关店铺secret的说明)| -| `FruitShareCodes` | 东东农场互助码 | 非必须 | 填写规则请看 [jdFruitShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdFruitShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | +| `FRUITSHARECODES` | 东东农场互助码 | 非必须 | 填写规则请看 [jdFruitShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdFruitShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | | `PETSHARECODES` | 东东萌宠互助码 | 非必须 | 填写规则请看 [jdPetShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdPetShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | | `PLANT_BEAN_SHARECODES` | 种豆得豆互助码 | 非必须 | 填写规则请看 [jdPlantBeanShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdPlantBeanShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | | `SUPERMARKET_SHARECODES`| 京小超商圈互助码 | 非必须 | 填写规则请看 [jdSuperMarketShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdSuperMarketShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | +| `DDFACTORY_SHARECODES`| 东东工厂互助码 | 非必须 | 填写规则请看 [jdFactoryShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdFactoryShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | +| `DREAM_FACTORY_SHARE_CODES`| 京喜工厂互助码 | 非必须 | 填写规则请看 [jdDreamFactoryShareCodes.js](https://github.com/lxk0301/jd_scripts/blob/master/jdDreamFactoryShareCodes.js) 或见下方[互助码的填写规则](#互助码的填写规则) | | `TG_PROXY_HOST` | Telegram 代理的 IP | 非必须 | 代理类型为 http。例子:http代理 http://127.0.0.1:1080 则填写 127.0.0.1 | | `TG_PROXY_PORT` | Telegram 代理的端口 | 非必须 | 例子:http代理 http://127.0.0.1:1080 则填写 1080 | - +| `MONEY_TREE_SELL_FRUIT` | 摇钱树是否卖出金果 | 非必须 | 控制摇钱树脚本是否自动卖出金果兑换成金币,`true`卖出,`false`不卖出,默认`true` | +| `FACTORAY_WANTPRODUCT_NAME` | 东东工厂心仪商品 | 非必须 | 提供心仪商品名称(请尽量填写完整和别的商品有区分度),达到条件后兑换,如不提供则会兑换当前所选商品 | ##### 互助码的填写规则 diff --git a/iCloud.md b/iCloud.md index 1db8479..4066d16 100644 --- a/iCloud.md +++ b/iCloud.md @@ -36,6 +36,8 @@ ```javascript 'use strict'; exports.main_handler = async (event, context, callback) => { + //解决云函数热启动问题 + delete require.cache[require.resolve('./jd_xtg1.js')]; require('./jd_xtg1.js') //这里写你想要的脚本 require('./jd_xtg2.js') //这里写你想要的脚本 require('./jd_xtg3.js') //这里写你想要的脚本 @@ -44,8 +46,7 @@ exports.main_handler = async (event, context, callback) => { ``` 此时,同一时间点下,会同时执行多个脚本,触发器触发后,index.js文件中require()下的所有脚本都会被执行 -**优点**:同一时间下可以同时执行多个脚本,适合脚本种类少的repository,对脚本数量少的repository推荐使用此方案 -**缺点**:多个脚本不同时间点运行无法满足 +**优点**:同一时间下可以同时执行多个脚本,适合脚本种类少的repository,对脚本数量少的repository推荐使用此方案
**缺点**:多个脚本不同时间点运行无法满足 方案二:同一个仓库下不同的时间点,分别执行不同的脚本(类似GitHub Action执行机制) @@ -57,6 +58,8 @@ exports.main_handler = async (event, context, callback) => { 'use strict'; exports.main_handler = async (event, context, callback) => { for (const v of event["Message"].split("\r\n")) { + //解决云函数热启动问题 + delete require.cache[require.resolve(`./${v}.js`)]; console.log(v); require(`./${v}.js`) } @@ -66,14 +69,15 @@ exports.main_handler = async (event, context, callback) => { 此时触发管理按照下图中进行设置,附加信息选择“是”,内容填写需要传递执行的具体脚本文件名,以回车键换行。触发器触发后,附加信息栏内的脚本会被执行,设置多个不同时间点的触发器达到类似GitHub Action的效果 -**优点**:可以满足个性化需求,同一个repository下只需要设置不同的触发器,可以实现不同时间点分别执行不同的脚本 -**缺点**:repository下脚本过多,如果需要设置多个触发器,实现个性化运行效果,由于云函数的限制,最多只能设置10个 +**优点**:可以满足个性化需求,同一个repository下只需要设置不同的触发器,可以实现不同时间点分别执行不同的脚本
**缺点**:repository下脚本过多,如果需要设置多个触发器,实现个性化运行效果,由于云函数的限制,最多只能设置10个 [![B20KxI.png](https://s1.ax1x.com/2020/11/05/B20KxI.png)](https://imgchr.com/i/B20KxI) [![BRCG0H.png](https://s1.ax1x.com/2020/11/05/BRCG0H.png)](https://imgchr.com/i/BRCG0H) -**注意:方案一与方案二不能混合到同一个index.js文件中使用,同一个仓库下,二者只能选择其一。目前由于云函数热启动问题的存在,频繁的触发器启动,虽然日志显示“调用成功”,但实际内容却没有执行,方案一与方案二暂时无法规避此问题,期待之后能解决** - +**注意:**
+Ⅰ方案一与方案二不能混合到同一个index.js文件中使用,同一个仓库下,二者只能选择其一。
+Ⅱ感谢[issues#115](https://github.com/lxk0301/jd_scripts/issues/115)中的解决方案,目前云函数连续测试已经可以规避热启动问题了。
+Ⅲ在确保完全按照本教程设置的情况下测试云函数运行情况,对于部分人运行日志中出现某些脚本运行失败其他正常,并且错误提示带有strict字样的,请自行删除index.js中的```'use strict';```,再做测试
**增加cookie** @@ -110,11 +114,9 @@ let CookieJDs = [ ![iCloud2](./icon/iCloud2.png) -函数名称:可以自定义,比如为jd。 -运行环境:选择 “Nodejs 12.16”。 -创建方式:选择 “空白函数”。 +**函数名称**:可以自定义,比如为jd。
**运行环境**:选择 “Nodejs 12.16”。
**创建方式**:选择 “空白函数”。 -确保环境为Nodejs 12.16,执行方法改为:index.main_handler,提交方式建议选本地文件夹,然后从GitHub项目克隆Zip压缩包,解压成文件夹,然后点击这个上传把文件夹上传进来(记得node_modules文件夹一并上传),完了后点击下面的高级设置。 +确保环境为Nodejs 12.16,执行方法改为:index.main_handler,提交方式建议选本地文件夹,然后从GitHub项目克隆Zip压缩包,解压成文件夹,然后点击这个上传把文件夹上传进来(记得node_modules文件夹一并上传或者将node_modules文件夹上传到“层”,之后选择“函数管理”-“层管理”绑定上传好的层),完了后点击下面的高级设置。 ![iCloud3](./icon/iCloud3.png) @@ -132,14 +134,21 @@ let CookieJDs = [ ![BcGvM4.png](https://s1.ax1x.com/2020/11/04/BcGvM4.png) -![UTOOLS1604471299130.png](https://img01.sogoucdn.com/app/a/100520146/f8d70ea4f8e08d9e87ec8c13474f22c3) +创建触发器 + +![iCloud6](./icon/iCloud6.png) + +触发方式默认“**定时触发**”,定时任务名称随便起个名字,触发周期根据自己需要自行设置。 想进阶使用触发器的自行查看本文中方案一和方案二中的说明 关于触发周期中的自定义触发周期,使用的是 Cron表达式,这个自行学习下吧 + [Corn文档](https://cloud.tencent.com/document/product/583/9708#cron-.E8.A1.A8.E8.BE.BE.E5.BC.8F) +目前repo中按照每个脚本一个定时器的方式设置到云函数中,大约需要触发器10多个,由于云函数触发器限制最多10个,需要对触发器进行整合,整合后触发器保持在10个以内,以下设置仅供参考
+![iCloud5](./icon/iCloud5.png) 点击提交,所有流程就结束了。 diff --git a/icon/TG_PUSH1.png b/icon/TG_PUSH1.png new file mode 100644 index 0000000..0e2c8a1 Binary files /dev/null and b/icon/TG_PUSH1.png differ diff --git a/icon/TG_PUSH2.png b/icon/TG_PUSH2.png new file mode 100644 index 0000000..a9d8c58 Binary files /dev/null and b/icon/TG_PUSH2.png differ diff --git a/icon/TG_PUSH3.png b/icon/TG_PUSH3.png new file mode 100644 index 0000000..e213067 Binary files /dev/null and b/icon/TG_PUSH3.png differ diff --git a/icon/iCloud5.png b/icon/iCloud5.png new file mode 100644 index 0000000..d565183 Binary files /dev/null and b/icon/iCloud5.png differ diff --git a/icon/iCloud6.png b/icon/iCloud6.png new file mode 100644 index 0000000..8210a7f Binary files /dev/null and b/icon/iCloud6.png differ diff --git a/index.js b/index.js new file mode 100644 index 0000000..c70aaa6 --- /dev/null +++ b/index.js @@ -0,0 +1,26 @@ +//'use strict'; +exports.main_handler = async (event, context, callback) => { + try { + //如果想在一个定时触发器里面执行多个js文件需要在定时触发器的【附加信息】里面填写对应的名称,用 & 链接 + //例如我想一个定时触发器里执行jd_speed.js和jd_bean_change.js,在定时触发器的【附加信息】里面就填写 jd_speed&jd_bean_change + for (const v of event["Message"].split("&")) { + console.log(v); + var request = require('request'); + //1.执行自己上传的js文件 + //delete require.cache[require.resolve('./'+v+'.js')]; + //require('./'+v+'.js') + + //2.执行国内gitee远端js文件如果部署,在国内节点,选择1或2的方式 + //request('https://gitee.com/lxk0301/jd_scripts/raw/master/'+v+'.js', function (error, response, body) { + // eval(response.body) + //}) + + //3.执行github远端的js文件(因github的raw类型的文件被墙,此方法云函数不推荐) + request('https://raw.githubusercontent.com/lxk0301/jd_scripts/master/' + v + '.js', function (error, response, body) { + eval(response.body) + }) + } + } catch (e) { + console.error(e) + } +} diff --git a/jdCookie.js b/jdCookie.js index 8395dec..4eb2bb7 100644 --- a/jdCookie.js +++ b/jdCookie.js @@ -15,9 +15,14 @@ if (process.env.JD_COOKIE) { } else if (process.env.JD_COOKIE.indexOf('\n') > -1) { console.log(`您的cookie选择的是用换行隔开\n`) CookieJDs = process.env.JD_COOKIE.split('\n'); + } else if (process.env.JD_COOKIE.indexOf('\\n') > -1) { + //环境变量兼容腾讯云和docker下\n会被转义成\\n + console.log(`您的cookie选择的是用换行隔开\\n`) + CookieJDs = process.env.JD_COOKIE.split('\\n'); } else { - CookieJDs = process.env.JD_COOKIE.split(); + CookieJDs = [process.env.JD_COOKIE]; } + CookieJDs = [...new Set(CookieJDs)] console.log(`\n====================共有${CookieJDs.length}个京东账号Cookie=========\n`); console.log(`==================脚本执行- 北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}=====================\n`) // console.log(`\n==================脚本执行来自 github action=====================\n`) diff --git a/jdDreamFactoryShareCodes.js b/jdDreamFactoryShareCodes.js new file mode 100644 index 0000000..5f591dc --- /dev/null +++ b/jdDreamFactoryShareCodes.js @@ -0,0 +1,31 @@ +/* +京喜工厂互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// github action用户的好友互助码填写到Action->Settings->Secrets->new Secret里面(Name填写 PLANT_BEAN_SHARECODES(此处的Name必须按此来写,不能随意更改),内容处填写互助码,填写规则如下) +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let shareCodes = [ + 'V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=@Bo-jnVs_m9uBvbRzraXcSA==',//账号一的好友shareCode,不同好友中间用@符号隔开 + '1uzRU5HkaUgvy0AB5Q9VUg==@PDPM257r_KuQhil2Y7koNw==',//账号二的好友shareCode,不同好友中间用@符号隔开 +] +// 判断github action里面是否有东东萌宠互助码 +if (process.env.DREAM_FACTORY_SHARE_CODES) { + if (process.env.DREAM_FACTORY_SHARE_CODES.indexOf('&') > -1) { + console.log(`您的互助码选择的是用&隔开\n`) + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split('&'); + } else if (process.env.DREAM_FACTORY_SHARE_CODES.indexOf('\n') > -1) { + console.log(`您的互助码选择的是用换行隔开\n`) + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split('\n'); + } else { + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split(); + } +} else if (process.env.DREAM_FACTORY_SHARE_CODES) { + console.log(`由于您secret里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < shareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['shareCodes' + index] = shareCodes[i]; +} \ No newline at end of file diff --git a/jdFactoryShareCodes.js b/jdFactoryShareCodes.js new file mode 100644 index 0000000..99a5008 --- /dev/null +++ b/jdFactoryShareCodes.js @@ -0,0 +1,31 @@ +/* +东东工厂互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// github action用户的好友互助码填写到Action->Settings->Secrets->new Secret里面(Name填写 PLANT_BEAN_SHARECODES(此处的Name必须按此来写,不能随意更改),内容处填写互助码,填写规则如下) +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let shareCodes = [ + '',//账号一的好友shareCode,不同好友中间用@符号隔开 + '',//账号二的好友shareCode,不同好友中间用@符号隔开 +] +// 判断github action里面是否有东东工厂互助码 +if (process.env.DDFACTORY_SHARECODES) { + if (process.env.DDFACTORY_SHARECODES.indexOf('&') > -1) { + console.log(`您的互助码选择的是用&隔开\n`) + shareCodes = process.env.DDFACTORY_SHARECODES.split('&'); + } else if (process.env.DDFACTORY_SHARECODES.indexOf('\n') > -1) { + console.log(`您的互助码选择的是用换行隔开\n`) + shareCodes = process.env.DDFACTORY_SHARECODES.split('\n'); + } else { + shareCodes = process.env.DDFACTORY_SHARECODES.split(); + } +} else if (process.env.DDFACTORY_SHARECODES) { + console.log(`由于您secret里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < shareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['shareCodes' + index] = shareCodes[i]; +} \ No newline at end of file diff --git a/jdJxStoryShareCodes.js b/jdJxStoryShareCodes.js new file mode 100644 index 0000000..9453429 --- /dev/null +++ b/jdJxStoryShareCodes.js @@ -0,0 +1,30 @@ +/* +京喜故事互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等Node.js用户在此处填写京喜故事的好友码。 +// github action用户的好友互助码填写到Action->Settings->Secrets->new Secret里面(Name填写 JXSTORY_SHARECODES(此处的Name必须按此来写,不能随意更改),内容处填写互助码,填写规则如下) +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let shareCodes = [ + '',//账号一的好友shareCode,不同好友中间用@符号隔开 + '',//账号二的好友shareCode +] +// 判断github action里面是否有京喜故事互助码 +if (process.env.JXSTORY_SHARECODES) {if (process.env.JXSTORY_SHARECODES.indexOf('&') > -1) { + console.log(`您的互助码选择的是用&隔开\n`) + shareCodes = process.env.JXSTORY_SHARECODES.split('&'); + } else if (process.env.JXSTORY_SHARECODES.indexOf('\n') > -1) { + console.log(`您的互助码选择的是用换行隔开\n`) + shareCodes = process.env.JXSTORY_SHARECODES.split('\n'); + } else { + shareCodes = process.env.JXSTORY_SHARECODES.split(); + } +} else if (process.env.JXSTORY_SHARECODES) { + console.log(`由于您secret里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < shareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['shareCodes' + index] = shareCodes[i]; +} diff --git a/jdPlantBeanShareCodes.js b/jdPlantBeanShareCodes.js index 356cc89..3894909 100644 --- a/jdPlantBeanShareCodes.js +++ b/jdPlantBeanShareCodes.js @@ -8,7 +8,7 @@ // 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 // 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 let PlantBeanShareCodes = [ - '66j4yt3ebl5ierjljoszp7e4izzbzaqhi5k2unz2afwlyqsgnasq@olmijoxgmjutyrsovl2xalt2tbtfmg6sqldcb3q@e7lhibzb3zek27amgsvywffxx7hxgtzstrk2lba',//账号一的好友shareCode,不同好友中间用@符号隔开 + '66j4yt3ebl5ierjljoszp7e4izzbzaqhi5k2unz2afwlyqsgnasq@olmijoxgmjutyrsovl2xalt2tbtfmg6sqldcb3q@e7lhibzb3zek27amgsvywffxx7hxgtzstrk2lba@olmijoxgmjutyx55upqaqxrblt7f3h26dgj2riy',//账号一的好友shareCode,不同好友中间用@符号隔开 '4npkonnsy7xi3p6pjfxg6ct5gll42gmvnz7zgoy@6dygkptofggtp6ffhbowku3xgu@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy',//账号二的好友shareCode,不同好友中间用@符号隔开 ] // 判断github action里面是否有东东萌宠互助码 diff --git a/jd_818.js b/jd_818.js index 7fbeb49..5212741 100644 --- a/jd_818.js +++ b/jd_818.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-11-03 09:25:47 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-11-02 09:26:12 + * @Last Modified time: 2020-11-23 12:27:07 */ /* 京东手机狂欢城活动,每日可获得30+以上京豆(其中20京豆是往期奖励,需第一天参加活动后,第二天才能拿到) @@ -140,7 +140,7 @@ function listMeeting() { 'Accept': 'application/json, text/plain, */*', 'Connection':' keep-alive', 'Cookie': cookie, - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.14(0x17000e2a) NetType/4G Language/zh_CN', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Referer': `https://rdcseason.m.jd.com/?reloadWQPage=t_${Date.now()}`, 'Accept-Encoding': 'gzip, deflate, br' @@ -187,7 +187,7 @@ function listGoods() { 'Accept': 'application/json, text/plain, */*', 'Connection':' keep-alive', 'Cookie': cookie, - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.14(0x17000e2a) NetType/4G Language/zh_CN', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Referer': `https://rdcseason.m.jd.com/?reloadWQPage=t_${Date.now()}`, 'Accept-Encoding': 'gzip, deflate, br' @@ -233,7 +233,7 @@ function shopInfo() { 'Accept': 'application/json, text/plain, */*', 'Connection':' keep-alive', 'Cookie': cookie, - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.14(0x17000e2a) NetType/4G Language/zh_CN', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Referer': `https://rdcseason.m.jd.com/?reloadWQPage=t_${Date.now()}`, 'Accept-Encoding': 'gzip, deflate, br' @@ -286,7 +286,7 @@ function browseGoods(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -320,7 +320,7 @@ function getGoodsPrize(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -353,7 +353,7 @@ function browseShop(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -386,7 +386,7 @@ function getShopPrize(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -420,7 +420,7 @@ function browseMeeting(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -453,7 +453,7 @@ function getMeetingPrize(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -486,7 +486,7 @@ function myRank() { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -549,7 +549,7 @@ function saveJbean(id) { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com/", "Accept-Encoding": "gzip, deflate, br" @@ -633,7 +633,7 @@ function toHelp(code) { "Cookie": cookie, "Connection": "keep-alive", "Accept": "application/json, text/plain, */*", - "User-Agent": "jdapp;iPhone;9.1.0;14.0;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167348;supportBestPay/0;jdSupportDarkMode/0;pv/252.3;apprpd/Home_Main;ref/JDWebViewController;psq/2;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|695;jdv/0|kong|t_2010957099_|jingfen|3b5422e836e74037862fea3dcf1a6802|1600647811440|1600647814;adk/;app_device/IOS;pap/JA2015_311210|9.1.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Referer": "https://rdcseason.m.jd.com/", "Content-Length": "44", "Accept-Language": "zh-cn" @@ -665,7 +665,7 @@ function getHelp() { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "jdapp;iPhone;9.1.0;14.0;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167348;supportBestPay/0;jdSupportDarkMode/0;pv/255.2;apprpd/Home_Main;ref/JDMainPageViewController;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|701;jdv/0|kong|t_2010957099_|jingfen|3b5422e836e74037862fea3dcf1a6802|1600647811440|1600647814;adk/;app_device/IOS;pap/JA2015_311210|9.1.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com", "Accept-Encoding": "gzip, deflate, br" @@ -726,7 +726,7 @@ function getListJbean() { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "jdapp;iPhone;9.1.0;14.0;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167348;supportBestPay/0;jdSupportDarkMode/0;pv/255.2;apprpd/Home_Main;ref/JDMainPageViewController;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|701;jdv/0|kong|t_2010957099_|jingfen|3b5422e836e74037862fea3dcf1a6802|1600647811440|1600647814;adk/;app_device/IOS;pap/JA2015_311210|9.1.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com", "Accept-Encoding": "gzip, deflate, br" @@ -761,7 +761,7 @@ function getListIntegral() { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "jdapp;iPhone;9.1.0;14.0;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167348;supportBestPay/0;jdSupportDarkMode/0;pv/255.2;apprpd/Home_Main;ref/JDMainPageViewController;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|701;jdv/0|kong|t_2010957099_|jingfen|3b5422e836e74037862fea3dcf1a6802|1600647811440|1600647814;adk/;app_device/IOS;pap/JA2015_311210|9.1.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com", "Accept-Encoding": "gzip, deflate, br" @@ -797,7 +797,7 @@ function getListRank() { "Accept": "application/json, text/plain, */*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "jdapp;iPhone;9.1.0;14.0;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167348;supportBestPay/0;jdSupportDarkMode/0;pv/255.2;apprpd/Home_Main;ref/JDMainPageViewController;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|701;jdv/0|kong|t_2010957099_|jingfen|3b5422e836e74037862fea3dcf1a6802|1600647811440|1600647814;adk/;app_device/IOS;pap/JA2015_311210|9.1.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://rdcseason.m.jd.com", "Accept-Encoding": "gzip, deflate, br" @@ -847,7 +847,7 @@ function updateShareCodes(url = 'https://raw.githubusercontent.com/lxk0301/updat }) }) } -function updateShareCodesCDN(url = 'https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_shareCodes.json') { +function updateShareCodesCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam/master/jd_shareCodes.json') { return new Promise(resolve => { //https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_shareCodes.json //https://raw.githubusercontent.com/lxk0301/updateTeam/master/jd_shareCodes.json @@ -879,7 +879,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_bean_change.js b/jd_bean_change.js index 731870f..f5448a7 100644 --- a/jd_bean_change.js +++ b/jd_bean_change.js @@ -138,7 +138,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -175,7 +175,7 @@ function getJingBeanBalanceDetail(page) { "url": `https://api.m.jd.com/client.action?functionId=getJingBeanBalanceDetail`, "body": `body=${escape(JSON.stringify({"pageSize": "20", "page": page.toString()}))}&appid=ld`, "headers": { - 'User-Agent': 'JD4iPhone/167169 (iPhone; iOS 13.4.1; Scale/3.00)', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Host': 'api.m.jd.com', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie, diff --git a/jd_bean_home.js b/jd_bean_home.js new file mode 100644 index 0000000..84312da --- /dev/null +++ b/jd_bean_home.js @@ -0,0 +1,257 @@ +/* +领京豆额外奖励 +入口:首页-领京豆 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#领京豆额外奖励 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, tag=领京豆额外奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_bean_home.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, tag=领京豆额外奖励 + +===============Surge================= +领京豆额外奖励 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js + +============小火箭========= +领京豆额外奖励 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('领京豆额外奖励'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : ""}`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await jdBeanHome(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdBeanHome() { + await getTaskList() + await showMsg(); +} + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function getTaskList() { + return new Promise(resolve => { + const body = {"rnVersion": "4.7", "rnClient": "2", "source": "AppHome"}; + $.post(taskUrl('findBeanHome', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + let beanTask = data.data.floorList.filter(vo => vo.floorName === "种豆得豆定制化场景")[0] + if (!beanTask.viewed) { + await receiveTask() + await $.wait(3000) + } + + let tasks = data.data.floorList.filter(vo => vo.floorName === "赚京豆")[0]['stageList'] + for (let i = 0; i < tasks.length; ++i) { + const vo = tasks[i] + if (vo.viewed) continue + await receiveTask(vo.stageId, `4_${vo.stageId}`) + await $.wait(3000) + } + await award() + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveTask(itemId = "zddd", type = "3") { + return new Promise(resolve => { + const body = {"awardFlag": false, "itemId": itemId, "source": "home", "type": type}; + $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + console.log(`完成任务成功,进度${data.data.taskProgress}/${data.data.taskThreshold}`) + } + else{ + console.log(`完成任务失败,${data.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + + +function award() { + return new Promise(resolve => { + const body = {"awardFlag": true, "source": "home"}; + $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + console.log(`领奖成功,获得 ${data.data.beanNum} 个京豆`) + message += `领奖成功,获得 ${data.data.beanNum} 个京豆\n` + } else { + console.log(`领奖失败,${data.errorMessage}`) + message += `领奖失败,${data.errorMessage}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body) { + body["version"] = "9.0.0.1"; + body["monitor_source"] = "plant_app_plant_index"; + body["monitor_refer"] = ""; + return { + url: JD_API_HOST, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded" + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,o)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),h=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t))}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",o){const r=t=>{if(!t||!this.isLoon()&&this.isSurge())return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,r(o)):this.isQuanX()&&$notify(e,s,i,r(o)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_bean_sign.js b/jd_bean_sign.js index a013c92..10d51b3 100644 --- a/jd_bean_sign.js +++ b/jd_bean_sign.js @@ -1,7 +1,7 @@ /* 京豆签到,自用,可N个京东账号,IOS软件用户请使用 https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js Node.JS专用 -更新时间:2020-11-09 +更新时间:2020-11-27 从 github @ruicky改写而来 version v0.0.1 create by ruicky @@ -14,8 +14,9 @@ const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; const exec = require('child_process').execSync const fs = require('fs') const download = require('download'); -const path = "./result.txt"; -const JD_DailyBonusPath = "./JD_DailyBonus.js"; +let resultPath = "./result.txt"; +let JD_DailyBonusPath = "./JD_DailyBonus.js"; +let outPutUrl = './'; let cookiesArr = [], cookie = ''; if ($.isNode()) { @@ -29,9 +30,10 @@ if ($.isNode()) { $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); return; } + await requireConfig(); // 下载最新代码 await downFile(); - const content = await fs.readFileSync('./JD_DailyBonus.js', 'utf8') + const content = await fs.readFileSync(JD_DailyBonusPath, 'utf8') for (let i =0; i < cookiesArr.length; i++) { cookie = cookiesArr[i]; if (cookie) { @@ -40,7 +42,7 @@ if ($.isNode()) { $.nickName = ''; await TotalBean(); console.log(`*****************开始京东账号${$.index} ${$.nickName || $.UserName}京豆签到*******************\n`); - console.log(`⚠⚠⚠⚠⚠⚠⚠⚠ 如遇到Bark APP推送通知消息失败的,请换用其他通知方式,Bark对推送内容长度有限制 ⚠⚠⚠⚠⚠⚠⚠⚠⚠\n`) + console.log(`⚠️⚠️⚠️⚠️目前Bark APP推送通知消息对推送内容长度有限制,如使用此推送方式脚本会默认转换成简洁内容推送 ⚠️⚠️⚠️⚠️\n`) await changeFile(content); await execSign(); } @@ -52,11 +54,13 @@ async function execSign() { console.log(`\n开始执行脚本签到,请稍等`) try { if (notify.SCKEY || notify.BARK_PUSH || notify.DD_BOT_TOKEN || (notify.TG_BOT_TOKEN && notify.TG_USER_ID) || notify.IGOT_PUSH_KEY) { - await exec("node JD_DailyBonus.js >> result.txt"); + await exec(`${process.execPath} ${JD_DailyBonusPath} >> ${resultPath}`); + const notifyContent = await fs.readFileSync(resultPath, "utf8"); + console.log(`👇👇👇👇👇👇👇👇👇👇👇LOG记录👇👇👇👇👇👇👇👇👇👇👇\n${notifyContent}\n👆👆👆👆👆👆👆👆👆LOG记录👆👆👆👆👆👆👆👆👆👆👆`); } else { // 如果没有提供通知推送,则打印日志 console.log('没有提供通知推送,则打印脚本执行日志') - await exec(`node JD_DailyBonus.js`, { stdio: "inherit" }); + await exec(`${process.execPath} ${JD_DailyBonusPath}`, { stdio: "inherit" }); } // await exec("node JD_DailyBonus.js", { stdio: "inherit" }); // console.log('执行完毕', new Date(new Date().getTime() + 8 * 60 * 60 * 1000).toLocaleDateString()) @@ -64,11 +68,12 @@ async function execSign() { if ($.isNode()) { let notifyContent = ""; let BarkContent = ''; - if (fs.existsSync(path)) { - notifyContent = await fs.readFileSync(path, "utf8"); + if (fs.existsSync(resultPath)) { + notifyContent = await fs.readFileSync(resultPath, "utf8"); const barkContentStart = notifyContent.indexOf('【签到概览】') const barkContentEnd = notifyContent.length; if (process.env.JD_BEAN_SIGN_STOP_NOTIFY === 'true') return + if (notify.BARK_PUSH) process.env.JD_BEAN_SIGN_NOTIFY_SIMPLE = 'true'; if (process.env.JD_BEAN_SIGN_NOTIFY_SIMPLE === 'true') { if (barkContentStart > -1 && barkContentEnd > -1) { BarkContent = notifyContent.substring(barkContentStart, barkContentEnd); @@ -90,7 +95,7 @@ async function execSign() { } //运行完成后,删除下载的文件 console.log('运行完成后,删除下载的文件\n') - await deleteFile(path);//删除result.txt + await deleteFile(resultPath);//删除result.txt await deleteFile(JD_DailyBonusPath);//删除JD_DailyBonus.js console.log(`*****************京东账号${$.index} ${$.nickName || $.UserName}京豆签到完成*******************\n`); } catch (e) { @@ -112,7 +117,12 @@ async function downFile () { } else { url = 'https://cdn.jsdelivr.net/gh/NobyDa/Script@master/JD-DailyBonus/JD_DailyBonus.js'; } - await download(url, './') + try { + await download(url, outPutUrl); + console.log('文件下载完毕'); + } catch (e) { + console.log("文件下载异常:" + e); + } } async function changeFile (content) { @@ -154,7 +164,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -200,7 +210,17 @@ function downloadUrl(url = 'https://raw.githubusercontent.com/NobyDa/Script/mast }) }) } - +function requireConfig() { + return new Promise(resolve => { + const file = 'jd_bean_sign.js'; + fs.access(file, fs.constants.W_OK, (err) => { + resultPath = err ? '/tmp/result.txt' : resultPath; + JD_DailyBonusPath = err ? '/tmp/JD_DailyBonus.js' : JD_DailyBonusPath; + outPutUrl = err ? '/tmp/' : outPutUrl; + resolve() + }); + }) +} function timeFormat(time) { let date; if (time) { diff --git a/jd_blueCoin.js b/jd_blueCoin.js index 352e39c..34a85a9 100644 --- a/jd_blueCoin.js +++ b/jd_blueCoin.js @@ -1,7 +1,7 @@ /* 京小超兑换奖品 脚本地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js 感谢@yangtingxiao提供PR -更新时间:2020-11-05 +更新时间:2020-11-23 支持京东多个账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js ======================quantumultx=============== @@ -18,7 +18,7 @@ const $ = new Env('京小超兑换奖品'); const notify = $.isNode() ? require('./sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let coinToBeans = $.getdata('coinToBeans') || 0; //兑换多少数量的京豆(20或者1000),0默认兑换不兑换,如需兑换把0改成20或者1000,或者'商品名称'(商品名称放到单引号内)即可 +let coinToBeans = $.getdata('coinToBeans') || 20; //兑换多少数量的京豆(20或者1000),0表示不兑换,默认兑换20京豆,如需兑换把0改成20或者1000,或者'商品名称'(商品名称放到单引号内)即可 let jdNotify = false;//是否开启静默运行,默认false关闭(即:奖品兑换成功后会发出通知提示) //IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; @@ -55,6 +55,7 @@ const JD_API_HOST = `https://api.m.jd.com/api?appid=jdsupermarket`; $.nickName = ''; await TotalBean(); console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + console.log(`目前暂无兑换酒类的奖品功能,即使输入酒类名称,脚本也会提示下架\n`) if (!$.isLogin) { $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); @@ -73,7 +74,7 @@ const JD_API_HOST = `https://api.m.jd.com/api?appid=jdsupermarket`; } if (`${coinToBeans}` !== '0') { await smtgHome();//查询蓝币数量,是否满足兑换的条件 - await smtg_queryPrize(); + await PrizeIndex(); } else { console.log('查询到您设置的是不兑换京豆选项,现在为您跳过兑换京豆。如需兑换,请去BoxJs设置或者修改脚本coinToBeans\n') } @@ -83,7 +84,131 @@ const JD_API_HOST = `https://api.m.jd.com/api?appid=jdsupermarket`; })() .catch((e) => $.logErr(e)) .finally(() => $.done()) - +async function PrizeIndex() { + await smtg_queryPrize(); + // await smtg_materialPrizeIndex();//兑换酒类奖品,此兑换API与之前的兑换京豆类的不一致,故目前无法进行 + // const prizeList = [...$.queryPrizeData, ...$.materialPrizeIndex]; + const prizeList = [...$.queryPrizeData]; + if (`${coinToBeans}` === '1000') { + if (prizeList[1].beanType === 'BeanPackage') { + console.log(`查询换${prizeList[1].title}ID成功,ID:${prizeList[1].prizeId}`) + $.title = prizeList[1].title; + $.blueCost = prizeList[1].blueCost; + } else { + console.log(`查询换1000京豆ID失败`) + $.beanerr = `东哥今天不给换`; + return ; + } + if (prizeList[1].inStock === 506) { + $.beanerr = `失败,1000京豆领光了,请明天再来`; + return ; + } + if (prizeList[1].targetNum === prizeList[1].finishNum) { + $.beanerr = `${prizeList[1].subTitle}`; + return ; + } + //兑换1000京豆 + if ($.totalBlue > $.blueCost) { + await smtg_obtainPrize(prizeList[1].prizeId); + } else { + console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); + $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; + } + } else if (`${coinToBeans}` === '20') { + if (prizeList[0].beanType === 'Bean') { + console.log(`查询换${prizeList[0].title}ID成功,ID:${prizeList[0].prizeId}`) + $.title = prizeList[0].title; + $.blueCost = prizeList[0].blueCost; + } else { + console.log(`查询换万能的京豆ID失败`) + $.beanerr = `东哥今天不给换`; + return ; + } + if (prizeList[0].inStock === 506) { + console.log(`失败,万能的京豆领光了,请明天再来`); + $.beanerr = `失败,万能的京豆领光了,请明天再来`; + return ; + } + if (prizeList[0].targetNum === prizeList[0].finishNum) { + $.beanerr = `${prizeList[0].subTitle}`; + return ; + } + //兑换万能的京豆(1-20京豆) + if ($.totalBlue > $.blueCost) { + await smtg_obtainPrize(prizeList[0].prizeId,1000); + } else { + console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); + $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; + } + } else { + //自定义输入兑换 + let prizeId = '', i; + for (let index = 0; index < prizeList.length; index ++) { + if (prizeList[index].title.indexOf(coinToBeans) > -1) { + prizeId = prizeList[index].prizeId; + i = index; + $.title = prizeList[index].title; + $.blueCost = prizeList[index].blueCost; + } + } + if (prizeId) { + if (prizeList[i].inStock === 506 || prizeList[i].inStock === -1) { + console.log(`失败,您输入设置的${coinToBeans}领光了,请明天再来`); + $.beanerr = `失败,您输入设置的${coinToBeans}领光了,请明天再来`; + return ; + } + if ((prizeList[i].targetNum) && prizeList[i].targetNum === prizeList[i].finishNum) { + $.beanerr = `${prizeList[0].subTitle}`; + return ; + } + if ($.totalBlue > $.blueCost) { + await smtg_obtainPrize(prizeId); + } else { + console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); + $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; + } + } else { + console.log(`奖品兑换列表[${coinToBeans}]已下架,请检查APP是否存在此商品,如存在请检查您的输入是否正确`); + $.beanerr = `奖品兑换列表[${coinToBeans}]已下架`; + } + } +} +//查询白酒类奖品列表API +function smtg_materialPrizeIndex(timeout = 0) { + return new Promise((resolve) => { + setTimeout( ()=>{ + let url = { + url : `${JD_API_HOST}&functionId=smtg_materialPrizeIndex&clientVersion=8.0.0&client=m&body=%7B%22channel%22:%221%22%7D&t=${Date.now()}`, + headers : { + 'Origin' : `https://jdsupermarket.jd.com`, + 'Cookie' : cookie, + 'Connection' : `keep-alive`, + 'Accept' : `application/json, text/plain, */*`, + 'Referer' : `https://jdsupermarket.jd.com/game/?tt=1597540727225`, + 'Host' : `api.m.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Accept-Language' : `zh-cn` + } + } + $.post(url, async (err, resp, data) => { + try { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode !== 0) { + $.beanerr = `${data.data.bizMsg}`; + return + } + $.materialPrizeIndex = data.data.result.prizes || []; + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + }) + },timeout) + }) +} //查询任务 function smtg_queryPrize(timeout = 0){ return new Promise((resolve) => { @@ -112,89 +237,7 @@ function smtg_queryPrize(timeout = 0){ } if (data.data.bizCode === 0) { const { prizeList } = data.data.result; - if (`${coinToBeans}` === '1000') { - if (prizeList[1].beanType === 'BeanPackage') { - console.log(`查询换${prizeList[1].title}ID成功,ID:${prizeList[1].prizeId}`) - $.title = prizeList[1].title; - $.blueCost = prizeList[1].blueCost; - } else { - console.log(`查询换1000京豆ID失败`) - $.beanerr = `东哥今天不给换`; - return ; - } - if (prizeList[1].inStock === 506) { - $.beanerr = `失败,1000京豆领光了,请明天再来`; - return ; - } - if (prizeList[1].targetNum === prizeList[1].finishNum) { - $.beanerr = `${prizeList[1].subTitle}`; - return ; - } - //兑换1000京豆 - if ($.totalBlue > $.blueCost) { - await smtg_obtainPrize(prizeList[1].prizeId); - } else { - console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); - $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; - } - } else if (`${coinToBeans}` === '20') { - if (prizeList[0].beanType === 'Bean') { - console.log(`查询换${prizeList[0].title}ID成功,ID:${prizeList[0].prizeId}`) - $.title = prizeList[0].title; - $.blueCost = prizeList[0].blueCost; - } else { - console.log(`查询换万能的京豆ID失败`) - $.beanerr = `东哥今天不给换`; - return ; - } - if (prizeList[0].inStock === 506) { - console.log(`失败,万能的京豆领光了,请明天再来`); - $.beanerr = `失败,万能的京豆领光了,请明天再来`; - return ; - } - if (prizeList[0].targetNum === prizeList[0].finishNum) { - $.beanerr = `${prizeList[0].subTitle}`; - return ; - } - //兑换万能的京豆(1-20京豆) - if ($.totalBlue > $.blueCost) { - await smtg_obtainPrize(prizeList[0].prizeId,1000); - } else { - console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); - $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; - } - } else { - //自定义输入兑换 - let prizeId = '', i; - for (let index = 0; index < prizeList.length; index ++) { - if (prizeList[index].title.indexOf(coinToBeans) > -1) { - prizeId = prizeList[index].prizeId; - i = index; - $.title = prizeList[index].title; - $.blueCost = prizeList[index].blueCost; - } - } - if (prizeId) { - if (prizeList[i].inStock === 506) { - console.log(`失败,您输入设置的${coinToBeans}领光了,请明天再来`); - $.beanerr = `失败,您输入设置的${coinToBeans}领光了,请明天再来`; - return ; - } - if (prizeList[i].targetNum === prizeList[i].finishNum) { - $.beanerr = `${prizeList[0].subTitle}`; - return ; - } - if ($.totalBlue > $.blueCost) { - await smtg_obtainPrize(prizeId); - } else { - console.log(`兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`); - $.beanerr = `兑换失败,您目前蓝币${$.totalBlue}个,不足以兑换${$.title}所需的${$.blueCost}个`; - } - } else { - console.log(`奖品兑换列表[${coinToBeans}]已下架,请检查APP是否存在此商品,如存在请检查您的输入是否正确`); - $.beanerr = `奖品兑换列表[${coinToBeans}]已下架`; - } - } + $.queryPrizeData = data.data.result.prizeList || []; } } } catch (e) { @@ -321,7 +364,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -364,7 +407,7 @@ function taskUrl(function_id, body = {}) { return { url: `${JD_API_HOST}&functionId=${function_id}&clientVersion=8.0.0&client=m&body=${escape(JSON.stringify(body))}&t=${Date.now()}`, headers: { - 'User-Agent': 'jdapp;iPhone;9.0.8;13.6;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Host': 'api.m.jd.com', 'Cookie': cookie, 'Referer': 'https://jdsupermarket.jd.com/game', diff --git a/jd_car.js b/jd_car.js new file mode 100644 index 0000000..7c91bdc --- /dev/null +++ b/jd_car.js @@ -0,0 +1,321 @@ +/* +京东汽车,签到满500赛点可兑换500京豆,一天运行一次即可 +长期活动 +活动入口:首页👉京东汽车👉屏幕右中部,车主福利 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东汽车 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车 + +===============Surge================= +京东汽车 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js + +============小火箭========= +京东汽车 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('京东汽车'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://car-member.jd.com/api/'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : ""}`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await jdCar(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdCar() { + await sign() + await $.wait(1000) + await mission() + await $.wait(1000) + await getPoint() +} + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function sign() { + return new Promise(resolve => { + $.post(taskUrl('v1/user/sign'), (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + message += `签到失败,${data.error.msg}\n` + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log(`签到成功,获得${data.data.point},已签到${data.data.signDays}天`) + message += `签到成功,获得${data.data.point},已签到${data.data.signDays}天\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function mission() { + return new Promise(resolve => { + $.get(taskUrl('v1/user/mission'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + let missions = data.data.missionList + for (let i = 0; i < missions.length; ++i) { + const mission = missions[i] + if (mission['missionStatus'] === 0 && (mission['missionType'] === 1 || mission['missionType'] === 5)) { + console.log(`去做任务:${mission['missionName']}`) + await doMission(mission['missionId']) + await $.wait(1000) // 等待防黑 + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function doMission(missionId) { + return new Promise(resolve => { + $.post(taskPostUrl('v1/game/mission', {"missionId": missionId}), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log("任务领取成功") + await receiveMission(missionId) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveMission(missionId) { + return new Promise(resolve => { + $.post(taskPostUrl('v1/user/mission/receive', {"missionId": missionId}), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log("任务完成成功") + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getPoint() { + return new Promise(resolve => { + $.get(taskUrl('v1/user/point'), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + if (data.data.remainPoint >= data.data.oncePoint) { + console.log(`当前赛点:${data.data.remainPoint}/${data.data.oncePoint},可以兑换京豆,请打开APP兑换`) + message += `当前赛点:${data.data.remainPoint}/${data.data.oncePoint},可以兑换京豆,请打开APP兑换\n` + }else{ + console.log(`当前赛点:${data.data.remainPoint}/${data.data.oncePoint}无法兑换京豆`) + message += `当前赛点:${data.data.remainPoint}/${data.data.oncePoint},无法兑换京豆\n` + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}${function_id}?timestamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "car-member.jd.com", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}${function_id}?timestamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + body: JSON.stringify(body), + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json;charset=UTF-8", + "Host": "car-member.jd.com", + "activityid": "39443aee3ff74fcb806a6f755240d127", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_club_lottery.js b/jd_club_lottery.js index d21a5a2..bf13da4 100644 --- a/jd_club_lottery.js +++ b/jd_club_lottery.js @@ -2,7 +2,7 @@ * @Author: lxk0301 * @Date: 2020-11-03 20:35:07 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-10-12 20:37:10 + * @Last Modified time: 2020-11-23 12:27:09 摇京豆(京东APP首页-领京豆-摇京豆) 更新时间:2020-10-12 Modified from https://github.com/Zero-S1/JD_tools/blob/master/JD_vvipclub.py @@ -78,6 +78,8 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; async function clubLottery() { await doTasks();//做任务 await getFreeTimes();//获取摇奖次数 + await vvipclub_receive_lottery_times();//新版:领取一次免费的机会 + await vvipclub_shaking_info();//新版:查询多少次摇奖次数 await shaking();//开始摇奖 } async function doTasks() { @@ -121,6 +123,20 @@ async function doTasks() { } } async function shaking() { + for (let i = 0; i < new Array($.leftShakingTimes).fill('').length; i++) { + console.log(`开始新版-摇奖`) + // await $.wait(500); + const newShakeBeanRes = await vvipclub_shaking_lottery(); + if (newShakeBeanRes.success) { + console.log(`新版-剩余摇奖次数:${newShakeBeanRes.data.remainLotteryTimes}`) + if (newShakeBeanRes.data && newShakeBeanRes.data.rewardBeanAmount) { + $.prizeBeanCount += newShakeBeanRes.data.rewardBeanAmount; + console.log(`恭喜你,中奖了,获得${newShakeBeanRes.data.rewardBeanAmount}京豆\n`) + } else { + console.log(`未中奖\n`) + } + } + } for (let i = 0; i < new Array($.freeTimes).fill('').length; i++) { console.log(`开始摇奖`) await $.wait(1000); @@ -140,6 +156,106 @@ function showMsg() { } } //====================API接口================= +//查询剩余摇奖次数API +function vvipclub_shaking_info() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_shaking_info`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + if (data.success) { + $.leftShakingTimes = data.data.leftShakingTimes;//剩余抽奖次数 + console.log(`新版——摇奖次数${$.leftShakingTimes}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//新版摇奖API +function vvipclub_shaking_lottery() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_shaking_lottery&body=%7B%7D`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//领取新版本摇一摇一次免费的次数 +function vvipclub_receive_lottery_times() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_receive_lottery_times`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} //查询多少次机会 function getFreeTimes() { return new Promise(resolve => { @@ -233,7 +349,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -261,13 +377,13 @@ function TotalBean() { }) }) } -function taskUrl(function_id, body = {}) { +function taskUrl(function_id, body = {}, appId = 'vip_h5') { return { - url: `${JD_API_HOST}?functionId=${function_id}&appid=vip_h5&body=${escape(JSON.stringify(body))}&_=${Date.now()}`, + url: `${JD_API_HOST}?functionId=${function_id}&appid=${appId}&body=${escape(JSON.stringify(body))}&_=${Date.now()}`, headers: { 'Cookie': cookie, 'Host': 'api.m.jd.com', - 'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1`, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Referer': 'https://vip.m.jd.com/newPage/reward/123dd/slideContent?page=focus', } } diff --git a/jd_collectProduceScore.js b/jd_collectProduceScore.js index a49766f..b34f2c5 100644 --- a/jd_collectProduceScore.js +++ b/jd_collectProduceScore.js @@ -124,7 +124,7 @@ function taskPostUrl(functionId, body = {}) { url: `${JD_API_HOST}?functionId=${functionId}`, body: `functionId=${functionId}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, headers: { - 'User-Agent': 'jdapp;iPhone;9.2.0;14.1;;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'api.m.jd.com', 'Cookie': cookie, diff --git a/jd_daily_egg.js b/jd_daily_egg.js index 60dd668..b19ac6b 100644 --- a/jd_daily_egg.js +++ b/jd_daily_egg.js @@ -1,3 +1,9 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-10 14:10:27 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-11-20 14:11:01 + */ /* 京东金融-天天提鹅 定时收鹅蛋,兑换金币 @@ -8,7 +14,6 @@ const $ = new Env('天天提鹅'); let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; const notify = $.isNode() ? require('./sendNotify') : ''; -let jdNotify = false;//是否开启推送互助码 //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; if ($.isNode()) { @@ -43,11 +48,6 @@ if ($.isNode()) { } continue } - message = ''; - subTitle = ''; - goodsUrl = ''; - taskInfoKey = []; - option = {}; await jdDailyEgg(); } } @@ -175,7 +175,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -215,7 +215,7 @@ function taskUrl(function_id, body) { 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`, 'Host' : `ms.jr.jd.com`, 'Connection' : `keep-alive`, - 'User-Agent' : `jdapp;iPhone;9.0.0;13.4.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/F75E8AED-CB48-4EAC-A213-E8CE4018F214;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167237;supportBestPay/0;jdSupportDarkMode/0;pv/1287.19;apprpd/MyJD_GameMain;ref/https%3A%2F%2Fuua.jr.jd.com%2Fuc-fe-wxgrowing%2Fmoneytree%2Findex%2F%3Fchannel%3Dyxhd%26lng%3D113.325843%26lat%3D23.204628%26sid%3D2d98e88cf7d182f60d533476c2ce777w%26un_area%3D19_1601_50258_51885;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|3485;jdv/0|kong|t_1000170135|tuiguang|notset|1593059927172|1593059927;adk/;app_device/IOS;pap/JA2015_311210|9.0.0|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'User-Agent' : $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Referer' : `https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index`, 'Accept-Language' : `zh-cn` } diff --git a/jd_digital_floor.js b/jd_digital_floor.js new file mode 100644 index 0000000..8763900 --- /dev/null +++ b/jd_digital_floor.js @@ -0,0 +1,393 @@ +/* +数码加购京豆 +共计25京豆,一天运行一次即可 +活动时间:2020-12-4 到 2020-12-11 +活动入口:https://prodev.m.jd.com/mall/active/nKxVyPnuLwAsQSTfidZ9z4RKVZy/index.html#/ +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_digital_floor.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#数码加购京豆 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_digital_floor.js, tag=数码加购京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_digital_floor.js, tag=数码加购京豆 + +===============Surge================= +数码加购京豆 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_digital_floor.js + +============小火箭========= +数码加购京豆 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_digital_floor.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('数码加购京豆'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +const inviteCodes = [`40cd108f-9eed-4897-b795-45a5b221cd6b@49efb480-d6d7-456b-a4e0-14b170b161e0@`,'9d4262a5-1a02-4ae7-8a86-8d070d531464@687b14e0-ce0a-45eb-bf46-71aa0da05f18']; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://digital-floor.m.jd.com/adf/index/'; +!(async () => { + await requireConfig() + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await shareCodesFormat() + await jdDigitalFloor() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdDigitalFloor() { + $.bean = 0 + await helpFriends() + await getUserInfo() + await getTaskList() + await showMsg() +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + let res = await doSupport(code); + await $.wait(500) + if (res===5) { + // 助力次数已用完 + break + } + } +} +function doSupport(shareId) { + return new Promise(resolve => { + $.post(taskPostUrl('doSupport',`shareId=${shareId}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`助力好友${shareId}成功`) + await supportCheck(shareId) + }else{ + console.log(`助力好友失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data.data); + } + }) + }) +} +function supportCheck(shareId) { + return new Promise(resolve => { + $.post(taskPostUrl('supportCheck',`shareId=${shareId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`检查助力,助力好友${shareId}成功`) + }else{ + console.log(`检查助力失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function getUserInfo() { + return new Promise(resolve => { + $.get(taskUrl('shareInfo'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + $.shareId = data.data.shareId + console.log(`\n您的${$.name}好友助力邀请码:${data.data.shareId}\n`) + message += `\n您的${$.name}好友助力邀请码:${data.data.shareId}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getTaskList() { + return new Promise(resolve => { + $.get(taskUrl('indexInfo'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + const tasks = data.data + for(let i = 0; i < tasks.length; ++i){ + const task = tasks[i] + console.log(`去加购物车:${task['skuName']}`) + await browseSku(task['skuId']) + } + message += `共获得${$.bean}个京豆\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getPrize(skuId) { + return new Promise(resolve => { + $.post(taskPostUrl('getPrize',`skuId=${skuId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + $.bean += data.data + console.log(`任务领奖成功,获得${data.data}个京豆`) + }else{ + console.log(`任务领奖失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function browseSku(skuId) { + return new Promise(resolve => { + $.post(taskPostUrl('browseSku',`skuId=${skuId}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`任务领取成功`) + await $.wait(5000) + await getPrize(skuId) + } else{ + console.log(data) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = null //await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = [] //$.isNode() ? require('./jdSplitShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +function taskPostUrl(function_id, body) { + return { + url: `${JD_API_HOST}${function_id}?t=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + body: body, + headers: { + 'Host': 'digital-floor.m.jd.com', + 'pragma': 'no-cache', + 'cache-control': 'no-cache', + 'accept': 'application/json, text/plain, */*', + 'dnt': '1', + 'content-type': 'application/x-www-form-urlencoded', + 'origin': 'https://pro.m.jd.com', + 'sec-fetch-site': 'same-site', + 'sec-fetch-mode': 'cors', + 'sec-fetch-dest': 'empty', + 'referer': 'https://pro.m.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', + 'Cookie': cookie, + 'user-agent': 'jdapp;iPhone;9.2.0;14.0;53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2;network/wifi;supportApplePay/3;hasUPPay/1;pushNoticeIsOpen/0;model/iPhone10,2;addressid/138413818;hasOCPay/0;appBuild/167408;supportBestPay/1;jdSupportDarkMode/0;pv/1710.16;apprpd/WorthBuy_List;ref/JDWebViewController;psq/2;ads/;psn/53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2|5870;jdv/0|kong|t_1000089893_|tuiguang|9a75f97593f344eb9c46b99e196608d2|1605846323;adk/;app_device/IOS;pap/JA2015_311210|9.2.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1',} + } +} +function taskUrl(function_id) { + return { + url: `${JD_API_HOST}${function_id}?t=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + headers: { + 'Host': 'digital-floor.m.jd.com', + 'pragma': 'no-cache', + 'cache-control': 'no-cache', + 'accept': 'application/json, text/plain, */*', + 'dnt': '1', + 'content-type': 'application/x-www-form-urlencoded', + 'origin': 'https://pro.m.jd.com', + 'sec-fetch-site': 'same-site', + 'sec-fetch-mode': 'cors', + 'sec-fetch-dest': 'empty', + 'referer': 'https://pro.m.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', + 'Cookie': cookie, + 'user-agent': 'jdapp;iPhone;9.2.0;14.0;53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2;network/wifi;supportApplePay/3;hasUPPay/1;pushNoticeIsOpen/0;model/iPhone10,2;addressid/138413818;hasOCPay/0;appBuild/167408;supportBestPay/1;jdSupportDarkMode/0;pv/1710.16;apprpd/WorthBuy_List;ref/JDWebViewController;psq/2;ads/;psn/53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2|5870;jdv/0|kong|t_1000089893_|tuiguang|9a75f97593f344eb9c46b99e196608d2|1605846323;adk/;app_device/IOS;pap/JA2015_311210|9.2.0|IOS 14.0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1',} + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index 29b6119..ccb4640 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -1,265 +1,1439 @@ /* 京东京喜工厂 -未完,待续 +更新时间:2020-12-07 +活动入口 :京东APP->游戏与互动->查看更多->京喜工厂 +或者: 京东APP首页搜索 "玩一玩" ,造物工厂即可 + + +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京喜工厂 +10 * * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js, tag=京喜工厂, enabled=true + +================Loon============== +[Script] +cron "10 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js,tag=京喜工厂 + +===============Surge================= +京喜工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js + +============小火箭========= +京喜工厂 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js, cronexpr="10 * * * *", timeout=200, enable=true + */ -const $hammer = (() => { - const isRequest = "undefined" != typeof $request, - isSurge = "undefined" != typeof $httpClient, - isQuanX = "undefined" != typeof $task; - const log = (...n) => { for (let i in n) console.log(n[i]) }; - const alert = (title, body = "", subtitle = "", link = "", option) => { - if (isSurge) return $notification.post(title, subtitle, body, link); - if (isQuanX) return $notify(title, subtitle, (link && !body ? link : body), option); - log("==============📣系统通知📣=============="); - log("title:", title, "subtitle:", subtitle, "body:", body, "link:", link); + +const $ = new Env('京喜工厂'); +const JD_API_HOST = 'https://m.jingxi.com'; + +const notify = $.isNode() ? require('./sendNotify') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +const tuanActiveId = `jfkcidGQavswLOBcAWljrw==`; +const jxOpenUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D`; +let cookiesArr = [], cookie = '', message = ''; +const inviteCodes = ['V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=', 'PDPM257r_KuQhil2Y7koNw==', "gB99tYLjvPcEFloDgamoBw=="]; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; - const read = key => { - if (isSurge) return $persistentStore.read(key); - if (isQuanX) return $prefs.valueForKey(key); - }, - write = (key, val) => { - if (isSurge) return $persistentStore.write(key, val); - if (isQuanX) return $prefs.setValueForKey(key, val); - }; - const request = (method, params, callback) => { - /** - * - * params(): {url: , headers: , body: } | - * - * callback( - * error, - * {status: , headers: , body: } | "" - * ) - * - */ - let options = {}; - if (typeof params == "string") { - options.url = params; - } else { - options.url = params.url; - if (typeof params == "object") { - params.headers && (options.headers = params.headers); - params.body && (options.body = params.body); - } - } - method = method.toUpperCase(); - - const writeRequestErrorLog = function (m, u) { - return err => { - log("=== request error -s--"); - log(`${m} ${u}`, err); - log("=== request error -e--"); - }; - }(method, options.url); - - if (isSurge) { - const _runner = method == "GET" ? $httpClient.get : $httpClient.post; - return _runner(options, (error, response, body) => { - if (error == null || error == "") { - response.body = body; - callback("", response); - } else { - writeRequestErrorLog(error); - callback(error, ""); - } - }); - } - if (isQuanX) { - options.method = method; - $task.fetch(options).then( - response => { - response.status = response.statusCode; - delete response.statusCode; - callback("", response); - }, - reason => { - writeRequestErrorLog(reason.error); - callback(reason.error, ""); - } - ); - } - }; - const done = (value = {}) => { - if (isQuanX) return isRequest ? $done(value) : null; - if (isSurge) return isRequest ? $done(value) : $done(); - }; - return { isRequest, isSurge, isQuanX, log, alert, read, write, request, done }; -})(); - - -//京东接口地址 -const JD_API_HOST = 'https://wq.jd.com'; - -//直接用NobyDa的jd cookie -// const cookie = $hammer.read('CookieJD'); -const cookie = 'unpl=V2_ZzNtbUAHRRx0DxZVch9aBWIBRllLAhMSfQtDUnxLWVdnBhpcclRCFnQUR1JnGFUUZAMZXURcQhJFOEZVehhdDWMEGllyZ0sdGwgLVBUaMgUqTl9tQVdzFEUIQlx%252bGlwAZAAXW0tRRhZ9DU5TfRpsNWcFIl1DVkIUcgBBVnkaVDU8VnxbEgJDESFYRFNyHllQVwIiXHJWc0MbCEdVehteBmYAEhBCU0sQdghDV3gcWgxhBhFVR19EE3Y4R2R4; PPRD_P=CT.138912.3.26-UUID.1594174344038855825195; __jda=122270672.1594174344038855825195.1594174344.1594619829.1594628524.29; __jdb=122270672.4.1594174344038855825195|29.1594628524; __jdc=122270672; __jdv=122270672%7Ckong%7Ct_1000170136%7Ctuiguang%7Cnotset%7C1594569450665; __wga=1594631325352.1594630264664.1594619828892.1594619828892.3.2; _tj_rvurl=https%3A//wq.jd.com/cube/front/activePublish/dream_factory_report/380556.html%3Fptag%3D138912.3.26%26lng%3D113.321134%26lat%3D23.139617%26sid%3D6c732f3e20be25526c2e67df89e488dw%26un_area%3D19_1601_50258_51885; cid=8; mba_muid=1594174344038855825195.33.1594631325409; mba_sid=33.18; retina=1; shshshfp=3f7499d014a4f06d56edfb5378a934ee; shshshfpb=w5O9mqDoHWvVwOS9jAYB%20zg%3D%3D; shshshsID=ed6e17a13e5b4921d09de669e2b06c89_3_1594631325584; wqmnx1=MDEyNjM1M3B3am1ncmZyZHR0My4mMTImMjlzYzNlNjdld2ExMDIxNjg1NnBoOTsuNWE0ZWVjYmRla2lEQS0tLS1ENXV0ZTNVL3NpTzFlaDFkczAzaFA7dTEzcGV5ZG9yZXYxcE1HYWVKZXJDbzs0Ly9hOTBjZmEyMTswZzAwdGFvfDUwMTY7O2RlO0o1Mi5JMztsLlA7IG4gX2tjWHBiNi5LLGVrby80cEpLMWY3bjI0MllPT1UhSCU%3D; wxa_level=1; pt_key=app_openAAJfBSQbAEBjl86WMnH-4g3Is6PISRQsx5CU-pQolK0klfaTVHmW5nfZL7DkOGhtRWp6ttQKfdDSiHZ1el6DX2SEjWkotlT2; pt_pin=%E8%A2%AB%E6%8A%98%E5%8F%A0%E7%9A%84%E8%AE%B0%E5%BF%8633; pwdt_id=%E8%A2%AB%E6%8A%98%E5%8F%A0%E7%9A%84%E8%AE%B0%E5%BF%8633; sid=6c732f3e20be25526c2e67df89e488dw; wq_area=19_1601_3633%7C3; visitkey=270851475495567; jxsid=15946198288819114076; sc_width=414; webp=0; shshshfpa=b134218e-f14e-6005-fa8e-52d2bc02126f-1594364440'; -let shareCodes = [ - 'V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=', -]; -let factoryId, productionId, userTaskStatusList, dailyTask = [], produceTask = []; -const name = '京喜工厂'; -let message = ''; -let subTitle = ''; -const Task = step() -Task.next(); -function* step() { - const startTime = Date.now(); - yield userInfo(); - yield collectElectricity(); - yield investElectric(); - yield taskList(); - //yield produceTaskFun();//生产任务 - const end = ((Date.now() - startTime) / 1000).toFixed(2); - console.log(`\n完成${name}脚本耗时: ${end} 秒\n`); - $hammer.alert(name, message, subTitle); +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]) } +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + $.ele = 0; + $.pickEle = 0; + $.pickFriendEle = 0; + $.friendList = []; + $.canHelpFlag = true;//能否助力朋友 + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); -function produceTaskFun() { - for (let item of produceTask) { - if (item.awardStatus !== 1) { - if (item.completedTimes >= item.targetTimes) { - const url = `/newtasksys/newtasksys_front/Award?source=dreamfactory&bizCode=dream_factory&taskId=${item.taskId}&sceneval=2&g_login_type=1`; - request(url).then((res) => { - console.log(`每日任务完成结果${JSON.stringify(res)}}`); - try { - if (res.ret === 0) { - console.log(`${item.taskName}任务完成`) - } - } catch (e) { - console.log(`${item.taskName}任务异常`) - } - }) + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue } + await jdDreamFactory() } } - Task.next(); +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdDreamFactory() { + await userInfo(); + await QueryFriendList();//查询今日招工情况以及剩余助力次数 + await joinLeaderTuan();//参团 + await helpFriends(); + if (!$.unActive) return + await getUserElectricity(); + await taskList(); + await investElectric(); + await QueryHireReward();//收取招工电力 + await PickUp();//收取自家的地下零件 + await stealFriend(); + await tuanActivity(); + await QueryAllTuan(); + await exchangeProNotify(); + await showMsg(); } + // 收取发电机的电力 -function collectElectricity() { - const url = `/dreamfactory/generator/CollectCurrentElectricity?zone=dream_factory&apptoken=&pgtimestamp=&phoneID=&factoryid=${factoryId}&doubleflag=1&sceneval=2`; - request(url).then((res) => { - try { - if (res.ret === 0) { - console.log(`成功从发电机收取${res.data.CollectElectricity}电力`); - } - Task.next(); - } catch (e) { - console.log('收集电力异常') - } - }) -} -// 投入电力 -function investElectric() { - const url = `/dreamfactory/userinfo/InvestElectric?zone=dream_factory&productionId=${productionId}&sceneval=2&g_login_type=1`; - request(url).then((res) => { - try { - if (res.ret === 0) { - console.log(`成功投入电力${res.data.investElectric}电力`); - message += `【投入电力】${res.data.investElectric}`; - } else { - console.log(`投入失败,${res.message}`); - } - Task.next(); - } catch (e) { - console.log('收集电力异常') +function collectElectricity(facId = $.factoryId, help = false, master) { + return new Promise(async resolve => { + // let url = `/dreamfactory/generator/CollectCurrentElectricity?zone=dream_factory&apptoken=&pgtimestamp=&phoneID=&factoryid=${facId}&doubleflag=1&sceneval=2&g_login_type=1`; + // if (help && master) { + // url = `/dreamfactory/generator/CollectCurrentElectricity?zone=dream_factory&factoryid=${facId}&master=${master}&sceneval=2&g_login_type=1`; + // } + let body = `factoryid=${facId}&apptoken=&pgtimestamp=&phoneID=&doubleflag=1`; + if (help && master) { + body += `factoryid=${facId}&master=${master}`; } - }) -} -// 初始化任务 -function taskList() { - const url = `/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&bizCode=dream_factory&sceneval=2&g_login_type=1`; - request(url).then((res) => { - try { - //console.log(`${JSON.stringify(res)}`) - //console.log(res) - if (res.ret === 0) { - userTaskStatusList = res.data.userTaskStatusList; - for (let item of res.data.userTaskStatusList) { - if (item.dateType === 2) { - dailyTask.push(item); - } - if (item.dateType === 1) { - produceTask.push(item); - } - } - Task.next(); - } - } catch (e) { - console.log('初始化任务异常') - } - }).catch((error) => { - console.log(error) - }) -} -//初始化个人信息 -function userInfo() { - const url = `/dreamfactory/userinfo/GetUserInfo?zone=dream_factory&pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=&sceneval=2`; - request(url).then((response) => { - try { - // taskInfo = res.data.result.taskInfos; - if (response.ret === 0) { - const { data } = response; - // !data.productionList && !data.factoryList - if (data.factoryList && data.productionList) { - const production = data.productionList[0]; - const factory = data.factoryList[0]; - factoryId = factory.factoryId;//工厂ID - productionId = production.productionId;//商品ID - subTitle = data.user.pin; - console.log(`\n我的分享码\n${data.user.encryptPin}\n`); - // console.log(`进度:${(production.investedElectric/production.needElectric).toFixed(2) * 100}%\n`); - message += `【生产进度】${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%\n`; - Task.next(); + $.get(taskurl(`generator/CollectCurrentElectricity`, body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) } else { - return $hammer.alert(name, '\n【提示】此账号京喜工厂活动未开始\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 开启活动\n'); + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (help) { + $.ele += Number(data.data['loginPinCollectElectricity']) + console.log(`帮助好友收取 ${data.data['CollectElectricity']} 电力,获得 ${data.data['loginPinCollectElectricity']} 电力`); + message += `【帮助好友】帮助成功,获得 ${data.data['loginPinCollectElectricity']} 电力\n` + } else { + $.ele += Number(data.data['CollectElectricity']) + console.log(`收取 ${data.data['CollectElectricity']} 电力`); + message += `【收取发电站】收取成功,获得 ${data.data['CollectElectricity']} 电力\n` + } + } else { + if (help) { + console.log(`收取好友电力失败:${data.msg}\n`); + } else { + console.log(`收取电力失败:${data.msg}\n`); + } + } + } } - } else { - Task.return(); - } - } catch (e) { - console.log(e); - console.log('初始化任务异常'); - } - }) -} - -//等待一下 -function sleep(s) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve(); - }, s * 1000); - }) -} - -async function request(url, body = {}) { - await sleep(2); //歇口气儿, 不然会报操作频繁 - return new Promise((resolve, reject) => { - $hammer.request('GET', taskurl(url, body), (error, response) => { - if(error){ - $hammer.log("Error:", error); - }else{ - //console.log(response.body) - resolve(JSON.parse(response.body)); + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); } }) }) } -function taskurl(url, body) { +// 投入电力 +function investElectric() { + return new Promise(async resolve => { + // const url = `/dreamfactory/userinfo/InvestElectric?zone=dream_factory&productionId=${$.productionId}&sceneval=2&g_login_type=1`; + $.get(taskurl('userinfo/InvestElectric', `productionId=${$.productionId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.ret === 0) { + console.log(`成功投入电力${data.data.investElectric}电力`); + message += `【投入电力】投入成功,共计 ${data.data.investElectric} 电力\n`; + } else { + console.log(`投入失败,${data.msg}`); + message += `【投入电力】投入失败,${data.msg}\n`; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化任务 +function taskList() { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&bizCode=dream_factory&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('GetUserTaskStatusList'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + let userTaskStatusList = data['data']['userTaskStatusList']; + for (let i = 0; i < userTaskStatusList.length; i++) { + const vo = userTaskStatusList[i]; + if (vo['awardStatus'] !== 1) { + if (vo.completedTimes >= vo.targetTimes) { + console.log(`任务:${vo.description}可完成`) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } else { + switch (vo.taskType) { + case 2: // 逛一逛任务 + case 6: // 浏览商品任务 + case 9: // 开宝箱 + for (let i = vo.completedTimes; i <= vo.configTargetTimes; ++i) { + console.log(`去做任务:${vo.taskName}`) + await doTask(vo.taskId) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } + break + case 4: // 招工 + break + case 5: + // 收集类 + break + case 1: // 登陆领奖 + default: + break + } + } + } + } + console.log(`完成任务:共领取${$.ele}电力`) + message += `【每日任务】领奖成功,共计 ${$.ele} 电力\n`; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 获得用户电力情况 +function getUserElectricity() { + return new Promise(async resolve => { + // const url = `/dreamfactory/generator/QueryCurrentElectricityQuantity?zone=dream_factory&factoryid=${$.factoryId}&sceneval=2&g_login_type=1` + $.get(taskurl(`generator/QueryCurrentElectricityQuantity`, `factoryid=${$.factoryId}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`\nnextCollectDoubleFlag::${data.data.nextCollectDoubleFlag}`); + console.log(`nextCollectDoubleType::${data.data.nextCollectDoubleType}\n`); + $.log(`下次集满收取${data.data.nextCollectDoubleFlag === 1 ? '可' : '不可'}双倍电力`) + console.log(`发电机:当前 ${data.data.currentElectricityQuantity} 电力,最大值 ${data.data.maxElectricityQuantity} 电力`) + if (data.data.nextCollectDoubleFlag === 1) { + if (data.data.currentElectricityQuantity === data.data.maxElectricityQuantity && data.data.doubleElectricityFlag) { + console.log(`发电机:电力可翻倍并收获`) + // await shareReport(); + await collectElectricity() + } else { + message += `【发电机电力】当前 ${data.data.currentElectricityQuantity} 电力,未达到收获标准\n` + } + } else { + //再收取双倍电力达到上限时,直接收取,不再等到满级 + await collectElectricity() + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +//查询有多少的招工电力可收取 +function QueryHireReward() { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/HireAward?zone=dream_factory&date=${new Date().Format("yyyyMMdd")}&type=0&sceneval=2&g_login_type=1` + $.get(taskurl('friend/QueryHireReward'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + for (let item of data['data']['hireReward']) { + if (item.date !== new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).Format("yyyyMMdd")) { + await hireAward(item.date, item.type); + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 收取招工电力 +function hireAward(date, type = 0) { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/HireAward?zone=dream_factory&date=${new Date().Format("yyyyMMdd")}&type=0&sceneval=2&g_login_type=1` + $.get(taskurl('friend/HireAward', `date=${date}&type=${type}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`打工电力:收取成功`) + message += `【打工电力】:收取成功\n` + } else { + console.log(`打工电力:收取失败,${data.msg}`) + message += `【打工电力】收取失败,${data.msg}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function helpFriends() { + if ($.canHelpFlag) { + await shareCodesFormat(); + for (let code of $.newShareCodes) { + if (code) { + if ($.encryptPin === code) { + console.log(`不能为自己助力,跳过`); + continue; + } + const assistFriendRes = await assistFriend(code); + if (assistFriendRes && assistFriendRes['ret'] === 0) { + console.log(`助力朋友:${code}成功,因一次只能助力一个,故跳出助力`) + break + } else if (assistFriendRes && assistFriendRes['ret'] === 11009) { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg},跳出助力`); + break + } else { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg}`) + } + } + } + } else { + $.log(`今日助力好友机会已耗尽\n`); + } +} +// 帮助用户 +function assistFriend(sharepin) { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/AssistFriend?zone=dream_factory&sharepin=${escape(sharepin)}&sceneval=2&g_login_type=1` + const options = { + 'url': `https://m.jingxi.com/dreamfactory/friend/AssistFriend?zone=dream_factory&sharepin=${escape(sharepin)}&sceneval=2&g_login_type=1`, + 'headers': { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/index.html", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // if (data['ret'] === 0) { + // console.log(`助力朋友:${sharepin}成功`) + // } else { + // console.log(`助力朋友[${sharepin}]失败:${data.msg}`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//查询助力招工情况 +function QueryFriendList() { + return new Promise(async resolve => { + $.get(taskurl('friend/QueryFriendList'), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const { assistListToday = [], assistNumMax, hireListToday = [], hireNumMax } = data; + if (assistListToday.length === assistNumMax) { + $.canHelpFlag = false; + } + $.log(`【今日招工进度】${hireListToday.length}/${hireNumMax}`); + message += `【招工进度】${hireListToday.length}/${hireNumMax}\n`; + } else { + console.log(`QueryFriendList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 任务领奖 +function completeTask(taskId, taskName) { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/Award?source=dreamfactory&bizCode=dream_factory&taskId=${taskId}&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('Award', taskId), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + switch (data['data']['awardStatus']) { + case 1: + $.ele += Number(data['data']['prizeInfo'].replace('\\n', '')) + console.log(`领取${taskName}任务奖励成功,收获:${Number(data['data']['prizeInfo'].replace('\\n', ''))}电力`); + break + case 1013: + case 0: + console.log(`领取${taskName}任务奖励失败,任务已领奖`); + break + default: + console.log(`领取${taskName}任务奖励失败,${data['msg']}`) + break + } + // if (data['ret'] === 0) { + // console.log("做任务完成!") + // } else { + // console.log(`异常:${JSON.stringify(data)}`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 完成任务 +function doTask(taskId) { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/DoTask?source=dreamfactory&bizCode=dream_factory&taskId=${taskId}&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('DoTask', taskId), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log("做任务完成!") + } else { + console.log(`DoTask异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化个人信息 +function userInfo() { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetUserInfo', `pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.unActive = true;//标记是否开启了京喜活动或者选购了商品进行生产 + $.encryptPin = ''; + $.shelvesList = []; + if (data.factoryList && data.productionList) { + const production = data.productionList[0]; + const factory = data.factoryList[0]; + const productionStage = data.productionStage; + $.factoryId = factory.factoryId;//工厂ID + $.productionId = production.productionId;//商品ID + $.commodityDimId = production.commodityDimId; + $.encryptPin = data.user.encryptPin; + // subTitle = data.user.pin; + await GetCommodityDetails();//获取已选购的商品信息 + if (productionStage['productionStageAwardStatus'] === 1) { + $.log(`可以开红包了\n`); + await DrawProductionStagePrize();//领取红包 + } else { + $.log(`再加${productionStage['productionStageProgress']}电力可开红包\n`) + } + console.log(`当前电力:${data.user.electric}`) + console.log(`当前等级:${data.user.currentLevel}`) + console.log(`分享码: ${data.user.encryptPin}`); + console.log(`生产进度:${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%`); + message += `【京东账号${$.index}】${$.nickName}\n` + message += `【生产商品】${$.productName}\n`; + message += `【当前等级】${data.user.userIdentity} ${data.user.currentLevel}\n`; + message += `【生产进度】${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%\n`; + if (production.investedElectric >= production.needElectric) { + $.log(`可以对方商品了`) + // await exchangeProNotify() + } + } else { + $.unActive = false;//标记是否开启了京喜活动或者选购了商品进行生产 + if (!data.factoryList) { + console.log(`【提示】京东账号${$.index}[${$.nickName}]京喜工厂活动未开始\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 开启活动\n`); + // $.msg($.name, '【提示】', `京东账号${$.index}[${$.nickName}]京喜工厂活动未开始\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 开启活动`); + } else if (data.factoryList && !data.productionList) { + console.log(`【提示】京东账号${$.index}[${$.nickName}]京喜工厂未选购商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选购\n`) + // $.msg($.name, '【提示】', `京东账号${$.index}[${$.nickName}]京喜工厂未选择商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选择商品`); + } + } + } else { + console.log(`GetUserInfo异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询当前生产的商品名称 +function GetCommodityDetails() { + return new Promise(async resolve => { + // const url = `/dreamfactory/diminfo/GetCommodityDetails?zone=dream_factory&sceneval=2&g_login_type=1&commodityId=${$.commodityDimId}`; + $.get(taskurl('diminfo/GetCommodityDetails', `commodityId=${$.commodityDimId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.productName = data['commodityList'][0].name; + } else { + console.log(`GetCommodityDetails异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 查询已完成商品 +function GetShelvesList(pageNo = 1) { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetShelvesList', `pageNo=${pageNo}&pageSize=12`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const { shelvesList } = data; + if (shelvesList) { + $.shelvesList = [...$.shelvesList, ...shelvesList]; + pageNo ++ + GetShelvesList(pageNo); + } + } else { + console.log(`GetShelvesList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//领取红包 +function DrawProductionStagePrize() { + return new Promise(async resolve => { + // const url = `/dreamfactory/userinfo/DrawProductionStagePrize?zone=dream_factory&sceneval=2&g_login_type=1&productionId=${$.productionId}`; + $.get(taskurl('userinfo/DrawProductionStagePrize', `productionId=${$.productionId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`领取红包功能(测试中):${data}`); + // if (safeGet(data)) { + // data = JSON.parse(data); + // if (data['ret'] === 0) { + // + // } else { + // console.log(`异常:${JSON.stringify(data)}`) + // } + // } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function PickUp(encryptPin = $.encryptPin, help = false) { + $.pickUpMyselfComponent = true; + const GetUserComponentRes = await GetUserComponent(encryptPin); + if (GetUserComponentRes && GetUserComponentRes['ret'] === 0) { + const { componentList } = GetUserComponentRes['data']; + if (componentList && componentList.length <= 0) { + if (help) { + $.log(`好友【${encryptPin}】地下暂无零件可收`) + } else { + $.log(`自家地下暂无零件可收`) + } + $.pickUpMyselfComponent = false; + } + for (let item of componentList) { + await $.wait(1000); + const PickUpComponentRes = await PickUpComponent(item['placeId'], encryptPin); + if (PickUpComponentRes) { + if (PickUpComponentRes['ret'] === 0) { + const data = PickUpComponentRes['data']; + if (help) { + console.log(`收取好友[${encryptPin}]零件成功:获得${data['increaseElectric']}电力\n`); + $.pickFriendEle += data['increaseElectric']; + } else { + console.log(`收取自家零件成功:获得${data['increaseElectric']}电力\n`); + $.pickEle += data['increaseElectric']; + } + } else { + if (help) { + console.log(`收好友[${encryptPin}]零件失败:${PickUpComponentRes.msg},直接跳出`) + } else { + console.log(`收自己地下零件失败:${PickUpComponentRes.msg},直接跳出`); + $.pickUpMyselfComponent = false; + } + break + } + } + } + } +} +function GetUserComponent(pin = $.encryptPin) { + return new Promise(resolve => { + $.get(taskurl('usermaterial/GetUserComponent', `pin=${pin}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + + } else { + console.log(`GetUserComponent失败:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//收取地下随机零件电力API + +function PickUpComponent(index, encryptPin) { + return new Promise(resolve => { + $.get(taskurl('usermaterial/PickUpComponent', `placeId=${index}&pin=${encryptPin}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // if (data['ret'] === 0) { + // data = data['data']; + // if (help) { + // console.log(`收取好友[${encryptPin}]零件成功:获得${data['increaseElectric']}电力\n`); + // $.pickFriendEle += data['increaseElectric']; + // } else { + // console.log(`收取自家零件成功:获得${data['increaseElectric']}电力\n`); + // $.pickEle += data['increaseElectric']; + // } + // } else { + // if (help) { + // console.log(`收好友[${encryptPin}]零件失败:${JSON.stringify(data)}`) + // } else { + // console.log(`收零件失败:${JSON.stringify(data)}`) + // } + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//偷好友的电力 +async function stealFriend() { + if (!$.pickUpMyselfComponent) { + $.log(`今日收取零件已达上限,偷好友零件也达到上限,故跳出`) + return + } + await getFriendList(); + $.friendList = [...new Set($.friendList)]; + for (let i = 0; i < $.friendList.length; i++) { + let pin = $.friendList[i];//好友的encryptPin + if (pin === 'V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=' || pin === 'Bo-jnVs_m9uBvbRzraXcSA==') { + continue + } + await PickUp(pin, true); + // await getFactoryIdByPin(pin);//获取好友工厂ID + // if ($.stealFactoryId) await collectElectricity($.stealFactoryId,true, pin); + } +} +function getFriendList(sort = 0) { + return new Promise(async resolve => { + $.get(taskurl('friend/QueryFactoryManagerList', `sort=${sort}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + if (data.list && data.list.length <= 0) { + console.log(`查询好友列表完成,共${$.friendList.length}好友,下面开始拾取好友地下的零件\n`); + return + } + let friendsEncryptPins = []; + for (let item of data.list) { + friendsEncryptPins.push(item.encryptPin); + } + $.friendList = [...$.friendList, ...friendsEncryptPins]; + if (!$.isNode()) return + await getFriendList(data.sort); + } else { + console.log(`QueryFactoryManagerList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getFactoryIdByPin(pin) { + return new Promise((resolve, reject) => { + // const url = `/dreamfactory/userinfo/GetUserInfoByPin?zone=dream_factory&pin=${pin}&sceneval=2`; + $.get(taskurl('userinfo/GetUserInfoByPin', `pin=${pin}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (data.data.factoryList) { + //做此判断,有时候返回factoryList为null + // resolve(data['data']['factoryList'][0]['factoryId']) + $.stealFactoryId = data['data']['factoryList'][0]['factoryId']; + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function tuanActivity() { + const tuanConfig = await QueryActiveConfig(); + if (tuanConfig && tuanConfig.ret === 0) { + const { activeId, surplusOpenTuanNum, tuanId } = tuanConfig['data']['userTuanInfo']; + console.log(`今日剩余开团次数:${surplusOpenTuanNum}次`); + $.surplusOpenTuanNum = surplusOpenTuanNum; + if (!tuanId && surplusOpenTuanNum > 0) { + //开团 + $.log(`准备开团`) + await CreateTuan(); + } else if (tuanId) { + //查询词团信息 + const QueryTuanRes = await QueryTuan(activeId, tuanId); + if (QueryTuanRes && QueryTuanRes.ret === 0) { + const { tuanInfo } = QueryTuanRes.data; + for (let item of tuanInfo) { + const { realTuanNum, tuanNum, userInfo } = item; + $.log(`\n开团情况:${realTuanNum}/${tuanNum}\n`); + if (realTuanNum === tuanNum) { + for (let user of userInfo) { + if (user.encryptPin === $.encryptPin) { + if (user.receiveElectric && user.receiveElectric > 0) { + console.log(`您在${new Date(user.joinTime * 1000).toLocaleString()}开团奖励已经领取成功\n`) + if ($.surplusOpenTuanNum > 0) await CreateTuan(); + } else { + $.log(`开始领取开团奖励`); + await tuanAward(item.tuanActiveId, item.tuanId);//isTuanLeader + } + } + } + } else { + $.log(`\n此团未达领取团奖励人数:${tuanNum}人\n`) + } + } + } + } + } +} +//可获取开团后的团ID,如果团ID为空并且surplusOpenTuanNum>0,则可继续开团 +//如果团ID不为空,则查询QueryTuan() +function QueryActiveConfig() { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/QueryActiveConfig?activeId=${escape(tuanActiveId)}&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + const { userTuanInfo } = data['data']; + console.log(`\n团活动ID ${userTuanInfo.activeId}`); + console.log(`团ID ${userTuanInfo.tuanId}\n`); + } else { + console.log(`QueryActiveConfig异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function QueryTuan(activeId, tuanId) { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/QueryTuan?activeId=${escape(activeId)}&tuanId=${escape(tuanId)}&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + // $.log(`\n开团情况:${data.data.tuanInfo.realTuanNum}/${data.data.tuanInfo.tuanNum}\n`) + } else { + console.log(`异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//开团API +function CreateTuan() { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/CreateTuan?activeId=${escape(tuanActiveId)}&isOpenApp=1&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`开团成功tuanId为\n${data.data['tuanId']}`); + } else { + console.log(`异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function joinLeaderTuan() { + await updateTuanIds(); + if (!$.tuanIdS) await updateTuanIdsCDN(); + for (let tuanId of $.tuanIdS.tuanIds) { + if (!tuanId) continue + await JoinTuan(tuanId); + } +} +function JoinTuan(tuanId) { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/JoinTuan?activeId=${escape(tuanActiveId)}&tuanId=${escape(tuanId)}&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html?exchange=%7B%22activeId%22:%22ilOin38J30PcT9xnWbx9lw%3D%3D%22,%22sTuanId%22:%22QvqM7GtgQQJUO8jaz1CYBA%3D%3D%22,%22sPin%22:%22V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k%3D%22,%22sType%22:%22101%22%7D&ptag=139022.1.2?srv=jinshusongjin_https://wq.jd.com/cube/front/activePublish/dream_factory_report/380556.html_jing", + "User-Agent": "jdpingou" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`参团成功\n${JSON.stringify(data)}\n`); + } else { + console.log(`参团失败:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询所有的团情况(自己开团以及参加别人的团) +function QueryAllTuan() { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/QueryAllTuan?activeId=${escape(tuanActiveId)}&pageNo=1&pageSize=10&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;" + } + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + const { tuanInfo } = data; + for (let item of tuanInfo) { + if (item.tuanNum === item.realTuanNum) { + // console.log(`参加团主【${item.tuanLeader}】已成功`) + const { userInfo } = item; + for (let item2 of userInfo) { + if (item2.encryptPin === $.encryptPin) { + if (item2.receiveElectric && item2.receiveElectric > 0) { + console.log(`${new Date(item2.joinTime * 1000).toLocaleString()}参加团主【${item2.nickName}】的奖励已经领取成功`) + } else { + console.log(`开始领取${new Date(item2.joinTime * 1000).toLocaleString()}参加团主【${item2.nickName}】的奖励`) + await tuanAward(item.tuanActiveId, item.tuanId, item.tuanLeader === $.encryptPin);//isTuanLeader + } + } + } + } else { + console.log(`${new Date(item.beginTime * 1000).toLocaleString()}参加团主【${item.tuanLeader}】失败`) + } + } + } else { + console.log(`QueryAllTuan异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//开团人的领取奖励API +function tuanAward(activeId, tuanId, isTuanLeader = true) { + return new Promise((resolve) => { + const options = { + 'url': `https://m.jingxi.com/dreamfactory/tuan/Award?activeId=${escape(activeId)}&tuanId=${escape(tuanId)}&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;" + } + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (isTuanLeader) { + console.log(`开团奖励(团长)${data.data['electric']}领取成功`); + message += `【开团(团长)奖励】${data.data['electric']}领取成功\n`; + if ($.surplusOpenTuanNum > 0) { + $.log(`开团奖励(团长)已领取,准备开团`); + await CreateTuan(); + } + } else { + console.log(`参团奖励${data.data['electric']}领取成功`); + message += `【参团奖励】${data.data['electric']}领取成功\n`; + } + } else if (data['ret'] === 10212) { + console.log(`${JSON.stringify(data)}`); + + if (isTuanLeader && $.surplusOpenTuanNum > 0) { + $.log(`团奖励已领取,准备开团`); + await CreateTuan(); + } + } else { + console.log(`异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function updateTuanIds(url = 'https://raw.githubusercontent.com/lxk0301/updateTeam/master/jd_updateFactoryTuanId.json') { + return new Promise(resolve => { + $.get({url}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + } else { + $.tuanIdS = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function updateTuanIdsCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam/master/jd_updateFactoryTuanId.json') { + return new Promise(resolve => { + $.get({url}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + } else { + $.tuanIdS = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function checkExchange() { + +} +//商品可兑换时的通知 +async function exchangeProNotify() { + await GetShelvesList(); + let exchangeEndTime, exchangeEndHours, nowHours; + //脚本运行的UTC+8时区的时间戳 + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); + if ($.shelvesList && $.shelvesList.length > 0) console.log(`\n 商品名 兑换状态`) + for (let shel of $.shelvesList) { + console.log(`${shel['name']} ${shel['exchangeStatus'] === 1 ? '未兑换' : shel['exchangeStatus'] === 2 ? '已兑换' : '兑换超时'}`) + if (shel['exchangeStatus'] === 1) { + exchangeEndTime = shel['exchangeEndTime'] * 1000; + $.picture = shel['picture']; + // 兑换截止时间点 + exchangeEndHours = new Date(exchangeEndTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).getHours(); + //兑换截止时间(年月日 时分秒) + $.exchangeEndTime = new Date(exchangeEndTime + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('zh', {hour12: false}); + //脚本运行此时的时间点 + nowHours = nowTimes.getHours(); + } + } + if (exchangeEndTime) { + //比如兑换(超时)截止时间是2020/12/8 09:20:04,现在时间是2020/12/6 + if (nowTimes < exchangeEndTime) { + //还可以兑换 + // 一:在兑换超时这一天(2020/12/8 09:20:04)的前2小时内通知 + if ((exchangeEndTime - nowTimes) <= 3600000 * 2) { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + } + //二:在兑换超时日期前的时间一天通知三次(2020/12/6 9,10,11点,以及在2020/12/7 9,10,11点各通知一次) + if (nowHours === exchangeEndHours || nowHours === (exchangeEndHours + 1) || nowHours === (exchangeEndHours + 2)) { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, {'open-url': jxOpenUrl, 'media-url': $.picture}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + } + } else { + //兑换已超时 + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, {'open-url': jxOpenUrl}) + await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, { url: jxOpenUrl }) + } + } +} +async function showMsg() { + return new Promise(async resolve => { + message += `【收取自己零件】${$.pickUpMyselfComponent ? `获得${$.pickEle}电力` : `今日已达上限`}\n`; + message += `【收取好友零件】${$.pickUpMyselfComponent ? `获得${$.pickFriendEle}电力` : `今日已达上限`}\n`; + let ctrTemp; + if ($.isNode() && process.env.DREAMFACTORY_NOTIFY_CONTROL) { + ctrTemp = `${process.env.DREAMFACTORY_NOTIFY_CONTROL}` === 'false'; + } else if ($.getdata('jdDreamFactory')) { + ctrTemp = $.getdata('jdDreamFactory') === 'false'; + } else { + ctrTemp = `${jdNotify}` === 'false'; + } + if (ctrTemp) { + $.msg($.name, '', message); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${message}`); + } + } else if (new Date().getHours() === 22) { + $.msg($.name, '', `${message}`) + $.log(`\n${message}`); + } else { + $.log(`\n${message}`); + } + resolve() + }) +} +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `http://api.turinglabs.net/api/v1/jd/jxfactory/read/${randomCount}/`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = $.isNode() ? require('./jdDreamFactoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function taskurl(functionId, body = '') { return { - url: `${JD_API_HOST}${url}`, + url: `${JD_API_HOST}/dreamfactory/${functionId}?zone=dream_factory&${body}&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now()}`, headers: { - 'Cookie' : cookie, - 'Host': 'wq.jd.com', + 'Cookie': cookie, + 'Host': 'm.jingxi.com', 'Accept': '*/*', 'Connection': 'keep-alive', - 'User-Agent': 'jdapp;iPhone;9.0.4;13.5.1;;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': 'jdpingou;iPhone;3.14.4;14.0;ae75259f6ca8378672006fc41079cd8c90c53be8;network/wifi;model/iPhone10,2;appBuild/100351;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/62;pap/JA2015_311210;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', 'Accept-Language': 'zh-cn', 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', 'Accept-Encoding': 'gzip, deflate, br', } } -} \ No newline at end of file +} +function newtasksysUrl(functionId, taskId) { + let url = `${JD_API_HOST}/newtasksys/newtasksys_front/${functionId}?source=dreamfactory&bizCode=dream_factory&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now()}`; + if (taskId) { + url += `&taskId=${taskId}`; + } + return { + url, + "headers": { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;", + 'Accept-Language': 'zh-cn', + 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} +Date.prototype.Format = function (fmt) { //author: meizz + var o = { + "M+": this.getMonth() + 1, //月份 + "d+": this.getDate(), //日 + "h+": this.getHours(), //小时 + "m+": this.getMinutes(), //分 + "s+": this.getSeconds(), //秒 + "q+": Math.floor((this.getMonth() + 3) / 3), //季度 + "S": this.getMilliseconds() //毫秒 + }; + if (/(y+)/.test(fmt)) + fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(fmt)) + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_ds.js b/jd_ds.js new file mode 100644 index 0000000..abcdbd6 --- /dev/null +++ b/jd_ds.js @@ -0,0 +1,198 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-27 09:19:21 + * @Last Modified by: shylocks https://github.com/shylocks + * @Last Modified time: 2020-12-7 17:39:02 + */ +/* +京东代属脚本,类似十元街,⚠️⚠️⚠️⚠️限校园用户可使用,其他用户签到失败无京豆 +一周签到下来可获得30京豆,一天任意时刻运行一次即可 + +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js +参考github@jidesheng6修改而来 +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东代属 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_ds.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属 + +===============Surge================= +京东代属 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js + +============小火箭========= +京东代属 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('京东代属'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await userSignIn(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function userSignIn() { + return new Promise(resolve => { + const body = {"activityId":"28acd0b5255d4aed866c60508ebf10f8","inviterId":"gCBrvPfINCZc+dotfvHPlA==","channel":"MiniProgram"}; + $.get(taskUrl('userSignIn', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + console.log(`今日签到成功`) + if (data.data) { + let { alreadySignDays, beanTotalNum, todayPrize, eachDayPrize } = data.data; + message += `【第${alreadySignDays}日签到】成功,获得${todayPrize.beanAmount}京豆 🐶\n`; + if (alreadySignDays === 7) alreadySignDays = 0; + message += `【明日签到】可获得${eachDayPrize[alreadySignDays].beanAmount}京豆 🐶\n`; + message += `【累计获得】${beanTotalNum}京豆 🐶\n`; + } + } else if (data.code === 81) { + console.log(`今日已签到`) + message += `【签到】失败,今日已签到`; + } else if (data.code === 82) { + console.log(`非校园用户无法签到`) + message += `【签到】失败,非校园用户无法签到`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=campus-mall&client=ds_m&fromType=wxapp×tamp=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://servicewechat.com/wxcb6c7f7be08467e3/104/page-frame.html", + "Cookie": cookie, + "User-Agent": 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.18(0x17001231) NetType/WIFI Language/zh_CN'//$.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_fruit.js b/jd_fruit.js index c42003b..b0f4eee 100644 --- a/jd_fruit.js +++ b/jd_fruit.js @@ -1,6 +1,6 @@ /* 东东水果:脚本更新地址 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_fruit.js -更新时间:2020-11-10 +更新时间:2020-11-30 东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -37,7 +37,7 @@ let message = '', subTitle = '', option = {}, isFruitFinished = false; const retainWater = 100;//保留水滴大于多少g,默认100g; let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 let jdFruitBeanCard = false;//农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水 -let randomCount = 20; +let randomCount = $.isNode() ? 20 : 5; const JD_API_HOST = 'https://api.m.jd.com/client.action'; const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`; !(async () => { @@ -335,15 +335,24 @@ async function doTenWaterAgain() { await myCardInfoForFarm(); const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes; console.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁': fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁': doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`) - if (totalEnergy >= 100 && $.myCardInfoRes.doubleCard > 0) { + if (totalEnergy >= 100 && doubleCard > 0) { //使用翻倍水滴卡 - for (let i = 0; i < new Array($.myCardInfoRes.doubleCard).fill('').length; i++) { + for (let i = 0; i < new Array(doubleCard).fill('').length; i++) { await userMyCardForFarm('doubleCard'); console.log(`使用翻倍水滴卡结果:${JSON.stringify($.userMyCardRes)}`); } await initForFarm(); totalEnergy = $.farmInfo.farmUserPro.totalEnergy; } + if (signCard > 0) { + //使用加签卡 + for (let i = 0; i < new Array(signCard).fill('').length; i++) { + await userMyCardForFarm('signCard'); + console.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`); + } + await initForFarm(); + totalEnergy = $.farmInfo.farmUserPro.totalEnergy; + } jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard; if ($.isNode() && process.env.FRUIT_BEAN_CARD) { jdFruitBeanCard = process.env.FRUIT_BEAN_CARD; @@ -362,17 +371,6 @@ async function doTenWaterAgain() { console.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`) } } - // if (Date.now() < new Date(activeEndTime).getTime()) { - // if (totalEnergy >= 100 && $.myCardInfoRes.beanCard > 0) { - // //使用水滴换豆卡 - // await userMyCardForFarm('beanCard'); - // console.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`); - // if ($.userMyCardRes.code === '0') { - // message += `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n`; - // } - // } - // return - // } // if (totalEnergy > 100 && $.myCardInfoRes.fastCard > 0) { // //使用快速浇水卡 // await userMyCardForFarm('fastCard'); @@ -766,9 +764,17 @@ async function clockInIn() { } // async function getAwardInviteFriend() { - await friendListInitForFarm(); - await receiveFriendInvite(); + await friendListInitForFarm();//查询好友列表 console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); + console.log(`开始删除${$.friendList.friends.length}个好友,可拿每天的邀请奖励`); + for (let friend of $.friendList.friends) { + console.log(`\n开始删除好友 [${friend.shareCode}]`); + const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`,"version":8,"channel":1 }); + if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { + console.log(`删除好友 [${friend.shareCode}] 成功\n`); + } + } + await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 if ($.friendList.inviteFriendCount > 0) { if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { console.log('开始领取邀请好友的奖励'); @@ -867,9 +873,9 @@ async function receiveFriendInvite() { await inviteFriend(code); console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`) if ($.inviteFriendRes.helpResult.code === '0') { - console.log(`您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) + console.log(`成功,您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) } else if ($.inviteFriendRes.helpResult.code === '17') { - console.log(`对方已是您的好友`) + console.log(`失败,对方已是您的好友`) } } // console.log(`开始接受6fbd26cc27ac44d6a7fed34092453f77的邀请\n`) @@ -1143,7 +1149,7 @@ async function initForFarm() { "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site", - "user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Content-Type": "application/x-www-form-urlencoded" } }; @@ -1216,7 +1222,7 @@ function timeFormat(time) { return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()); } function readShareCode() { - return new Promise(resolve => { + return new Promise(async resolve => { $.get({url: `http://api.turinglabs.net/api/v1/jd/farm/read/${randomCount}/`}, (err, resp, data) => { try { if (err) { @@ -1234,6 +1240,8 @@ function readShareCode() { resolve(data); } }) + await $.wait(10000); + resolve() }) } function shareCodesFormat() { @@ -1330,7 +1338,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -1398,7 +1406,7 @@ function taskUrl(function_id, body = {}) { url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&body=${escape(JSON.stringify(body))}`, headers: { Cookie: cookie, - UserAgent: `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1`, + UserAgent: $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), } } } diff --git a/jd_health.js b/jd_health.js new file mode 100644 index 0000000..bcfc2a2 --- /dev/null +++ b/jd_health.js @@ -0,0 +1,385 @@ +/* +健康抽奖机 ,活动于2020-12-31日结束 +活动地址:https://h5.m.jd.com/babelDiy/Zeus/3HBUP66Gnx92mRt2bXbT9VamYWSx/index.html +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#健康抽奖机 +10 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, tag=健康抽奖机, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 + +===============Surge================= +健康抽奖机 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js + +============小火箭========= +健康抽奖机 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, cronexpr="10 0 * * *", timeout=200, enable=true + */ +const $ = new Env('健康抽奖机'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +const inviteCodes = [`P04z54XCjVUnoaW5nJcXCCyoR8C6i9QR16e`, 'P04z54XCjVUnoaW5m9cZ2T6jChKkh8FWbFAplQ', `P04z54XCjVUnoaW5u2ak7ZCdan1Bdbpik_F9ud7lznm`, `P04z54XCjVUnoaW5m9cZ2ariXVJwFN5uKHNqnc`]; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await shareCodesFormat(); + await jdHealth() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdHealth() { + await helpFriends(); + await jdhealth_getTaskDetail(); + await doTask(); + await jdhealth_getTaskDetail(0); + if($.userInfo.scorePerLottery<=$.userInfo.userScore){ + console.log(`当前用户金币: ${$.userInfo.userScore},抽奖需要${$.userInfo.scorePerLottery},开始抽奖`) + message += `当前用户金币: ${$.userInfo.userScore},抽奖需要${$.userInfo.scorePerLottery},开始抽奖\n` + for(let i=0;i { + if (!jdNotify) { + $.msg($.name, '', `${message}`); + } else { + $.log(`京东账号${$.index}${$.nickName}\n${message}`); + } + if (new Date().getHours() === 23) { + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + const helpRes = await jdhealth_collectScore(code,6,null); + if (helpRes.code === 0 && helpRes.data.bizCode === -7) { + console.log(`助力机会已耗尽,跳出`); + break + } + } +} +async function doTask() { + for (let item of $.taskVos) { + if (item.taskType === 9||item.taskType === 26) { + //逛会场任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`) + for (let task of item.shoppingActivityVos) { + if (task.status === 1) { + await jdhealth_collectScore(task.taskToken,item.taskId,task.itemId,1); + await $.wait(15000) + await jdhealth_collectScore(task.taskToken,item.taskId,task.itemId,0); + } + } + } else if(item.status!==4){ + console.log(`${item.taskName}已做完`) + } + } + + if (item.taskType === 21) { + // 会员任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.brandMemberVos) { + if (task.status === 1) { + await jdhealth_collectScore(task.taskToken,item.taskId,task.itemId,1); + await jdhealth_collectScore(task.taskToken,item.taskId,task.itemId,0); + } + } + } else if(item.status!==4){ + console.log(`${item.taskName}已做完`) + } + } + } +} + +//领取做完任务的奖励 +function jdhealth_collectScore(taskToken, taskId, itemId, actionType=0) { + return new Promise(resolve => { + let body = { "appId":"1EFRTwg","taskToken":taskToken,"taskId":taskId,"itemId":itemId,"actionType":actionType } + $.post(taskPostUrl("harmony_collectScore", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.data.bizCode === 1){ + console.log(`任务领取成功`); + message += `任务领取成功\n` + } + else if (data.data.bizCode === 0) { + if(data.data.result.taskType===6){ + console.log(`助力好友:${data.data.result.itemId}成功!`) + message += `助力好友:${data.data.result.itemId}成功!\n` + }else { + console.log(`任务完成成功`); + message += `任务完成成功!\n` + } + + } else { + console.log(`${data.data.bizMsg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 抽奖 +function jdhealth_getLottery() { + return new Promise(resolve => { + let body = { "appId":"1EFRTwg"} + $.post(taskPostUrl("interact_template_getLotteryResult", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`抽奖成功,获得:${JSON.stringify(data.data.result.userAwardsCacheDto)}`); + message+= `抽奖成功,获得:${JSON.stringify(data.data.result.userAwardsCacheDto)}\n` + } else { + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function jdhealth_getTaskDetail(get=1) { + return new Promise(resolve => { + $.post(taskPostUrl("healthyDay_getHomeData", {"appId":"1EFRTwg","taskToken":""}, ), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + $.userInfo = data.data.result.userInfo; + if(get) + $.taskVos.map(item => { + if (item.taskType === 14) { + console.log(`\n您的${$.name}好友助力邀请码:${item.assistTaskDetailVo.taskToken}\n`) + message += `\n您的${$.name}好友助力邀请码:${item.assistTaskDetailVo.taskToken}\n` + } + }) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `http://api.turinglabs.net/api/v1/jd/jdhealth/read/${randomCount}/`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + // await $.wait(2000); + // resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = null //await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = [] //$.isNode() ? require('./jdSplitShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function taskPostUrl(function_id, body = {}, function_id2) { + let url = `${JD_API_HOST}`; + if (function_id2) { + url += `?functionId=${function_id2}`; + } + return { + url, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.1.0`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_jdfactory.js b/jd_jdfactory.js new file mode 100644 index 0000000..ba9d5c3 --- /dev/null +++ b/jd_jdfactory.js @@ -0,0 +1,739 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-12-06 18:19:21 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-12-06 22:58:02 + */ +/* +东东工厂,不是京喜工厂 +免费产生的电量(10秒1个电量,500个电量满,5000秒到上限不生产,算起来是84分钟达到上限) +故建议1小时运行一次 +开会员任务和去京东首页点击“数码电器任务目前未做 +不会每次运行脚本都投入电力 +只有当心仪的商品存在,并且收集起来的电量满足当前商品所需电力,才投入 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东工厂 +10 * * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js, tag=东东工厂, enabled=true + +================Loon============== +[Script] +cron "10 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js,tag=东东工厂 + +===============Surge================= +东东工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js + +============小火箭========= +东东工厂 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js, cronexpr="10 * * * *", timeout=200, enable=true + */ +const $ = new Env('东东工厂'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +let wantProduct = ``;//心仪商品名称 +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +const inviteCodes = [`P04z54XCjVWnYaS5u2ak7ZCdan1Bdd2GGiWvC6_uERj`, 'P04z54XCjVWnYaS5m9cZ2ariXVJwHf0bgkG7Uo']; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await shareCodesFormat(); + await jdFactory() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdFactory() { + await jdfactory_getHomeData(); + await helpFriends(); + // $.newUser !==1 && $.haveProduct === 2,老用户但未选购商品 + // $.newUser === 1新用户 + if ($.newUser === 1) return + await jdfactory_collectElectricity();//收集产生的电量 + await jdfactory_getTaskDetail(); + await doTask(); + await algorithm();//投入电力逻辑 + await showMsg(); +} +function showMsg() { + return new Promise(resolve => { + if (!jdNotify) { + $.msg($.name, '', `${message}`); + } else { + $.log(`京东账号${$.index}${$.nickName}\n${message}`); + } + if (new Date().getHours() === 23) { + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} +async function algorithm() { + // 当心仪的商品存在,并且收集起来的电量满足当前商品所需,就投入 + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getHomeData'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.haveProduct = data.data.result.haveProduct; + $.userName = data.data.result.userName; + $.newUser = data.data.result.newUser; + wantProduct = $.isNode() ? (process.env.FACTORAY_WANTPRODUCT_NAME ? process.env.FACTORAY_WANTPRODUCT_NAME : wantProduct) : ($.getdata('FACTORAY_WANTPRODUCT_NAME') ? $.getdata('FACTORAY_WANTPRODUCT_NAME') : wantProduct); + if (data.data.result.factoryInfo) { + let { totalScore, useScore, produceScore, remainScore, couponCount, name } = data.data.result.factoryInfo + console.log(`\n已选商品:${name}`); + console.log(`当前已投入电量/所需电量:${useScore}/${totalScore}`); + console.log(`已选商品剩余量:${couponCount}`); + console.log(`当前总电量:${remainScore * 1 + useScore * 1}`); + console.log(`当前完成度:${((remainScore * 1 + useScore * 1)/(totalScore * 1)).toFixed(2) * 100}%\n`); + message += `京东账号${$.index} ${$.nickName}\n`; + message += `已选商品:${name}\n`; + message += `当前已投入电量/所需电量:${useScore}/${totalScore}\n`; + message += `已选商品剩余量:${couponCount}\n`; + message += `当前总电量:${remainScore * 1 + useScore * 1}\n`; + message += `当前完成度:${((remainScore * 1 + useScore * 1)/(totalScore * 1)).toFixed(2) * 100}%\n`; + if (wantProduct) { + console.log(`BoxJs或环境变量提供的心仪商品:${wantProduct}\n`); + await jdfactory_getProductList(true); + let wantProductSkuId = ''; + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > - 1) { + totalScore = item['fullScore'] * 1; + couponCount = item.couponCount; + name = item.name; + } + if (item.name.indexOf(wantProduct) > - 1 && item.couponCount > 0) { + wantProductSkuId = item.skuId; + } + } + // console.log(`\n您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${remainScore * 1 + useScore * 1}\n`); + if (wantProductSkuId && ((remainScore * 1 + useScore * 1) >= (totalScore * 1 + 100000))) { + console.log(`\n提供的心仪商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【满足】兑换此商品所需总电量:${totalScore + 100000}`); + console.log(`请去活动页面更换成心仪商品并手动投入电量兑换\n`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面\n更换成心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请去活动页面更换成心仪商品并手动投入电量兑换`); + } else { + console.log(`您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${remainScore * 1 + useScore * 1}\n不满足兑换心仪商品的条件\n`) + } + } else { + console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称,否则满足条件后会为您兑换当前所选商品:${name}\n`); + if (((remainScore * 1 + useScore * 1) >= totalScore * 1 + 100000) && (couponCount * 1 > 0)) { + console.log(`\n所选商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【满足】兑换此商品所需总电量:${totalScore}`); + console.log(`BoxJs或环境变量暂未提供心仪商品,下面为您目前选的${name} 发送提示通知\n`); + // await jdfactory_addEnergy(); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您所选商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面查看`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n所选商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请速去活动页面查看`); + } else { + console.log(`\n所选商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【不满足】兑换此商品所需总电量:${totalScore}`) + console.log(`故不一次性投入电力,一直放到蓄电池累计\n`); + } + } + } else { + console.log(`\n此账号${$.index}${$.nickName}暂未选择商品\n`); + message += `已选商品:暂无\n`; + message += `心仪商品:${wantProduct ? wantProduct : '暂无'}\n`; + if (wantProduct) { + console.log(`BoxJs或环境变量提供的心仪商品:${wantProduct}\n`); + await jdfactory_getProductList(true); + let wantProductSkuId = '', name, totalScore, couponCount, remainScore; + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > - 1) { + totalScore = item['fullScore'] * 1; + couponCount = item.couponCount; + name = item.name; + } + if (item.name.indexOf(wantProduct) > - 1 && item.couponCount > 0) { + wantProductSkuId = item.skuId; + } + } + if (totalScore) { + // 库存存在您设置的心仪商品 + message += `心仪商品数量:${couponCount}\n`; + message += `心仪商品所需电量:${totalScore}\n`; + message += `您当前总电量:${$.batteryValue * 1}\n`; + if (wantProductSkuId && (($.batteryValue * 1) >= (totalScore))) { + console.log(`\n提供的心仪商品${name}目前数量:${couponCount},且当前总电量为:${$.batteryValue * 1},【满足】兑换此商品所需总电量:${totalScore}`); + console.log(`请去活动页面选择心仪商品并手动投入电量兑换\n`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${$.batteryValue * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${$.batteryValue * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请去活动页面选择此心仪商品并手动投入电量兑换`); + } else { + console.log(`您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${$.batteryValue * 1}\n不满足兑换心仪商品的条件\n`) + } + } else { + message += `目前库存:暂无您设置的心仪商品\n`; + } + } else { + console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称\n`); + await jdfactory_getProductList(true); + message += `当前剩余最多商品:${$.canMakeList[0].name}\n`; + message += `兑换所需电量:${$.canMakeList[0].fullScore}\n`; + message += `您当前总电量:${$.batteryValue * 1}\n`; + if ($.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0].fullScore) { + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n${message}【满足】兑换${$.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`); + } else { + console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0].name}所需的 ${$.canMakeList[0].fullScore}电量\n`) + } + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + const helpRes = await jdfactory_collectScore(code); + if (helpRes.code === 0 && helpRes.data.bizCode === -7) { + console.log(`助力机会已耗尽,跳出`); + break + } + } +} +async function doTask() { + for (let item of $.taskVos) { + if (item.taskType === 1) { + //关注店铺任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.followShopVo) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 2) { + //看看商品任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.productInfoVos) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 3) { + //逛会场任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.shoppingActivityVos) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 10) { + if (item.status === 1) { + if (item.threeMealInfoVos[0].status === 1) { + //可以做此任务 + console.log(`准备做此任务:${item.taskName}`); + await jdfactory_collectScore(item.threeMealInfoVos[0].taskToken); + } else if (item.threeMealInfoVos[0].status === 0) { + console.log(`${item.taskName} 任务已错过时间`) + } + } else if (item.status === 2){ + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 21) { + //开通会员任务 + if (item.status === 1) { + console.log(`此任务:${item.taskName},跳过`); + // for (let task of item.brandMemberVos) { + // if (task.status === 1) { + // await jdfactory_collectScore(task.taskToken); + // } + // } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 13) { + //每日打卡 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 14) { + //好友助力 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + // await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 23) { + //从数码电器首页进入 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + await queryVkComponent(); + await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + } +} + +//领取做完任务的奖励 +function jdfactory_collectScore(taskToken) { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_collectScore", { taskToken }, "jdfactory_collectScore"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + console.log(`领取做完任务的奖励:${JSON.stringify(data.data.result)}`); + } else { + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//给商品投入电量 +function jdfactory_addEnergy() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_addEnergy"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`给商品投入电量:${JSON.stringify(data.data.result)}`) + // $.taskConfigVos = data.data.result.taskConfigVos; + // $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//收集电量 +function jdfactory_collectElectricity() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_collectElectricity"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`成功收集${data.data.result.electricityValue}电量,当前蓄电池总电量:${data.data.result.batteryValue}\n`); + $.batteryValue = data.data.result.batteryValue; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//获取任务列表 +function jdfactory_getTaskDetail() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_getTaskDetail", {}, "jdfactory_getTaskDetail"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + $.taskVos.map(item => { + if (item.taskType === 14) { + console.log(`\n您的${$.name}好友助力邀请码:${item.assistTaskDetailVo.taskToken}\n`) + } + }) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//选择一件商品,只能在 $.newUser !== 1 && $.haveProduct === 2 并且 sellOut === 0的时候可用 +function jdfactory_makeProduct(skuId) { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_makeProduct', { skuId }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`选购商品成功:${JSON.stringify(data)}`); + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function queryVkComponent() { + return new Promise(resolve => { + const options = { + "url": `https://api.m.jd.com/client.action?functionId=queryVkComponent`, + "body": `adid=0E38E9F1-4B4C-40A4-A479-DD15E58A5623&area=19_1601_50258_51885&body={"componentId":"4f953e59a3af4b63b4d7c24f172db3c3","taskParam":"{\\"actId\\":\\"8tHNdJLcqwqhkLNA8hqwNRaNu5f\\"}","cpUid":"8tHNdJLcqwqhkLNA8hqwNRaNu5f","taskSDKVersion":"1.0.3","businessId":"babel"}&build=167436&client=apple&clientVersion=9.2.5&d_brand=apple&d_model=iPhone11,8&eid=eidIf12a8121eas2urxgGc+zS5+UYGu1Nbed7bq8YY+gPd0Q0t+iviZdQsxnK/HTA7AxZzZBrtu1ulwEviYSV3QUuw2XHHC+PFHdNYx1A/3Zt8xYR+d3&isBackground=N&joycious=228&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=88732f840b77821b345bf07fd71f609e6ff12f43&osVersion=14.2&partner=TF&rfs=0000&scope=11&screen=828*1792&sign=792d92f78cc893f43c32a4f0b2203a41&st=1606533009673&sv=122&uts=0f31TVRjBSsqndu4/jgUPz6uymy50MQJFKw5SxNDrZGH4Sllq/CDN8uyMr2EAv+1xp60Q9gVAW42IfViu/SFHwjfGAvRI6iMot04FU965+8UfAPZTG6MDwxmIWN7YaTL1ACcfUTG3gtkru+D4w9yowDUIzSuB+u+eoLwM7uynPMJMmGspVGyFIgDXC/tmNibL2k6wYgS249Pa2w5xFnYHQ==&uuid=hjudwgohxzVu96krv/T6Hg==&wifiBssid=1b5809fb84adffec2a397007cc235c03`, + "headers": { + "Cookie": cookie, + "Accept": `*/*`, + "Connection": `keep-alive`, + "Content-Type": `application/x-www-form-urlencoded`, + "Accept-Encoding": `gzip, deflate, br`, + "Host": `api.m.jd.com`, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + "Accept-Language": `zh-Hans-CN;q=1, en-CN;q=0.9`, + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log('queryVkComponent', data) + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询当前商品列表 +function jdfactory_getProductList(flag = false) { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getProductList'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.canMakeList = data.data.result.canMakeList;//当前可选商品列表 sellOut:1为已抢光,0为目前可选择 + $.canMakeList.sort(sortCouponCount); + console.log(`商品名称 可选状态 剩余量`) + for (let item of $.canMakeList) { + console.log(`${item.name.slice(-4)} ${item.sellOut === 1 ? '已抢光':'可 选'} ${item.couponCount}`); + } + if (!flag) { + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > -1 && item.couponCount > 0 && item.sellOut === 0) { + await jdfactory_makeProduct(item.skuId); + break + } + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function sortCouponCount(a, b) { + return b['couponCount'] - a['couponCount'] +} +function jdfactory_getHomeData() { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getHomeData'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + // console.log(data); + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.haveProduct = data.data.result.haveProduct; + $.userName = data.data.result.userName; + $.newUser = data.data.result.newUser; + if (data.data.result.factoryInfo) { + $.totalScore = data.data.result.factoryInfo.totalScore;//选中的商品,一共需要的电量 + $.userScore = data.data.result.factoryInfo.userScore;//已使用电量 + $.produceScore = data.data.result.factoryInfo.produceScore;//此商品已投入电量 + $.remainScore = data.data.result.factoryInfo.remainScore;//当前蓄电池电量 + $.couponCount = data.data.result.factoryInfo.couponCount;//已选中商品当前剩余量 + $.hasProduceName = data.data.result.factoryInfo.name;//已选中商品当前剩余量 + } + if ($.newUser === 1) { + //新用户 + console.log(`此京东账号${$.index}${$.nickName}为新用户暂未开启${$.name}活动\n现在为您从库存里面现有数量中选择一商品`); + if ($.haveProduct === 2) { + await jdfactory_getProductList();//选购商品 + } + // $.msg($.name, '暂未开启活动', `京东账号${$.index}${$.nickName}暂未开启${$.name}活动\n请去京东APP->搜索'玩一玩'->东东工厂->开启\n或点击弹窗即可到达${$.name}活动`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + } + if ($.newUser !== 1 && $.haveProduct === 2) { + console.log(`此京东账号${$.index}${$.nickName}暂未选购商品\n现在也能为您做任务和收集免费电力`); + // $.msg($.name, '暂未选购商品', `京东账号${$.index}${$.nickName}暂未选购商品\n请去京东APP->搜索'玩一玩'->东东工厂->选购一件商品\n或点击弹窗即可到达${$.name}活动`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + // await jdfactory_getProductList();//选购商品 + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `http://api.turinglabs.net/api/v1/jd/ddfactory/read/${randomCount}/`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = $.isNode() ? require('./jdFactoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +function taskPostUrl(function_id, body = {}, function_id2) { + let url = `${JD_API_HOST}`; + if (function_id2) { + url += `?functionId=${function_id2}`; + } + return { + url, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.1.0`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_joy.js b/jd_joy.js index 163025e..ec392ea 100644 --- a/jd_joy.js +++ b/jd_joy.js @@ -2,7 +2,7 @@ jd宠汪汪 搬的https://github.com/uniqueque/QuantumultX/blob/4c1572d93d4d4f883f483f907120a75d925a693e/Script/jd_joy.js 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js IOS用户支持京东双账号,NodeJs用户支持N个京东账号 -更新时间:2020-11-03 +更新时间:2020-12-06 建议先凌晨0点运行jd_joy.js脚本获取狗粮后,再运行此脚本(jd_joy_steal.js)可偷好友积分,6点运行可偷好友狗粮 feedCount:自定义 每次喂养数量; 等级只和喂养次数有关,与数量无关 推荐每次投喂10个,积累狗粮,然后去聚宝盆赌每小时的幸运奖,据观察,投入3000-6000中奖概率大,超过7000基本上注定亏本,即使是第一名 @@ -37,6 +37,7 @@ if ($.isNode()) { } let message = '', subTitle = ''; let FEED_NUM = ($.getdata('joyFeedCount') * 1) || 10; //每次喂养数量 [10,20,40,80] +let teamLevel = 2;//参加多少人的赛跑比赛,默认是双人赛跑,可选2,10,50。其他不可选,其中2代表参加双人PK赛,10代表参加10人突围赛,50代表参加50人挑战赛 //是否参加宠汪汪双人赛跑(据目前观察,参加双人赛跑不消耗狗粮,如需参加其他多人赛跑,请关闭) // 默认 'true' 参加双人赛跑,如需关闭 ,请改成 'false'; let joyRunFlag = true; @@ -133,15 +134,16 @@ async function joinTwoPeopleRun() { console.log(`\n===========以下是双人赛跑信息========\n`) await getPetRace(); if ($.petRaceResult) { + teamLevel = $.isNode() ? (process.env.JOY_TEAM_LEVEL ? process.env.JOY_TEAM_LEVEL : teamLevel) : ($.getdata('JOY_TEAM_LEVEL') ? $.getdata('JOY_TEAM_LEVEL') : teamLevel); let petRaceResult = $.petRaceResult.data.petRaceResult; let raceUsers = $.petRaceResult.data.raceUsers; console.log(`赛跑状态:${petRaceResult}\n`); if (petRaceResult === 'not_participate') { - console.log('暂未参赛,现在为您参加双人赛跑'); - await runMatch(2); + console.log(`暂未参赛,现在为您参加${teamLevel}人赛跑`); + await runMatch(teamLevel * 1); if ($.runMatchResult.success) { - console.log(`双人赛跑参加成功\n`); - message += `双人赛跑:成功参加\n`; + console.log(`${teamLevel}人赛跑参加成功\n`); + message += `${teamLevel}人赛跑:成功参加\n`; await getPetRace(); petRaceResult = $.petRaceResult.data.petRaceResult; raceUsers = $.petRaceResult.data.raceUsers; @@ -157,10 +159,16 @@ async function joinTwoPeopleRun() { } if (petRaceResult === 'unreceive') { console.log('今日参赛的比赛已经结束,现在领取奖励'); + await getWinCoin(); + let winCoin = 0; + if ($.getWinCoinRes && $.getWinCoinRes.success) { + winCoin = $.getWinCoinRes.data.winCoin; + } await receiveJoyRunAward(); console.log(`领取赛跑奖励结果:${JSON.stringify($.receiveJoyRunAwardRes)}`) if ($.receiveJoyRunAwardRes.success) { - $.msg($.name, '双人赛跑取得获胜', `【京东账号${$.index}】${$.nickName}\n太棒了,恭喜您获得300积分奖励`) + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n太棒了,${teamLevel}人赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`); + if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index}${$.nickName}\n${teamLevel}人赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`) } } if (petRaceResult === 'participate') { @@ -604,6 +612,7 @@ function getPetRace() { } //参加赛跑API function runMatch(teamLevel, timeout = 5000) { + if (teamLevel === 10 || teamLevel === 50) timeout = 60000; console.log(`正在参赛中,请稍等${timeout / 1000}秒,以防多个账号匹配到统一赛场\n`) return new Promise(async resolve => { await $.wait(timeout); @@ -650,6 +659,29 @@ function getBackupInfo() { }) }) } +//查询赛跑获得多少积分 +function getWinCoin() { + return new Promise(resolve => { + const url = `${weAppUrl}/combat/detail/v2?help=false&reqSource=weapp`; + $.get(taskUrl(url, 'draw.jdfcloud.com', `weapp`), (err, resp, data) => { + try { + if (err) { + console.log('\n京东宠汪汪: API查询请求失败 ‼️‼️') + } else { + // console.log('查询应援团信息API',(data)) + // $.appGetPetTaskConfigRes = JSON.parse(data); + if (data) { + $.getWinCoinRes = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} //领取赛跑奖励API function receiveJoyRunAward() { return new Promise(resolve => { @@ -693,7 +725,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -731,7 +763,7 @@ function taskUrl(url, Host, reqSource) { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } @@ -743,7 +775,7 @@ function taskPostUrl(url, body, reqSource, Host, ContentType) { body: body, headers: { 'Cookie': cookie, - 'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1`, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'reqSource': reqSource, 'Content-Type': ContentType, 'Host': Host, diff --git a/jd_joy_feedPets.js b/jd_joy_feedPets.js index 77ce1bc..1e497cb 100644 --- a/jd_joy_feedPets.js +++ b/jd_joy_feedPets.js @@ -104,7 +104,7 @@ function feedPets(feedNum) { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } @@ -162,7 +162,7 @@ function ThreeMeals() { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } @@ -207,7 +207,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_joy_help.js b/jd_joy_help.js index b46c542..3641d89 100644 --- a/jd_joy_help.js +++ b/jd_joy_help.js @@ -15,15 +15,15 @@ hostname = draw.jdfcloud.com ======================Surge===================== [Script] -宠汪汪强制为别人助力= type=http-request,pattern= ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/helpFriend\?friendPin,requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js +宠汪汪强制为别人助力= type=http-request,pattern= ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin,requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js ===================圈x===================== [rewrite_local] -^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/helpFriend\?friendPin url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js +^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js =====================LOON===================== [Script] -http-request ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js, requires-body=true, timeout=10, tag=宠汪汪强制为别人助力 +http-request ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/enterRoom\/h5\?reqSource=weapp&invitePin=.*+(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js, requires-body=true, timeout=10, tag=宠汪汪强制为别人助力 你也可从下面链接拿好友的friendPin(复制链接到有京东ck的浏览器打开即可) @@ -31,7 +31,7 @@ http-request ^https:\/\/draw\.jdfcloud\.com\/mirror\/\/pet\/enterRoom\/h5\?reqSo https://jdjoy.jd.com/pet/getFriends?itemsPerPage=20¤tPage=1 **/ let url = $request.url -const friendsArr = ["yhr_19820404", "13008094886_p", "13966269193_p", "jd_4e4d9825e5fb1", "jd_5ff306cf94512", "ququkoko", "jd_59a9823f35496", "529577509-275616", "18923155789_p", "jd_455da88071d1e", "dreamscometrue5120", "蒋周南19620607", "jd_620ceca400151", "杉雨2011", "MARYMY88", "13682627696_p", "jd_6777ee65f9fcc", "夏海东12315", "jd_437b4f3fa5d83", "zyjyc9998", "meoygua", "MLHK7288", "jd_42d9ce3001acd", "jd_57650a30ef6eb", "jd_44ca1016e0f96", "jd_74332d1d62a97", "jd_7dbe4f8a40a7d", "jd_4fa238e4e3039", "elbereth1122", "jd_4d9be23908e41", "jd_51f0d43d78900", "13588108107_p", "123by456", "09niuniuma", "143798682-947527", "jd_560c6f30e6951", "jd_54ddb8af5374a", "夏革平", "247466310", "wang2011", "chensue", "1362245003-624122", "wdGefYCBlyOuvz", "jd_412f7eb363cd8", "18311575050_p", "1307976-34738981", "wdgOGLtOJjjbnp", "klhzdx", "jd_5fdcdcb183d7d", "jd_5862fd8834680", "jd_6cd93e613b0e5", "jd_51a64a9da6b94", "302990512-553401", "jd_4078f69a72873", "jd_ewYCRdmukzQH", "13348822441_p", "hlcx86021", "390823571-784974", "jd_79af2bc7a56a3", "15053231812_p", "jd_6f53253d117c5", "jd_5bf29dffa62ea", "jd_47a1c4ad02103", "刘凤苓", "145391572-102667", "yanglan0409", "jd_4b8a70f3b06c3", "弑神X", "jd_59d962a076126", "sjw3000", "jd_4d4def8b59787", "L1518235423", "jd_579b891fbea9b", "frank818", "hellohuhua", "jd_4cf1918577871", "jd_akYbyiXqrIDC", "李纪红", "jd_54a4260ca986c", "jd_4cba35cfa8220", "13654075776_p", "13916051043", "jd_6f9b9a6769afb", "iamkgbfox", "jd_5fbda9be54d5b", "jd_76763ba485c5e", "jd_45a6b5953b15b", "jd_485c757b79422", "xiaojingang_0", "lanye1545", "chenzhiyun2002", "lmpbjs1988", "jd_SmPxpudoGYOb", "jwl19690905", "荷舞弄清影88", "jd_750d6a9734717", "jd_64e37854e713f", "jd_573c9832d8989", "wdkplHVQlgowTW", "wwk232323", "jd_6bfe51f915c90", "我手机号码", "13681610268_p", "ss836580793", "15868005933_p", "zooooo58", "陌上花开花又落", "jd_701f52f8badbb", "jd_462f9229c20e4", "jd_42193689987a0", "jd_7dc5829121bcc", "13656692651_phz", "jd_47f49f22f1dc3", "handechun959", "13775208986_p", "guoyizhang", "jd_677dd20bf2749", "被折叠的记忆33", "jd_FfAnqFVEoBul", "jd_4e59841cae4f9", "jd_5279d593e7803", "思绪随风2011", "jd_62e335d785872", "suyugen", "jd_4e68b48d16f7b", "jd_56b7a4e092e85", "cocoty", "jd_7b6d6e7dc98f1", "jd_63423cd594e8b", "greatyunyun", "4349小丢丢", "18027486801_p", "15207695569_p", "llbai11", "wdNRUvbJItetlvB", "jd_54154982c707f", "85192cool", "jd_60d497271825b", "greatyunyun9320", "ky252571504", "jd_74e60dbcae365", "wdiicnSbYSHWwE", "jd_529a0a309d418", "jd_7be92b11b7e8f", "13486659225_p", "jd_iFnquhpWWAzO", "jd_6e348ece13e20", "jd_6f5b49bb757cb", "znz传奇", "418001066_m", "jd_67ded5748c3ab", "361372-27819972", "jd_5fafb631c98af", "jd_76dd04e844d63", "小鹿Jenny", "00数字方程式", "jd_77a82b603c6c3", "勇敢的小泪", "jd_4481f68984466", "jd_758f5224ee957", "mwb1992062_m", "15975229552_p", "zdj8341", "pet_virtual_friend_胡皋三", "pet_virtual_friend_绿茶sama", "pet_virtual_friend_Ainio", "jd_4915949b7bfa1", "jd_7ca74ed9224ef", "jd_42764f5ea2341", "5317123-63418293", "jd_40a2d9485cbdb", "qazmcl1230", "jd_7ced325aba4fd", "jd_402fe7425fcaf", "95581245-627991", "luffy-314_m", "jd_BCXgLlmxHdiS", "jd_610b3d00928e5", "你要醒来", "338379384-148135", "pet_virtual_friend_乔治桑", "jd_54130a3e282ea", "jd_6169b3411ed5b", "jd_428d930ca56a5", "qq6924309", "pet_virtual_friend_路遇狗与少年", "jd_712bd3bfd55d6", "jd_4e97fe5ca4003", "tommy_he1", "13981372001_p", "129867657-673064", "jd_525d6e7a57e7c", "wdZuirGekSHKmF", "jd_75e1da74980ab", "jd_RVMXldNSQNOP", "jd_5f94da0265e0d", "jd_67ab629be7e61", "13887490621_p", "jd_4e0d529ba3c35", "jd_493918e314b50", "jd_71a220104187a", "jd_vVhhkdUpTkJQ", "gary388jingdong", "wdjQkAbFobMTyo", "cloud_kim", "jd_558ed75f52d39", "15555448319_p", "wdhxZuEvXhhvCf", "jd_72b940be8c0f4", "congcong炒葱葱", "jd_7eb0de64eb25a", "13209558123_p", "jd_53bf7cb6fb8e6", "jd_4fe620f72fa7c", "夏雨的爱情", "jd_47ba82eb392a5", "jd_LXnFHXoJwXkW", "62160785-578856", "醒醒该睡了", "jd_LOEWgvNwQIWD", "xiiirww", "pet_virtual_friend_特兰克斯", "pet_virtual_friend_Talon", "jd_4f7cd5b108733", "jd_NgNWXMVkJIvk", "jadonglin", "玩家卫弈", "liangxuejingdong", "jd_627171efb7c0a", "jd_53bc7a14f64d6", "15809290902_p", "jd_65a2ab73d9aa5", "jd_6edb943cacbfb", "jd_7f7eabc5caf7d", "jd_725e17effb6a9", "蔡辉煌", "voxb", "gdxx_hhw_m", "jd_78f0d6524a1dc", "jd_sDtnONLeHwfG", "xyyshy1983", "yinlang46", "ypqian", "15817094457_p", "fdxwb", "wuyaoxin2012", "明子溪", "henry1927_m", "chamy99", "jd_461e384274c34", "248358330-645106", "jd_4fd63de4a6033", "蜜糖向日葵", "wonghe", "36453197-121619", "琳琅满目cbb", "jd_5b7cc9e532426", "134795344-89911673", "15211488203_p", "jd_6f1f0722f8365", "jd_JmGCpqgpCtqG", "墨明棋妙陈", "pet_virtual_friend_1314爱澳", "1209815-33190621", "zhouhuayh", "jd_6d3cbb8b0751a", "jd_6e00e826f939b", "jd_704a2e5e28a66", "mztvip", "davidharry", "sara35424", "sun5025", "jd_62ce2385bb364", "352834026-406289", "pet_virtual_friend_丁座的真爱粉", "jd_582eecf8d27a9", "jd_49acdb02e8514", "13976911784_p", "jd_uGzohbhFpRuz", "wzywolfgang", "yjbonny", "沧海不轮回", "649297742_327799447", "倚兰椒", "琳琳8796", "snzh2013", "jd_73751adc04afd", "wdNnlMzPGJJKgqI", "yygt1158", "jd_53df36eb204a0", "花开花花落", "jd_611e082213c89", "jd_71e77d9235cf5", "jd_596fd9fea411f", "jd_7277d200aa1ac", "15230573701_p", "zb19881021", "692620136落", "168876810-159969", "zhushidan100", "上自习的猪", "15602231009_p", "jd_5213fd3fd5e09", "jd_6711f97ee4dfe", "44787591-640051", "MisterGlasses", "jd_7b22bbfe1e7e5", "138555963-81748582", "jd_QEVVkkDTQAlJ", "4932713-24535180", "jd_6dce98c07a644", "jd_DUtPtiiDamDr", "wangyneu", "wBm1TsDy3p_m", "jd_6acd3a6cc79cc","jd_444f5c020f31c","jd_71caf6b3ec4cb"] +const friendsArr = ["yhr_19820404", "13008094886_p", "13966269193_p", "jd_4e4d9825e5fb1", "jd_5ff306cf94512", "ququkoko", "jd_59a9823f35496", "529577509-275616", "18923155789_p", "jd_455da88071d1e", "dreamscometrue5120", "蒋周南19620607", "jd_620ceca400151", "杉雨2011", "MARYMY88", "13682627696_p", "jd_6777ee65f9fcc", "夏海东12315", "jd_437b4f3fa5d83", "zyjyc9998", "meoygua", "MLHK7288", "jd_42d9ce3001acd", "jd_57650a30ef6eb", "jd_44ca1016e0f96", "jd_74332d1d62a97", "jd_7dbe4f8a40a7d", "jd_4fa238e4e3039", "elbereth1122", "jd_4d9be23908e41", "jd_51f0d43d78900", "13588108107_p", "123by456", "09niuniuma", "143798682-947527", "jd_560c6f30e6951", "jd_54ddb8af5374a", "夏革平", "247466310", "wang2011", "chensue", "1362245003-624122", "wdGefYCBlyOuvz", "jd_412f7eb363cd8", "18311575050_p", "1307976-34738981", "wdgOGLtOJjjbnp", "klhzdx", "jd_5fdcdcb183d7d", "jd_5862fd8834680", "jd_6cd93e613b0e5", "jd_51a64a9da6b94", "302990512-553401", "jd_4078f69a72873", "jd_ewYCRdmukzQH", "13348822441_p", "hlcx86021", "390823571-784974", "jd_79af2bc7a56a3", "15053231812_p", "jd_6f53253d117c5", "jd_5bf29dffa62ea", "jd_47a1c4ad02103", "刘凤苓", "145391572-102667", "yanglan0409", "jd_4b8a70f3b06c3", "弑神X", "jd_59d962a076126", "sjw3000", "jd_4d4def8b59787", "L1518235423", "jd_579b891fbea9b", "frank818", "hellohuhua", "jd_4cf1918577871", "jd_akYbyiXqrIDC", "李纪红", "jd_54a4260ca986c", "jd_4cba35cfa8220", "13654075776_p", "13916051043", "jd_6f9b9a6769afb", "iamkgbfox", "jd_5fbda9be54d5b", "jd_76763ba485c5e", "jd_45a6b5953b15b", "jd_485c757b79422", "xiaojingang_0", "lanye1545", "chenzhiyun2002", "lmpbjs1988", "jd_SmPxpudoGYOb", "jwl19690905", "荷舞弄清影88", "jd_750d6a9734717", "jd_64e37854e713f", "jd_573c9832d8989", "wdkplHVQlgowTW", "wwk232323", "jd_6bfe51f915c90", "我手机号码", "13681610268_p", "ss836580793", "15868005933_p", "zooooo58", "陌上花开花又落", "jd_701f52f8badbb", "jd_462f9229c20e4", "jd_42193689987a0", "jd_7dc5829121bcc", "13656692651_phz", "jd_47f49f22f1dc3", "handechun959", "13775208986_p", "guoyizhang", "jd_677dd20bf2749", "被折叠的记忆33", "jd_FfAnqFVEoBul", "jd_4e59841cae4f9", "jd_5279d593e7803", "思绪随风2011", "jd_62e335d785872", "suyugen", "jd_4e68b48d16f7b", "jd_56b7a4e092e85", "cocoty", "jd_7b6d6e7dc98f1", "jd_63423cd594e8b", "greatyunyun", "4349小丢丢", "18027486801_p", "15207695569_p", "llbai11", "wdNRUvbJItetlvB", "jd_54154982c707f", "85192cool", "jd_60d497271825b", "greatyunyun9320", "ky252571504", "jd_74e60dbcae365", "wdiicnSbYSHWwE", "jd_529a0a309d418", "jd_7be92b11b7e8f", "13486659225_p", "jd_iFnquhpWWAzO", "jd_6e348ece13e20", "jd_6f5b49bb757cb", "znz传奇", "418001066_m", "jd_67ded5748c3ab", "361372-27819972", "jd_5fafb631c98af", "jd_76dd04e844d63", "小鹿Jenny", "00数字方程式", "jd_77a82b603c6c3", "勇敢的小泪", "jd_4481f68984466", "jd_758f5224ee957", "mwb1992062_m", "15975229552_p", "zdj8341", "pet_virtual_friend_胡皋三", "pet_virtual_friend_绿茶sama", "pet_virtual_friend_Ainio", "jd_4915949b7bfa1", "jd_7ca74ed9224ef", "jd_42764f5ea2341", "5317123-63418293", "jd_40a2d9485cbdb", "qazmcl1230", "jd_7ced325aba4fd", "jd_402fe7425fcaf", "95581245-627991", "luffy-314_m", "jd_BCXgLlmxHdiS", "jd_610b3d00928e5", "你要醒来", "338379384-148135", "pet_virtual_friend_乔治桑", "jd_54130a3e282ea", "jd_6169b3411ed5b", "jd_428d930ca56a5", "qq6924309", "pet_virtual_friend_路遇狗与少年", "jd_712bd3bfd55d6", "jd_4e97fe5ca4003", "tommy_he1", "13981372001_p", "129867657-673064", "jd_525d6e7a57e7c", "wdZuirGekSHKmF", "jd_75e1da74980ab", "jd_RVMXldNSQNOP", "jd_5f94da0265e0d", "jd_67ab629be7e61", "13887490621_p", "jd_4e0d529ba3c35", "jd_493918e314b50", "jd_71a220104187a", "jd_vVhhkdUpTkJQ", "gary388jingdong", "wdjQkAbFobMTyo", "cloud_kim", "jd_558ed75f52d39", "15555448319_p", "wdhxZuEvXhhvCf", "jd_72b940be8c0f4", "congcong炒葱葱", "jd_7eb0de64eb25a", "13209558123_p", "jd_53bf7cb6fb8e6", "jd_4fe620f72fa7c", "夏雨的爱情", "jd_47ba82eb392a5", "jd_LXnFHXoJwXkW", "62160785-578856", "醒醒该睡了", "jd_LOEWgvNwQIWD", "xiiirww", "pet_virtual_friend_特兰克斯", "pet_virtual_friend_Talon", "jd_4f7cd5b108733", "jd_NgNWXMVkJIvk", "jadonglin", "玩家卫弈", "liangxuejingdong", "jd_627171efb7c0a", "jd_53bc7a14f64d6", "15809290902_p", "jd_65a2ab73d9aa5", "jd_6edb943cacbfb", "jd_7f7eabc5caf7d", "jd_725e17effb6a9", "蔡辉煌", "voxb", "gdxx_hhw_m", "jd_78f0d6524a1dc", "jd_sDtnONLeHwfG", "xyyshy1983", "yinlang46", "ypqian", "15817094457_p", "fdxwb", "wuyaoxin2012", "明子溪", "henry1927_m", "chamy99", "jd_461e384274c34", "248358330-645106", "jd_4fd63de4a6033", "蜜糖向日葵", "wonghe", "36453197-121619", "琳琅满目cbb", "jd_5b7cc9e532426", "134795344-89911673", "15211488203_p", "jd_6f1f0722f8365", "jd_JmGCpqgpCtqG", "墨明棋妙陈", "pet_virtual_friend_1314爱澳", "1209815-33190621", "zhouhuayh", "jd_6d3cbb8b0751a", "jd_6e00e826f939b", "jd_704a2e5e28a66", "mztvip", "davidharry", "sara35424", "sun5025", "jd_62ce2385bb364", "352834026-406289", "pet_virtual_friend_丁座的真爱粉", "jd_582eecf8d27a9", "jd_49acdb02e8514", "13976911784_p", "jd_uGzohbhFpRuz", "wzywolfgang", "yjbonny", "沧海不轮回", "649297742_327799447", "倚兰椒", "琳琳8796", "snzh2013", "jd_73751adc04afd", "wdNnlMzPGJJKgqI", "yygt1158", "jd_53df36eb204a0", "花开花花落", "jd_611e082213c89", "jd_71e77d9235cf5", "jd_596fd9fea411f", "jd_7277d200aa1ac", "15230573701_p", "zb19881021", "692620136落", "168876810-159969", "zhushidan100", "上自习的猪", "15602231009_p", "jd_5213fd3fd5e09", "jd_6711f97ee4dfe", "44787591-640051", "MisterGlasses", "jd_7b22bbfe1e7e5", "138555963-81748582", "jd_QEVVkkDTQAlJ", "4932713-24535180", "jd_6dce98c07a644", "jd_DUtPtiiDamDr", "wangyneu", "wBm1TsDy3p_m", "jd_6acd3a6cc79cc","jd_444f5c020f31c","jd_71caf6b3ec4cb", "shin_dynasty", "carola82", "jd_AOhLSBLdSnux", "ningbormb"] //随机生成m(小)到n(大)的数,包含m和n function randomFriendPin(m,n) { return Math.round(Math.random()*(n - m) + m); diff --git a/jd_joy_reward.js b/jd_joy_reward.js index a8f331a..1f5749c 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -1,9 +1,7 @@ /* 宠汪汪积分兑换奖品脚本, 目前脚本只兑换京豆,兑换京豆成功,才会发出通知提示,其他情况不通知。 -更新时间:2020-11-05 +更新时间:2020-11-20 兑换规则:一个账号一天只能兑换一次京豆。 -1-20级:340积分兑换20京豆, 21-25级:320积分换20京豆 -再往上的等级兑换规则目前不知,欢迎大家提供信息 兑换奖品成功后才会有系统弹窗通知 每日京豆库存会在0:00、8:00、16:00更新,经测试发现中午12:00也会有补发京豆。 支持京东双账号 @@ -59,8 +57,6 @@ const JD_API_HOST = 'https://jdjoy.jd.com'; } continue } - message = ''; - subTitle = ''; await joyReward(); // $.msg($.name, '兑换脚本暂不能使用', `请停止使用,等待后期更新\n如果新版本兑换您有兑换机会,请抓包兑换\n再把抓包数据发送telegram用户@lxk0301`); } @@ -141,6 +137,8 @@ async function joyReward() { } else { console.log(`兑奖异常:${JSON.stringify($.exchangeRes)}`) } + } else { + console.log(`兑换京豆异常:${JSON.stringify($.exchangeRes)}`) } } else { console.log(`兑换${rewardNum}京豆失败,原因:京豆库存不足,已抢完,请下一场再兑换`) @@ -153,7 +151,7 @@ async function joyReward() { console.log('您设置了不兑换京豆,如需兑换京豆,请去BoxJs重新设置或修改第20行代码') } } else { - console.log(`${$.name}异常,${JSON.stringify($.getExchangeRewardsRes)}`) + console.log(`${$.name}getExchangeRewards异常,${JSON.stringify($.getExchangeRewardsRes)}`) } } function getExchangeRewards() { @@ -167,7 +165,7 @@ function getExchangeRewards() { "reqSource": "h5", "Connection": "keep-alive", "Accept": "*/*", - "User-Agent": "jdapp;iPhone;9.0.4;13.5.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/3B3AD5BC-B5E6-4A08-B32A-030CD805B5DD;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167283;supportBestPay/0;jdSupportDarkMode/1;pv/169.3;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/2;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|638;jdv/0|iosapp|t_335139774|appshare|CopyURL|1596547194976|1596547198;adk/;app_device/IOS;pap/JA2015_311210|9.0.4|IOS 13.5.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Referer": "https://jdjoy.jd.com/pet/index", "Accept-Language": "zh-cn", "Accept-Encoding": "gzip, deflate, br" @@ -175,10 +173,15 @@ function getExchangeRewards() { } $.get(option, (err, resp, data) => { try { - if (data) { - $.getExchangeRewardsRes = JSON.parse(data); + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) } else { - console.log(`${$.name}京豆api返回数据为空,请检查自身原因`) + if (data) { + $.getExchangeRewardsRes = JSON.parse(data); + } else { + console.log(`${$.name}api返回数据为空,请检查自身原因`) + } } } catch (e) { $.logErr(e, resp); @@ -202,7 +205,7 @@ function exchange(saleInfoId, orderSource) { "Origin": "https://jdjoy.jd.com", "reqSource": "h5", "Connection": "keep-alive", - "User-Agent": "jdapp;iPhone;9.0.4;13.5.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/3B3AD5BC-B5E6-4A08-B32A-030CD805B5DD;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167283;supportBestPay/0;jdSupportDarkMode/1;pv/169.3;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/2;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|638;jdv/0|iosapp|t_335139774|appshare|CopyURL|1596547194976|1596547198;adk/;app_device/IOS;pap/JA2015_311210|9.0.4|IOS 13.5.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Referer": "https://jdjoy.jd.com/pet/index", "Content-Length": "10", "Cookie": cookie @@ -210,11 +213,15 @@ function exchange(saleInfoId, orderSource) { } $.post(option, (err, resp, data) => { try { - // console.log('exchange', data) - if (data) { - $.exchangeRes = JSON.parse(data); + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) } else { - console.log(`${$.name}京豆api返回数据为空,请检查自身原因`) + if (data) { + $.exchangeRes = JSON.parse(data); + } else { + console.log(`${$.name}api返回数据为空,请检查自身原因`) + } } } catch (e) { $.logErr(e, resp); @@ -236,7 +243,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_joy_run.js b/jd_joy_run.js index afb2df7..534ade1 100644 --- a/jd_joy_run.js +++ b/jd_joy_run.js @@ -1,6 +1,6 @@ /** 宠汪汪邀请助力与赛跑助力脚本,感谢github@Zero-S1提供帮助 - 更新时间:2020-11-12(宠汪汪助力更新Token的配置正则表达式已改) + 更新时间:2020-11-29(宠汪汪助力更新Token的配置正则表达式已改) token时效很短,几个小时就失效了,闲麻烦的放弃就行 每天拿到token后,可一次性运行完毕即可。 @@ -15,8 +15,8 @@ hostname = draw.jdfcloud.com Surge [Script] 宠汪汪邀请助力与赛跑助力 = type=cron,cronexp="15 10 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js -宠汪汪助力更新Token = type=http-response,pattern=^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/addUser\?code=, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js -宠汪汪助力获取Token = type=http-request,pattern=^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/user\/detail\?openId=, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js +宠汪汪助力更新Token = type=http-response,pattern=^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code=, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js +宠汪汪助力获取Token = type=http-request,pattern=^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId=, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js 圈X [task_local] @@ -24,26 +24,26 @@ Surge 15 10 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, tag=宠汪汪邀请助力与赛跑助力, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true [rewrite_local] # 宠汪汪助力更新Token -^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/addUser\?code= url script-response-body https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js +^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code= url script-response-body https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js # 宠汪汪助力获取Token -^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/user\/detail\?openId= url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js +^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId= url script-request-header https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js *****Loon**** [Script] cron "15 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, tag=宠汪汪邀请助力与赛跑助力 -http-response ^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/addUser\?code= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力更新Token -http-request ^https:\/\/draw\.jdfcloud\.com\/\/api\/user\/user\/detail\?openId= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力获取Token +http-response ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力更新Token +http-request ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId= script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力获取Token **/ const isRequest = typeof $request != "undefined" -const $ = new Env('来客有礼宠汪汪'); +const $ = new Env('宠汪汪赛跑'); const JD_BASE_API = `https://draw.jdfcloud.com//pet`; //此处填入你需要助力好友的京东用户名 -//给下面好友邀请助力的 -let invite_pins = ["jd_6cd93e613b0e5,被折叠的记忆33,jd_704a2e5e28a66,jd_45a6b5953b15b,zooooo58"]; -//给下面好友赛跑助力 -let run_pins = ["jd_6cd93e613b0e5,被折叠的记忆33,jd_704a2e5e28a66,jd_45a6b5953b15b,zooooo58"]; +//下面给出好友邀请助力的示例填写规则 +let invite_pins = ["jd_6cd93e613b0e5,被折叠的记忆33,jd_704a2e5e28a66,jd_45a6b5953b15b,zooooo58,jd_66f5cecc1efcd"]; +//下面给出好友赛跑助力的示例填写规则 +let run_pins = ["jd_6cd93e613b0e5,被折叠的记忆33,jd_704a2e5e28a66,jd_45a6b5953b15b,zooooo58,jd_66f5cecc1efcd"]; // $.LKYLToken = '76fe7794c475c18711e3b47185f114b5' || $.getdata('jdJoyRunToken'); -$.LKYLToken = $.getdata('jdJoyRunToken'); +// $.LKYLToken = $.getdata('jdJoyRunToken'); //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; //IOS等用户直接用NobyDa的jd cookie @@ -55,7 +55,7 @@ const headers = { 'Lottery-Access-Signature' : '', 'Content-Type' : 'application/json', 'reqSource' : 'weapp', - 'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f2d) NetType/4G Language/zh_CN', + 'User-Agent' : $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Cookie' : '', 'openId' : '', 'Host' : 'draw.jdfcloud.com', @@ -101,19 +101,35 @@ if ($.isNode()) { } //获取来客有礼Token -function getToken() { +let count = 0; +async function getToken() { const url = $request.url; $.log(`${$.name}url\n${url}\n`) if (isURL(url, /^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code=/)) { const body = JSON.parse($response.body); - const LKYLToken = body.data.token; - $.log(`${$.name} token\n${LKYLToken}\n`) - if ($.getdata('jdJoyRunToken')) { - $.msg($.name, '更新Token: 成功🎉', `\n${LKYLToken}\n`); - } else { - $.msg($.name, '更新Token: 成功🎉', `\n${LKYLToken}\n`); + const LKYLToken = body.data && body.data.token; + if (LKYLToken) { + $.log(`${$.name} token\n${LKYLToken}\n`); + count = $.getdata('countFlag') ? $.getdata('countFlag') * 1 : 0; + count ++; + console.log(`count: ${count}`) + $.setdata(`${count}`, 'countFlag'); + if ($.getdata('countFlag') * 1 === 3) { + count = 0; + $.setdata(`${count}`, 'countFlag'); + $.msg($.name, '更新Token: 成功🎉', ``); + console.log(`开始上传Token`) + await $.http.get({url: `http://api.turinglabs.net/api/v1/jd/joy/create/${LKYLToken}/`}).then((resp) => { + if (resp.statusCode === 200) { + let { body } = resp; + console.log(`Token提交结果:${body}`) + body = JSON.parse(body); + console.log(`${body.message}`) + } + }); + } + $.setdata(LKYLToken, 'jdJoyRunToken'); } - $.setdata(LKYLToken, 'jdJoyRunToken'); $.done({ body: JSON.stringify(body) }) } else if (isURL(url, /^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId=/)){ if ($request && $request.method !== 'OPTIONS') { @@ -128,19 +144,49 @@ function getToken() { //} $.setdata(LKYLToken, 'jdJoyRunToken'); - $.msg($.name, '获取Token: 成功🎉', `\n${LKYLToken}\n`); + $.msg($.name, '获取Token: 成功🎉', ``); // $.done({ body: JSON.stringify(body) }) $.done({ url: url }) } + } else { + $.done() } } +function readToken() { + return new Promise(resolve => { + $.get({url: `http://api.turinglabs.net/api/v1/jd/joy/read/1/`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(data) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} async function main() { - console.log(`打印token \n${$.getdata('jdJoyRunToken')}\n`) if (!cookiesArr[0]) { $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); return; } + const readTokenRes = await readToken(); + if (readTokenRes && readTokenRes.code === 200) { + $.LKYLToken = readTokenRes.data[0] || $.getdata('jdJoyRunToken'); + } else { + $.LKYLToken = $.getdata('jdJoyRunToken'); + } + // $.LKYLToken = $.getdata('jdJoyRunToken'); + console.log(`打印token \n${$.LKYLToken}\n`) if (!$.LKYLToken) { $.msg($.name, '【提示】请先获取来客有礼宠汪汪token', "微信搜索'来客有礼'小程序\n点击底部的'发现'Tab\n即可获取Token"); return; @@ -153,8 +199,6 @@ async function main() { $.inviteReward = 0; $.runReward = 0; console.log(`\n开始【京东账号${$.index}】${UserName}\n`); - message = ''; - subTitle = ''; $.jdLogin = true; $.LKYLLogin = true; console.log(`=============【开始邀请助力】===============`) diff --git a/jd_joy_steal.js b/jd_joy_steal.js index 2a00493..c17d16d 100644 --- a/jd_joy_steal.js +++ b/jd_joy_steal.js @@ -228,7 +228,7 @@ function getFriends(currentPage = '1') { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } @@ -404,7 +404,7 @@ function getCoinChanges() { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } @@ -475,7 +475,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -513,7 +513,7 @@ function taskUrl(functionId, friendPin) { 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Referer': 'https://jdjoy.jd.com/pet/index', - 'User-Agent': 'jdapp;iPhone;8.5.8;13.4.1;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167169;supportBestPay/0;jdSupportDarkMode/0;pv/200.75;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/29;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|608;jdv/0|direct|-|none|-|1587263154256|1587263330;adk/;app_device/IOS;pap/JA2015_311210|8.5.8|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } diff --git a/jd_jxstory.js b/jd_jxstory.js new file mode 100644 index 0000000..7c1260c --- /dev/null +++ b/jd_jxstory.js @@ -0,0 +1,655 @@ +/* +京喜故事 +活动入口 :京喜APP->首页浮动窗口去领钱/京喜工厂-金牌厂长 +每天运行一次即可 + + +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京喜故事 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jxstory.js, tag=京喜故事, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jxstory.js,tag=京喜故事 + +===============Surge================= +京喜故事 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jxstory.js + +============小火箭========= +京喜故事 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jxstory.js, cronexpr="10 * * * *", timeout=200, enable=true + + */ + + +const $ = new Env('京喜故事'); +const JD_API_HOST = 'https://m.jingxi.com'; + +const notify = $.isNode() ? require('./sendNotify') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = 3; +let cookiesArr = [], cookie = '', message = ''; +const inviteCodes = ['qSDHMwUOz7onHcMyaju4KmdSXWf0dlv7LVnTt1Wzemo=@iuGNoGYvk9YdEImUAz25Wyzm7oeggrm0JSIYgZdHJGI=', 'iuGNoGYvk9YdEImUAz25Wyzm7oeggrm0JSIYgZdHJGI=']; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]) +} +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + $.ele = 0; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await shareCodesFormat(); + await jdJxStory() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdJxStory() { + await userInfo() + await helpFriends() + await sign() + await taskList() + for(let i =0;i { + $.get(taskurl('SignIn', `date=${new Date().Format("yyyyMMdd")}&type=0`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`签到钞票:收取成功,获得 ${data['data']['rewardMoneyToday']}`) + message += `【签到钞票】:收取成功,获得 ${data['data']['rewardMoneyToday']}\n` + } else { + console.log(`签到钞票:收取失败,${data.msg}`) + message += `【签到钞票】收取失败,${data.msg}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 初始化任务 +function taskList() { + return new Promise(async resolve => { + $.get(newtasksysUrl('GetUserTaskStatusList'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + let userTaskStatusList = data['data']['userTaskStatusList']; + for (let i = 0; i < userTaskStatusList.length; i++) { + const vo = userTaskStatusList[i]; + if (vo['awardStatus'] !== 1) { + if (vo.completedTimes >= vo.targetTimes) { + console.log(`任务:${vo.description}可完成`) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } else { + switch (vo.taskType) { + case 2: // 逛一逛任务 + case 6: // 浏览商品任务 + case 9: // 开宝箱 + for (let i = vo.completedTimes; i <= vo.configTargetTimes; ++i) { + console.log(`去做任务:${vo.taskName}`) + await doTask(vo.taskId) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } + break + case 4: // 招工 + break + case 5: // 京喜工厂投入电力 + console.log(`去做任务:${vo.taskName}`) + await doTask(vo.taskId) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + break + case 1: // 登陆领奖 + default: + break + } + } + } + } + console.log(`完成任务:共领取${$.ele}钞票`) + message += `【每日任务】领奖成功,共计 ${$.ele} 钞票\n`; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 钞票翻倍任务 +async function cardList() { + for (let i = 0; i < 10; ++i) { + await readyCard(); + } +} +function readyCard() { + return new Promise(async resolve => { + $.get(taskurl('ReadyCard'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + + if(data['ret']===0 && data['data']['flopFinishNumber']{ + return { + "cardId" : vo['cardId'], + "cardPosition" : index+1, + "cardStatus" :0 + } + }) + cardInfo[0]['cardStatus'] = 1 + + await selectCard(cardInfo) + // await $.wait(1000); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 选择卡片 +function selectCard(cardInfo) { + return new Promise(async resolve => { + $.get(taskurl('SelectCard',`cardInfo=${JSON.stringify({"cardInfo":cardInfo})}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret']===0){ + await $.wait(10000); + await finishCard(cardInfo[0]['cardId']) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 完成卡片 +function finishCard(cardId) { + return new Promise(async resolve => { + $.get(taskurl('FinishCard',`cardid=${cardId}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret']===0){ + let ratio = data['data']['cardInfo'].filter(vo=>vo['cardId']===cardId)[0]['cardRatio'] + console.log(`翻倍成功,获得${ratio}%,共计获得${data['data']['earnRatio']}%`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 升级 +function upgrade() { + return new Promise(async resolve => { + $.get(taskurl('UpgradeUserLevelDraw', `date=${new Date().Format("yyyyMMdd")}&type=0`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0&&data['data']['active']!=='') { + console.log(`升级成功,获得${JSON.stringify(data['data'])}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +// 点击 +function increase() { + return new Promise(async resolve => { + $.get(taskurl('IncreaseUserMoney'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`点击厂长成功,获得 ${data['data']['moneyNum']} 钞票`) + }else if(data['ret'] === 2005){ + // 点击上限 + $.click = false + }else{ + console.log(`点击厂长过快,休息25秒`) + await $.wait(25000); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (code) { + if ($.shareId === code) { + console.log(`不能为自己助力,跳过`); + continue; + } + await assistFriend(code); + } + } +} +// 帮助用户 +function assistFriend(shareId) { + return new Promise(async resolve => { + $.get(taskurl('AssistFriend',`shareId=${escape(shareId)}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`助力朋友:${shareId}成功`) + } else { + console.log(`助力朋友[${shareId}]失败:${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 任务领奖 +function completeTask(taskId, taskName) { + return new Promise(async resolve => { + $.get(newtasksysUrl('Award', taskId), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + switch (data['data']['awardStatus']) { + case 1: + $.ele += Number(data['data']['prizeInfo'].replace('\\n', '')) + console.log(`领取${taskName}任务奖励成功,收获:${Number(data['data']['prizeInfo'].replace('\\n', ''))}钞票`); + break + case 1013: + case 0: + console.log(`领取${taskName}任务奖励失败,任务已领奖`); + break + default: + console.log(`领取${taskName}任务奖励失败,${data['msg']}`) + break + } + // if (data['ret'] === 0) { + // console.log("做任务完成!") + // } else { + // console.log(`异常:${JSON.stringify(data)}`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 完成任务 +function doTask(taskId) { + return new Promise(async resolve => { + $.get(newtasksysUrl('DoTask', taskId), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log("做任务完成!") + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化个人信息 +function userInfo() { + return new Promise(async resolve => { + $.get(taskurl('GetUserInfo', ), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.shareId = data['shareId']; + console.log(`分享码: ${data['shareId']}`); + $.currentMoneyNum = data.currentMoneyNum; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function showMsg() { + return new Promise(async resolve => { + let ctrTemp; + if ($.isNode() && process.env.JXSTORY_NOTIFY_CONTROL) { + ctrTemp = `${process.env.JXSTORY_NOTIFY_CONTROL}` === 'false'; + } else if ($.getdata('jdJxStory')) { + ctrTemp = $.getdata('jdJxStory') === 'false'; + } else { + ctrTemp = `${jdNotify}` === 'false'; + } + if (ctrTemp) { + $.msg($.name, '', message); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${message}`); + } + } else { + $.log(`\n${message}\n`); + } + resolve() + }) +} +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `http://api.turinglabs.net/api/v1/jd/jxstory/read/${randomCount}/`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + // await $.wait(2000); + // resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + // const readShareCodeRes = await readShareCode(); + // if (readShareCodeRes && readShareCodeRes.code === 200) { + // $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + // } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = $.isNode() ? require('./jdJxStoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function taskurl(functionId, body = '') { + return { + url: `${JD_API_HOST}/jxstory/userinfo/${functionId}?bizcode=jxstory&${body}&_time=${Date.now()}&_=${Date.now()}&sceneval=2&g_login_type=1`, + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': 'jdpingou;iPhone;3.15.2;14.2;ae75259f6ca8378672006fc41079cd8c90c53be8;network/wifi;model/iPhone10,2;appBuild/100365;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/158;pap/JA2015_311210;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', + 'Accept-Language': 'zh-cn', + 'Referer': 'https://st.jingxi.com/pingou/jx_factory_story/index.html?ptag=138963.4.3', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} +function newtasksysUrl(functionId, taskId) { + let url = `${JD_API_HOST}/newtasksys/newtasksys_front/${functionId}?source=jxstory&bizCode=jxstory&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now()}`; + if (taskId) { + url += `&taskId=${taskId}`; + } + return { + url, + "headers": { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;", + 'Accept-Language': 'zh-cn', + 'Referer': 'https://st.jingxi.com/pingou/jx_factory_story/index.html', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} +Date.prototype.Format = function (fmt) { //author: meizz + var o = { + "M+": this.getMonth() + 1, //月份 + "d+": this.getDate(), //日 + "h+": this.getHours(), //小时 + "m+": this.getMinutes(), //分 + "s+": this.getSeconds(), //秒 + "q+": Math.floor((this.getMonth() + 3) / 3), //季度 + "S": this.getMilliseconds() //毫秒 + }; + if (/(y+)/.test(fmt)) + fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(fmt)) + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_kd.js b/jd_kd.js new file mode 100644 index 0000000..50c410a --- /dev/null +++ b/jd_kd.js @@ -0,0 +1,197 @@ +/* +京东快递签到 +活动地址:https://jingcai-h5.jd.com/#/ +签到领豆,14天内满4次和7次享额外奖励,每天运行一次即可 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js + +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东快递签到 +10 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, tag=京东快递签到, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_kd.png, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, tag=京东快递签到 + +===============Surge================= +京东快递签到 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js + +============小火箭========= +京东快递签到 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, cronexpr="10 0 * * *", timeout=200, enable=true + */ +const $ = new Env('京东快递签到'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await userSignIn(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function userSignIn() { + return new Promise(resolve => { + $.post(taskUrl(), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(resp) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 1) { + console.log(`今日签到成功,获得${data.content[0].title}`) + message += `今日签到成功,获得${data.content[0].title} 🐶\n`; + + } else if (data.code === -1) { + console.log(`今日已签到`) + message += `【签到】失败,今日已签到`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl() { + return { + url: `https://lop-proxy.jd.com/jiFenApi/signInAndGetReward`, + body: '[{"userNo":"$cooMrdGatewayUid$"}]', + headers: { + 'Host': 'lop-proxy.jd.com', + 'lop-dn': 'jingcai.jd.com', + 'biz-type': 'service-monitor', + 'app-key': 'jexpress', + 'access': 'H5', + 'content-type': 'application/json;charset=utf-8', + 'clientinfo': '{"appName":"jingcai","client":"m"}', + 'accept': 'application/json, text/plain, */*', + 'jexpress-report-time': '1607330170578', + 'x-requested-with': 'XMLHttpRequest', + 'source-client': '2', + 'appparams': '{"appid":158,"ticket_type":"m"}', + 'version': '1.0.0', + 'origin': 'https://jingcai-h5.jd.com', + 'sec-fetch-site': 'same-site', + 'sec-fetch-mode': 'cors', + 'sec-fetch-dest': 'empty', + 'referer': 'https://jingcai-h5.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9', + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_live_redrain.js b/jd_live_redrain.js new file mode 100644 index 0000000..66dca29 --- /dev/null +++ b/jd_live_redrain.js @@ -0,0 +1,246 @@ +/* +直播红包雨 +每天0,9,11,13,15,17,19,20,21,23可领,每日上限未知 +活动时间:2020-12-7 到 2020-12-12 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#直播红包雨 +0 0,9,11,13,15,17,19,20,21,23 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "0 0,9,11,13,15,17,19,20,21,23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 + +===============Surge================= +直播红包雨 = type=cron,cronexp="0 0,9,11,13,15,17,19,20,21,23 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js + +============小火箭========= +直播红包雨 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, cronexpr="0 0,9,11,13,15,17,19,20,21,23 * * *", timeout=200, enable=true + */ +const $ = new Env('直播红包雨'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + await getRedRain(); + if(!$.activityId) return + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : ""}`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + let nowTs = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 + // console.log(nowTs, $.startTime, $.endTime) + if ($.startTime <= nowTs && nowTs < $.endTime) { + await receiveRedRain(); + } else { + console.log(`不在红包雨时间之内`) + message += `不在红包雨时间之内` + } + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function getRedRain() { + return new Promise(resolve => { + $.post(taskPostUrl('liveActivityV842'), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.iconArea) { + let act = data.data.iconArea[0] + let url = data.data.iconArea[0].data.activityUrl + $.activityId = url.substr(url.indexOf("id=") + 3) + $.startTime = act.startTime + $.endTime = act.endTime + console.log(`下一场红包雨开始时间:${new Date(act.startTime)}`) + console.log(`下一场红包雨结束时间:${new Date(act.endTime)}`) + } else { + console.log(`暂无红包雨`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveRedRain() { + return new Promise(resolve => { + const body = {"actId": $.activityId}; + $.get(taskUrl('noahRedRainLottery', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.subCode === '0') { + console.log(`领取成功,获得${JSON.stringify(data.lotteryResult)}`) + // message+= `领取成功,获得${JSON.stringify(data.lotteryResult)}\n` + message += `${data.lotteryResult.jPeasList[0].ext}:${(data.lotteryResult.jPeasList[0].quantity)}京豆\n` + + } else if (data.subCode === '8') { + console.log(`今日次数已满`) + message += `领取失败,今日已签到\n`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `https://api.m.jd.com/client.action?functionId=${function_id}`, + body: 'body=%7B%22liveId%22%3A%222940585%22%7D&build=167408&client=apple&clientVersion=9.2.0&d_brand=apple&d_model=iPhone10%2C2&eid=eidIF3CF0112RTIyQTVGQTEtRDVCQy00Qg%3D%3D6HAJa9%2B/4Vedgo62xKQRoAb47%2Bpyu1EQs/6971aUvk0BQAsZLyQAYeid%2BPgbJ9BQoY1RFtkLCLP5OMqU&isBackground=Y&joycious=193&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&scope=01&sign=7e971605d8af9b6e40feb41e62893a63&st=1607389929151&sv=111&uts=0f31TVRjBSsxtiCuhT3/0Snw3oVtxkoVjP%2BnIIqtRBVZ6VIHub43H/trIkV5b%2BgqoCQ7mbttSEPca%2BOXsRcbxYda9CyPEW6BOlaC6KrfHnFbOmKyzcBSs1CpUf7QbFhQreXDZZjo44tCH2GKLlG5xh9SbE/Hggt//Go27hw79QdJ92%2BRFXGOEwN13aZu%2BrjHy50cnmfHmG8oU05aJ6vcjA%3D%3D', + headers: { + 'Host': 'api.m.jd.com', + 'content-type': 'application/x-www-form-urlencoded', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167408 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + //"Cookie": cookie, + } + } +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&_=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://h5.m.jd.com/active/redrain/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_lotteryMachine.js b/jd_lotteryMachine.js index 452a1d6..3b15d13 100644 --- a/jd_lotteryMachine.js +++ b/jd_lotteryMachine.js @@ -47,7 +47,7 @@ function updateShareCodes(url = 'https://raw.githubusercontent.com/yangtingxiao/ }) }) } -function updateShareCodesCDN(url = 'https://cdn.jsdelivr.net/gh/yangtingxiao/QuantumultX@master/scripts/jd/jd_lotteryMachine.js') { +function updateShareCodesCDN(url = 'https://raw.fastgit.org/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js') { return new Promise(resolve => { $.get({url}, async (err, resp, data) => { try { diff --git a/jd_mohe.js b/jd_mohe.js index 3bc8f5c..600221c 100644 --- a/jd_mohe.js +++ b/jd_mohe.js @@ -387,7 +387,7 @@ function lottery() { "content-type": "application/x-www-form-urlencoded", "cookie": cookie, "referer": "https://blindbox.jd.com/", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1 Edg/84.0.4147.125" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.get(options, (err, resp, data) => { @@ -414,7 +414,7 @@ function taskurl(url) { "content-type": "application/x-www-form-urlencoded", "cookie": cookie, "referer": "https://blindbox.jd.com/", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1 Edg/84.0.4147.125" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } } diff --git a/jd_moneyTree.js b/jd_moneyTree.js index 0cac275..b2f5cc4 100644 --- a/jd_moneyTree.js +++ b/jd_moneyTree.js @@ -1,6 +1,6 @@ /* 京东摇钱树 :https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_moneyTree.js -更新时间:2020-11-07 +更新时间:2020-11-16 京东摇钱树支持京东双账号 注:如果使用Node.js, 需自行安装'crypto-js,got,http-server,tough-cookie'模块. 例: npm install crypto-js http-server tough-cookie got --save */ @@ -30,7 +30,6 @@ if ($.isNode()) { cookiesArr.push($.getdata('CookieJD2')); } -const Notice = $.getdata('jdMoneyTreeNoticeTimes') * 1 || 2;//设置运行多少次才通知。默认运行两次脚本通知,其他设置请在BoxJs进行设置 let jdNotify = true;//是否开启静默运行,默认true开启 const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; let userInfo = null, taskInfo = [], message = '', subTitle = '', fruitTotal = 0; @@ -78,18 +77,10 @@ async function jd_moneyTree() { await sell(); await myWealth(); await stealFriendFruit() - await msgControl(); - console.log(`运行脚本次数和设置的次数是否相等::${($.getdata($.treeMsgTime) * 1) === Notice}`); - jdNotify = $.getdata('jdMoneyTreeNotify') ? $.getdata('jdMoneyTreeNotify') : jdNotify; - console.log(`box订阅静默运行-是否打开::${jdNotify || jdNotify === 'true'}`); - console.log(`是否弹窗通知::${(($.getdata($.treeMsgTime) * 1) === Notice) && (!jdNotify || jdNotify === 'false')}`); $.log(`\n${message}\n`); if (!jdNotify || jdNotify === 'false') { - if (($.getdata($.treeMsgTime) * 1) === Notice) { - $.msg($.name, subTitle, message); - $.setdata('0', $.treeMsgTime); - } + $.msg($.name, subTitle, message); } } function user_info() { @@ -121,13 +112,6 @@ function user_info() { if (userInfo.realName) { // console.log(`助力码sharePin为::${userInfo.sharePin}`); $.treeMsgTime = userInfo.sharePin; - if ($.getdata($.treeMsgTime)) { - if ($.getdata($.treeMsgTime) >= Notice) { - $.setdata('0', $.treeMsgTime); - } - } else { - $.setdata('0', $.treeMsgTime); - } subTitle = `【${userInfo.nick}】${userInfo.treeInfo.treeName}`; // message += `【我的金果数量】${userInfo.treeInfo.fruit}\n`; // message += `【我的金币数量】${userInfo.treeInfo.coin}\n`; @@ -273,6 +257,12 @@ function sell() { } params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) console.log(`目前金果数量${fruitTotal}`) + if ($.isNode()) { + if (process.env.MONEY_TREE_SELL_FRUIT && process.env.MONEY_TREE_SELL_FRUIT === 'false') { + rs() + return + } + } if (fruitTotal > 380) { request('sell', params).then((sellRes) => { console.log(`卖出金果结果:${JSON.stringify(sellRes)}\n`) @@ -583,7 +573,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -648,7 +638,7 @@ function taskurl(function_id, body) { 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`, 'Host' : `ms.jr.jd.com`, 'Connection' : `keep-alive`, - 'User-Agent' : `jdapp;iPhone;9.0.0;13.4.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/F75E8AED-CB48-4EAC-A213-E8CE4018F214;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167237;supportBestPay/0;jdSupportDarkMode/0;pv/1287.19;apprpd/MyJD_GameMain;ref/https%3A%2F%2Fuua.jr.jd.com%2Fuc-fe-wxgrowing%2Fmoneytree%2Findex%2F%3Fchannel%3Dyxhd%26lng%3D113.325843%26lat%3D23.204628%26sid%3D2d98e88cf7d182f60d533476c2ce777w%26un_area%3D19_1601_50258_51885;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|3485;jdv/0|kong|t_1000170135|tuiguang|notset|1593059927172|1593059927;adk/;app_device/IOS;pap/JA2015_311210|9.0.0|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'User-Agent' : $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Referer' : `https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index/?channel=yxhd&lng=113.325896&lat=23.204600&sid=2d98e88cf7d182f60d533476c2ce777w&un_area=19_1601_50258_51885`, 'Accept-Language' : `zh-cn` } diff --git a/jd_ms_redrain.js b/jd_ms_redrain.js new file mode 100644 index 0000000..446e24c --- /dev/null +++ b/jd_ms_redrain.js @@ -0,0 +1,187 @@ +/* +秒杀红包雨,可以获取3次,一天运行一次即可 +活动时间:2020-12-1 到 2020-12-31 +活动入口:首页👉秒杀👉往下拉(手指向上滑动)👉可以看到狂撒2亿京东 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#秒杀红包雨 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨 + +===============Surge================= +秒杀红包雨 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js + +============小火箭========= +秒杀红包雨 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('秒杀红包雨'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + for(let i=0;i<3;++i){ + await getRedRain(); + await $.wait(5000); //防止黑号 + } + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function getRedRain() { + return new Promise(resolve => { + const body = {"actId":"RRA318jCtaXhZJgiLryM1iydEhc7Jna"}; + $.get(taskUrl('noahRedRainLottery', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.subCode === '0') { + console.log(`领取成功,获得${JSON.stringify(data.lotteryResult)}`) + // message+= `领取成功,获得${JSON.stringify(data.lotteryResult)}\n` + message+= `${data.lotteryResult.jPeasList[0].ext}:${(data.lotteryResult.jPeasList[0].quantity)}京豆\n` + + } else if (data.subCode === '8') { + console.log(`今日次数已满`) + message += `领取失败,今日已签到\n`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&_=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://h5.m.jd.com/active/redrain/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_necklace.js b/jd_necklace.js new file mode 100644 index 0000000..c6cb87d --- /dev/null +++ b/jd_necklace.js @@ -0,0 +1,309 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-20 11:42:03 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-11-23 12:27:14 + */ +/* +点点券,可以兑换无门槛红包(1元,5元,10元,100元,部分红包需抢购) +APP活动入口:“最新版本京东APP >领券中心/券后9.9>领点点券”页面 +网页入口:https://h5.m.jd.com/babelDiy/Zeus/41Lkp7DumXYCFmPYtU3LTcnTTXTX/index.html +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===============Quantumultx=============== +[task_local] +#点点券 +10 0,20 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js, tag=点点券, enabled=true + +================Loon============== +[Script] +cron "10 0,20 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js,tag=点点券 + +===============Surge================= +点点券 = type=cron,cronexp="10 0,20 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js + +============小火箭========= +点点券 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js, cronexpr="10 0,20 * * *", timeout=200, enable=true + */ +const $ = new Env('点点券'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} + +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await jd_necklace(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jd_necklace() { + await necklace_homePage(); + await doTask(); + await necklace_homePage(); + await receiveBubbles(); + await sign(); + await necklace_homePage(); + await showMsg(); +} +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n当前${$.name}${$.totalScore}个`); + resolve() + }) +} +async function doTask() { + for (let item of $.taskConfigVos) { + if (item.taskStage === 0) { + console.log(`${item.taskName}未完成`); + await necklace_startTask(item.id); + await $.wait(2000); + await necklace_startTask(item.id); + } else if (item.taskStage === 2) { + console.log(`${item.taskName}任务已做完,奖励未领取`); + } else if (item.taskStage === 3) { + console.log(`${item.taskName}奖励已领取`); + } + } +} +async function receiveBubbles() { + for (let item of $.bubbles) { + console.log(`开始领取点点券\n`); + await necklace_chargeScores(item.id) + } +} +async function sign() { + if ($.signInfo.todayCurrentSceneSignStatus === 1) { + await necklace_sign(); + } else { + console.log(`当前${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}已签到`) + } +} +//每日签到福利 +function necklace_sign() { + return new Promise(resolve => { + const body = { + currentDate: $.lastRequestTime.replace(/:/g, "%3A"), + } + $.post(taskPostUrl("necklace_sign", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(data); + if (safeGet(data)) { + data = JSON.parse(data); + if (data.rtn_code === 0) { + if (data.data.biz_code === 0) { + console.log(`签到成功,时间:${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}`) + // $.taskConfigVos = data.data.result.taskConfigVos; + // $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//领取奖励 +function necklace_chargeScores(bubleId) { + return new Promise(resolve => { + const body = { + bubleId, + currentDate: $.lastRequestTime.replace(/:/g, "%3A"), + } + $.post(taskPostUrl("necklace_chargeScores", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(data); + if (safeGet(data)) { + data = JSON.parse(data); + if (data.rtn_code === 0) { + if (data.data.biz_code === 0) { + // $.taskConfigVos = data.data.result.taskConfigVos; + // $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function necklace_startTask(taskId) { + return new Promise(resolve => { + const body = { + taskId, + currentDate: $.lastRequestTime.replace(/:/g, "%3A"), + } + $.post(taskPostUrl("necklace_startTask", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(data); + if (safeGet(data)) { + data = JSON.parse(data); + if (data.rtn_code === 0) { + if (data.data.biz_code === 0) { + // $.taskConfigVos = data.data.result.taskConfigVos; + // $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function necklace_homePage() { + return new Promise(resolve => { + $.post(taskPostUrl('necklace_homePage'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.rtn_code === 0) { + if (data.data.biz_code === 0) { + $.taskConfigVos = data.data.result.taskConfigVos; + $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + $.lastRequestTime = data.data.result.lastRequestTime; + $.bubbles = data.data.result.bubbles; + $.signInfo = data.data.result.signInfo; + $.totalScore = data.data.result.totalScore; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskPostUrl(function_id, body = {}) { + const time = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + return { + url: `${JD_API_HOST}?functionId=${function_id}&appid=jd_mp_h5&loginType=2&client=jd_mp_h5&t=${time}&body=${escape(JSON.stringify(body))}`, + headers: { + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_pet.js b/jd_pet.js index 3c1f9e1..7e71281 100644 --- a/jd_pet.js +++ b/jd_pet.js @@ -1,6 +1,6 @@ /* 东东萌宠 更新地址: https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pet.js -更新时间:2020-11-07 +更新时间:2020-11-30 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -38,7 +38,7 @@ let message = '', subTitle = '', option = {}; let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 const JD_API_HOST = 'https://api.m.jd.com/client.action'; let goodsUrl = '', taskInfoKey = []; -let randomCount = 20; +let randomCount = $.isNode() ? 20 : 5; !(async () => { await requireConfig(); if (!cookiesArr[0]) { @@ -87,13 +87,18 @@ async function jdPet() { if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') { $.petInfo = initPetTownRes.result; if ($.petInfo.userStatus === 0) { - $.msg($.name, '【提示】此账号萌宠活动未开始,请手动去京东APP开启活动\n入口:我的->游戏与互动->查看更多', '', { "open-url": "openapp.jdmoble://" }); + $.msg($.name, '', `【提示】京东账号${$.index}${$.nickName}\n萌宠活动未开启\n请手动去京东APP开启活动\n入口:我的->游戏与互动->查看更多开启`, { "open-url": "openapp.jdmoble://" }); + return + } + if (!$.petInfo.goodsInfo) { + $.msg($.name, '', `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`, { "open-url": "openapp.jdmoble://" }); + await notify.sendNotify(`${$.name} - ${$.index} - ${$.nickName}`, `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`); return } goodsUrl = $.petInfo.goodsInfo && $.petInfo.goodsInfo.goodsUrl; // option['media-url'] = goodsUrl; // console.log(`初始化萌宠信息完成: ${JSON.stringify(petInfo)}`); - if ($.petInfo.petStatus === 5 && $.petInfo.showHongBaoExchangePop) { + if ($.petInfo.petStatus === 5) { await slaveHelp();//可以兑换而没有去兑换,也能继续助力好友 option['open-url'] = "openApp.jdMobile://"; $.msg($.name, `【提醒⏰】${$.petInfo.goodsInfo.goodsName}已可领取`, '请去京东APP或微信小程序查看', option); @@ -101,6 +106,14 @@ async function jdPet() { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `京东账号${$.index} ${$.nickName}\n${$.petInfo.goodsInfo.goodsName}已可领取`); } return + } else if ($.petInfo.petStatus === 6) { + await slaveHelp();//已领取红包,但未领养新的,也能继续助力好友 + option['open-url'] = "openApp.jdMobile://"; + $.msg($.name, `【提醒⏰】已领取红包,但未继续领养新的物品`, '请去京东APP或微信小程序继续领养', option); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `京东账号${$.index} ${$.nickName}\n已领取红包,但未继续领养新的物品`); + } + return } console.log(`\n【您的互助码shareCode】 ${$.petInfo.shareCode}\n`); await taskInit(); @@ -128,7 +141,7 @@ async function energyCollect() { let function_id = arguments.callee.name.toString(); const response = await request(function_id); // console.log(`收取任务奖励好感度完成:${JSON.stringify(response)}`); - if (response.code === '0') { + if (response.resultCode === '0') { message += `【第${response.result.medalNum + 1}块勋章完成进度】${response.result.medalPercent}%,还需收集${response.result.needCollectEnergy}好感\n`; message += `【已获得勋章】${response.result.medalNum}块,还需收集${response.result.needCollectMedalNum}块即可兑换奖品“${$.petInfo.goodsInfo.goodsName}”\n`; } @@ -154,7 +167,7 @@ async function feedPetsAgain() { // message += `【剩余狗粮】${$.petInfo.foodAmount}g\n`; } else { console.log("目前剩余狗粮:【" + foodAmount + "】g,不再继续投食,保留部分狗粮用于完成第二天任务"); - subTitle = $.petInfo.goodsInfo.goodsName; + subTitle = $.petInfo.goodsInfo && $.petInfo.goodsInfo.goodsName; // message += `【与爱宠相识】${$.petInfo.meetDays}天\n`; // message += `【剩余狗粮】${$.petInfo.foodAmount}g\n`; } @@ -183,9 +196,9 @@ async function doTask() { if (threeMealInit && !threeMealInit.finished) { if (threeMealInit.timeRange === -1) { console.log(`未到三餐时间`); - return + } else { + await threeMealInitFun(); } - await threeMealInitFun(); } if (browseShopsInit && !browseShopsInit.finished) { await browseShopsInitFun(); @@ -257,7 +270,7 @@ async function slaveHelp() { let response = await request(arguments.callee.name.toString(), {'shareCode': code}); if (response.code === '0' && response.resultCode === '0') { if (response.result.helpStatus === 0) { - console.log('已给好友: 【' + response.result.masterNickName + '】助力'); + console.log('已给好友: 【' + response.result.masterNickName + '】助力成功'); helpPeoples += response.result.masterNickName + ','; } else if (response.result.helpStatus === 1) { // 您今日已无助力机会 @@ -423,7 +436,7 @@ async function showMsg() { } } function readShareCode() { - return new Promise(resolve => { + return new Promise(async resolve => { $.get({url: `http://api.turinglabs.net/api/v1/jd/pet/read/${randomCount}/`}, (err, resp, data) => { try { if (err) { @@ -441,6 +454,8 @@ function readShareCode() { resolve(data); } }) + await $.wait(10000); + resolve() }) } function shareCodesFormat() { @@ -536,7 +551,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -568,7 +583,7 @@ function TotalBean() { async function request(function_id, body = {}) { await $.wait(3000); //歇口气儿, 不然会报操作频繁 return new Promise((resolve, reject) => { - $.get(taskUrl(function_id, body), (err, resp, data) => { + $.post(taskUrl(function_id, body), (err, resp, data) => { try { if (err) { console.log('\n东东萌宠: API查询请求失败 ‼️‼️'); @@ -585,15 +600,28 @@ async function request(function_id, body = {}) { }) }) } +// function taskUrl(function_id, body = {}) { +// return { +// url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&loginWQBiz=pet-town&body=${escape(JSON.stringify(body))}`, +// headers: { +// Cookie: cookie, +// UserAgent: $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), +// } +// }; +// } function taskUrl(function_id, body = {}) { + body["version"] = 2; + body["channel"] = 'app'; return { - url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&loginWQBiz=pet-town&body=${escape(JSON.stringify(body))}`, + url: `${JD_API_HOST}?functionId=${function_id}`, + body: `body=${escape(JSON.stringify(body))}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`, headers: { - Cookie: cookie, - UserAgent: `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1`, + 'Cookie': cookie, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', } }; } - // prettier-ignore function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,o)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),h=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t))}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",o){const r=t=>{if(!t||!this.isLoon()&&this.isSurge())return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,r(o)):this.isQuanX()&&$notify(e,s,i,r(o)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_pigPet.js b/jd_pigPet.js index 98c1548..e71c979 100644 --- a/jd_pigPet.js +++ b/jd_pigPet.js @@ -1,14 +1,23 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-10 14:07:07 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-11-23 12:27:16 + */ /* 京东金融养猪猪 一键开完所有的宝箱功能。耗时70秒 -抽奖 +大转盘抽奖 喂食 +每日签到 +完成分享任务得猪粮 12 * * * * */ const $ = new Env('金融养猪'); let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; +const MISSION_BASE_API = `https://ms.jr.jd.com/gw/generic/mission/h5/m`; const notify = $.isNode() ? require('./sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; @@ -43,11 +52,6 @@ if ($.isNode()) { } continue } - message = ''; - subTitle = ''; - goodsUrl = ''; - taskInfoKey = []; - option = {}; await jdPigPet(); } } @@ -59,9 +63,15 @@ if ($.isNode()) { $.done(); }) async function jdPigPet() { + await pigPetLogin(); + if (!$.hasPig) return + await pigPetSignIndex(); + await pigPetSign(); await pigPetOpenBox(); await pigPetLotteryIndex(); await pigPetLottery(); + await pigPetMissionList(); + await missions(); await pigPetUserBag(); } async function pigPetLottery() { @@ -71,6 +81,53 @@ async function pigPetLottery() { } } } +async function pigPetSign() { + if (!$.sign) { + await pigPetSignOne(); + } else { + console.log(`第${$.no}天已签到\n`) + } +} +function pigPetSignOne() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam": "{}", + "no": $.no + } + $.post(taskUrl('pigPetSignOne', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('签到结果',data) + // data = JSON.parse(data); + // if (data.resultCode === 0) { + // if (data.resultData.resultCode === 0) { + // if (data.resultData.resultData) { + // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + // $.sign = data.resultData.resultData.sign; + // $.no = data.resultData.resultData.today; + // } + // } else { + // console.log(`查询签到情况异常:${JSON.stringify(data)}`) + // } + // } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} //查询背包食物 function pigPetUserBag() { return new Promise(async resolve => { @@ -91,7 +148,7 @@ function pigPetUserBag() { console.log(`${item.goodsName} ${item.count}g`); } for (let item of data.resultData.resultData.goods) { - if (item.count > 20) { + if (item.count >= 20) { console.log(`10秒后开始喂食${item.goodsName},当前数量为${item.count}g`) await $.wait(10000); await pigPetAddFood(item.sku); @@ -120,7 +177,19 @@ function pigPetUserBag() { function pigPetAddFood(skuId) { return new Promise(async resolve => { console.log(`skuId::::${skuId}`) - const body = {"source":0,"channelLV":"yqs","riskDeviceParam":"{}","t":1605073588888, skuId ,"category":"1001"} + const body = { + "source": 0, + "channelLV":"yqs", + "riskDeviceParam":"{}", + "skuId": skuId.toString(), + "category":"1001", + } + // const body = { + // "source": 2, + // "channelLV":"juheye", + // "riskDeviceParam":"{}", + // "skuId": skuId.toString(), + // } $.post(taskUrl('pigPetAddFood', body), (err, resp, data) => { try { if (err) { @@ -128,7 +197,7 @@ function pigPetAddFood(skuId) { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - // console.log(data) + console.log(`喂食结果:${data}`) data = JSON.parse(data); } else { console.log(`京东服务器返回空数据`) @@ -142,6 +211,43 @@ function pigPetAddFood(skuId) { }) }) } +function pigPetLogin() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam":"{}", + } + $.post(taskUrl('pigPetLogin', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + $.hasPig = data.resultData.resultData.hasPig; + if (!$.hasPig) { + console.log(`\n京东账号${$.index} ${$.nickName} 未开启养猪活动,请手动去京东金融APP开启此活动\n`) + } + } else { + console.log(`Login其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} //开宝箱 function pigPetOpenBox() { return new Promise(async resolve => { @@ -199,7 +305,7 @@ function pigPetLotteryIndex() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(data) + // console.log(data) data = JSON.parse(data); if (data.resultCode === 0) { if (data.resultData.resultCode === 0) { @@ -223,6 +329,46 @@ function pigPetLotteryIndex() { }) }) } +//查询签到情况 +function pigPetSignIndex() { + $.sign = true; + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam": "{}" + } + $.post(taskUrl('pigPetSignIndex', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + $.sign = data.resultData.resultData.sign; + $.no = data.resultData.resultData.today; + } + } else { + console.log(`查询签到情况异常:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} //抽奖 function pigPetLotteryPlay() { return new Promise(async resolve => { @@ -240,13 +386,13 @@ function pigPetLotteryPlay() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(data) + // console.log(data) data = JSON.parse(data); if (data.resultCode === 0) { if (data.resultData.resultCode === 0) { if (data.resultData.resultData) { // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); - $.currentCount = data.resultData.resultData.currentCount; + $.currentCount = data.resultData.resultData.currentCount;//抽奖后剩余的抽奖次数 } } else { console.log(`其他情况:${JSON.stringify(data)}`) @@ -264,6 +410,202 @@ function pigPetLotteryPlay() { }) }) } +async function missions() { + for (let item of $.missions) { + if (item.status === 4) { + console.log(`\n${item.missionName}任务已做完,开始领取奖励`) + await pigPetDoMission(item.mid); + } else if (item.status === 5){ + console.log(`\n${item.missionName}已领取`) + } else if (item.status === 3){ + console.log(`\n${item.missionName}未完成`) + if (item.mid === 'CPD01') { + await pigPetDoMission(item.mid); + } else { + //TODO + // await pigPetDoMission(item.mid); + // await queryMissionReceiveAfterStatus(item.mid); + // await finishReadMission(item.mid); + } + } + } +} +//领取做完任务的奖品 +function pigPetDoMission(mid) { + return new Promise(async resolve => { + const body = { + "source":0, + "channelLV":"", + "riskDeviceParam":"{}", + mid + } + $.post(taskUrl('pigPetDoMission', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('pigPetDoMission',data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + if (data.resultData.resultData.award) { + console.log(`奖励${data.resultData.resultData.award.name},数量:${data.resultData.resultData.award.count}`) + } + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询任务列表 +function pigPetMissionList() { + return new Promise(async resolve => { + const body = { + "source":0, + "channelLV":"", + "riskDeviceParam":"{}", + } + $.post(taskUrl('pigPetMissionList', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + $.missions = data.resultData.resultData.missions;//抽奖后剩余的抽奖次数 + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function queryMissionReceiveAfterStatus(missionId) { + return new Promise(resolve => { + const body = {"missionId": missionId.toString()}; + const options = { + "url": `${MISSION_BASE_API}/queryMissionReceiveAfterStatus?reqData=%7B%2522missionId%2522:%2522${Number(missionId)}%2522%7D`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9", + "Connection": "keep-alive", + "Host": "ms.jr.jd.com", + "Cookie": cookie, + "Origin": "https://jdjoy.jd.com", + "Referer": "https://jdjoy.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('queryMissionReceiveAfterStatus',data) + // data = JSON.parse(data); + // if (data.resultCode === 0) { + // if (data.resultData.resultCode === 0) { + // if (data.resultData.resultData) { + // // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + // $.currentCount = data.resultData.resultData.currentCount;//抽奖后剩余的抽奖次数 + // } + // } else { + // console.log(`其他情况:${JSON.stringify(data)}`) + // } + // } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//做完浏览任务发送信息API +function finishReadMission(missionId) { + return new Promise(async resolve => { + const body = {"missionId": missionId.toString(),"readTime":10}; + const options = { + "url": `${MISSION_BASE_API}/finishReadMission?reqData=%7B%2522missionId%2522:%2522${Number(missionId)}%2522,%2522readTime%2522:10%7D`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9", + "Connection": "keep-alive", + "Host": "ms.jr.jd.com", + "Cookie": cookie, + "Origin": "https://jdjoy.jd.com", + "Referer": "https://jdjoy.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('finishReadMission',data) + // data = JSON.parse(data); + // if (data.resultCode === 0) { + // if (data.resultData.resultCode === 0) { + // if (data.resultData.resultData) { + // // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + // $.currentCount = data.resultData.resultData.currentCount;//抽奖后剩余的抽奖次数 + // } + // } else { + // console.log(`其他情况:${JSON.stringify(data)}`) + // } + // } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} function TotalBean() { return new Promise(async resolve => { const options = { @@ -276,7 +618,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -309,15 +651,16 @@ function taskUrl(function_id, body) { url: `${JD_API_HOST}/${function_id}?_=${Date.now()}`, body: `reqData=${encodeURIComponent(JSON.stringify(body))}`, headers: { - 'Accept' : `application/json`, - 'Origin' : `https://uua.jr.jd.com`, + 'Accept' : `*/*`, + 'Origin' : `https://u.jr.jd.com`, 'Accept-Encoding' : `gzip, deflate, br`, 'Cookie' : cookie, 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`, 'Host' : `ms.jr.jd.com`, 'Connection' : `keep-alive`, - 'User-Agent' : `jdapp;iPhone;9.0.0;13.4.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/F75E8AED-CB48-4EAC-A213-E8CE4018F214;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167237;supportBestPay/0;jdSupportDarkMode/0;pv/1287.19;apprpd/MyJD_GameMain;ref/https%3A%2F%2Fuua.jr.jd.com%2Fuc-fe-wxgrowing%2Fmoneytree%2Findex%2F%3Fchannel%3Dyxhd%26lng%3D113.325843%26lat%3D23.204628%26sid%3D2d98e88cf7d182f60d533476c2ce777w%26un_area%3D19_1601_50258_51885;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|3485;jdv/0|kong|t_1000170135|tuiguang|notset|1593059927172|1593059927;adk/;app_device/IOS;pap/JA2015_311210|9.0.0|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Referer' : `https://uua.jr.jd.com`, + // 'User-Agent' : `jdapp;iPhone;9.0.0;13.4.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/4g;ADID/F75E8AED-CB48-4EAC-A213-E8CE4018F214;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/167237;supportBestPay/0;jdSupportDarkMode/0;pv/1287.19;apprpd/MyJD_GameMain;ref/https%3A%2F%2Fuua.jr.jd.com%2Fuc-fe-wxgrowing%2Fmoneytree%2Findex%2F%3Fchannel%3Dyxhd%26lng%3D113.325843%26lat%3D23.204628%26sid%3D2d98e88cf7d182f60d533476c2ce777w%26un_area%3D19_1601_50258_51885;psq/1;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|3485;jdv/0|kong|t_1000170135|tuiguang|notset|1593059927172|1593059927;adk/;app_device/IOS;pap/JA2015_311210|9.0.0|IOS 13.4.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'User-Agent' : `jdapp;android;8.5.12;9;network/wifi;model/GM1910;addressid/1302541636;aid/ac31e03386ddbec6;oaid/;osVer/28;appBuild/73078;adk/;ads/;pap/JA2015_311210|8.5.12|ANDROID 9;osv/9;pv/117.24;jdv/0|kong|t_1000217905_|jingfen|644e9b005c8542c1ac273da7763971d8|1589905791552|1589905794;ref/com.jingdong.app.mall.WebActivity;partner/oppo;apprpd/Home_Main;Mozilla/5.0 (Linux; Android 9; GM1910 Build/PKQ1.190110.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 Edg/86.0.4240.111`, + 'Referer' : `https://u.jr.jd.com/`, 'Accept-Language' : `zh-cn` } } diff --git a/jd_plantBean.js b/jd_plantBean.js index 917bbb2..1640b5f 100644 --- a/jd_plantBean.js +++ b/jd_plantBean.js @@ -36,13 +36,13 @@ let shareCodes = [ // IOS本地脚本用户这个列表填入你要助力的好 //账号一的好友shareCode,不同好友的shareCode中间用@符号隔开 '66j4yt3ebl5ierjljoszp7e4izzbzaqhi5k2unz2afwlyqsgnasq@olmijoxgmjutyrsovl2xalt2tbtfmg6sqldcb3q@e7lhibzb3zek27amgsvywffxx7hxgtzstrk2lba@e7lhibzb3zek32e72n4xesxmgc2m76eju62zk3y', //账号二的好友shareCode,不同好友的shareCode中间用@符号隔开 - '4npkonnsy7xi3p6pjfxg6ct5gll42gmvnz7zgoy@6dygkptofggtp6ffhbowku3xgu@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy', + 'olmijoxgmjutyx55upqaqxrblt7f3h26dgj2riy@4npkonnsy7xi3p6pjfxg6ct5gll42gmvnz7zgoy@6dygkptofggtp6ffhbowku3xgu@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy', ] let currentRoundId = null;//本期活动id let lastRoundId = null;//上期id let roundList = []; let awardState = '';//上期活动的京豆是否收取 -let randomCount = 20; +let randomCount = $.isNode() ? 20 : 5; !(async () => { await requireConfig(); if (!cookiesArr[0]) { @@ -96,7 +96,7 @@ async function jdPlantBean() { awardState = roundList[0].awardState; $.taskList = $.plantBeanIndexResult.data.taskList; subTitle = `【京东昵称】${$.plantBeanIndexResult.data.plantUserInfo.plantNickName}`; - message += `【上期时间】${roundList[0].dateDesc}\n`; + message += `【上期时间】${roundList[0].dateDesc.replace('上期 ', '')}\n`; message += `【上期成长值】${roundList[0].growth}\n`; await receiveNutrients();//定时领取营养液 await doHelp();//助力 @@ -501,7 +501,7 @@ async function plantBeanIndex() { $.plantBeanIndexResult = await request('plantBeanIndex');//plantBeanIndexBody } function readShareCode() { - return new Promise(resolve => { + return new Promise(async resolve => { $.get({url: `http://api.turinglabs.net/api/v1/jd/bean/read/${randomCount}/`}, (err, resp, data) => { try { if (err) { @@ -519,6 +519,8 @@ function readShareCode() { resolve(data); } }) + await $.wait(15000); + resolve() }) } //格式化助力码 @@ -651,7 +653,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -711,7 +713,7 @@ function taskUrl(function_id, body) { 'Host': 'api.m.jd.com', 'Accept': '*/*', 'Connection': 'keep-alive', - 'User-Agent': 'JD4iPhone/167249 (iPhone;iOS 13.6.1;Scale/3.00)', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', 'Accept-Encoding': 'gzip, deflate, br', 'Content-Type': "application/x-www-form-urlencoded" diff --git a/jd_rankingList.js b/jd_rankingList.js index 71bf00c..24f2ce8 100644 --- a/jd_rankingList.js +++ b/jd_rankingList.js @@ -48,7 +48,7 @@ function updateShareCodes(url = 'https://raw.githubusercontent.com/yangtingxiao/ }) }) } -function scriptsCDN(url = 'https://cdn.jsdelivr.net/gh/yangtingxiao/QuantumultX@master/scripts/jd/jd_rankingList.js') { +function scriptsCDN(url = 'https://raw.fastgit.org/yangtingxiao/QuantumultX/master/scripts/jd/jd_rankingList.js') { return new Promise(resolve => { $.get({url}, async (err, resp, data) => { try { diff --git a/jd_redPacket.js b/jd_redPacket.js index 07c8348..c72f8b9 100644 --- a/jd_redPacket.js +++ b/jd_redPacket.js @@ -2,7 +2,7 @@ * @Author: lxk0301 * @Date: 2020-11-03 18:12:38 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-10-30 20:37:24 + * @Last Modified time: 2020-11-23 12:27:18 */ /* 京东全民开红包(京东app->主页->领券->抢红包(在底部)) @@ -268,7 +268,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -309,7 +309,7 @@ function taskUrl(function_id, body) { "Cookie": cookie, "Connection": "keep-alive", "Accept": "*/*", - "User-Agent": "jdapp;iPhone;9.0.2;13.5.1;e35caf0a69be42084e3c97eef56c3af7b0262d01;network/wifi;ADID/3B3AD5BC-B5E6-4A08-B32A-030CD805B5DD;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;model/iPhone11,8;addressid/;hasOCPay/0;appBuild/167249;supportBestPay/0;jdSupportDarkMode/0;pv/2.76;apprpd/CouponCenter;ref/NewCouponCenterViewController;psq/0;ads/;psn/e35caf0a69be42084e3c97eef56c3af7b0262d01|28;jdv/0|;adk/;app_device/IOS;pap/JA2015_311210|9.0.2|IOS 13.5.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Referer": "https://happy.m.jd.com/babelDiy/zjyw/3ugedFa7yA6NhxLN5gw2L3PF9sQC/index.html", "Content-Length": "36", "Accept-Language": "zh-cn" diff --git a/jd_shop.js b/jd_shop.js index b145fae..fe62485 100644 --- a/jd_shop.js +++ b/jd_shop.js @@ -109,7 +109,7 @@ function doTask(taskId) { url: `${JD_API_HOST}`, body: `functionId=takeTask&body=${escape(JSON.stringify(body))}&appid=ld`, headers: { - 'User-Agent': 'JD4iPhone/167169 (iPhone; iOS 13.4.1; Scale/3.00)', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Host': 'api.m.jd.com', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie, @@ -138,7 +138,7 @@ function getTask(body = {}) { url: `${JD_API_HOST}`, body: `functionId=queryTaskIndex&body=${escape(JSON.stringify(body))}&appid=ld`, headers: { - 'User-Agent': 'JD4iPhone/167169 (iPhone; iOS 13.4.1; Scale/3.00)', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Host': 'api.m.jd.com', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie, @@ -173,7 +173,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_small_home.js b/jd_small_home.js new file mode 100644 index 0000000..1484fb8 --- /dev/null +++ b/jd_small_home.js @@ -0,0 +1,798 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-12 11:42:12 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-11-23 12:27:20 + */ +/* +东东小窝 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js +现有功能: +做日常任务任务,每日抽奖(有机会活动京豆,使用的是免费机会,不消耗WO币) +助力好友:一个账号一天只能助力一次(即:每个人助力机会只有一次) +后期有空优化相互助力功能 +TODO;装扮领京豆(使用WO币购买装饰品可以获得京豆,分别可获得5,20,50,100,200,400,700,1200京豆) + +注:目前使用此脚本会给脚本内置的两个码进行助力,请知晓 + +APP活动入口: +京东APP首页 ->搜索 玩一玩 -> DIY理想家 +或 京东APP -> 我的-> 游戏与更多 - > 东东小窝 +微信小程序入口: +来客有礼 - > 首页 -> 东东小窝 +网页入口(注:进入后不能再此刷新,否则会有问题,需重新输入此链接进入) +https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html + +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +===============Quantumultx=============== +[task_local] +#东东小窝 +16 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, tag=东东小窝, img-url=https://raw.githubusercontent.com/58xinian/icon/master/ddxw.png enabled=true + +================Loon============== +[Script] +cron "16 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, tag=东东小窝 + +===============Surge================= +东东小窝 = type=cron,cronexp="16 0 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js + +============小火箭========= +东东小窝 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, cronexpr="16 0 * * *", timeout=200, enable=true + */ +const $ = new Env('东东小窝'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message = ''; +let isPurchaseShops = false;//是否一键加购商品到购物车,默认不加购 +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} + +const JD_API_HOST = 'https://lkyl.dianpusoft.cn/api'; + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await smallHome(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function smallHome() { + await loginHome(); + await ssjjRooms(); + await helpFriends(); + if (!$.isUnLock) return; + await createInviteUser(); + await queryDraw(); + await lottery(); + await doAllTask(); + await queryByUserId(); + await showMsg(); +} +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +async function lottery() { + if ($.freeDrawCount > 0) { + await drawRecord($.lotteryId); + } else { + console.log(`免费抽奖机会今日已使用\n`) + } +} +//获取详情 +function queryByUserId() { + return new Promise(resolve => { + $.get(taskUrl(`ssjj-wo-home-info/queryByUserId/2`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + message += `【小窝名】${data.body.name}\n`; + message += `【当前WO币】${data.body.woB}\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +async function doChannelsListTask(taskId, taskType) { + await queryChannelsList(taskId); + for (let item of $.queryChannelsList) { + if (item.showOrder === 1) { + await $.wait(1000) + await followChannel(taskId, item.id) + await queryDoneTaskRecord(taskId, taskType); + } + } +} +async function helpFriends() { + await updateInviteCode(); + if (!$.inviteCodes) await updateInviteCodeCDN(); + for (let item of $.inviteCodes.inviteCode) { + if (!item) continue + await createAssistUser(item, $.createAssistUserID || "1318106976846299138"); + } +} +async function doAllTask() { + await queryAllTaskInfo();//获取任务详情列表$.taskList + console.log(` 任务名称 完成进度 `) + for (let item of $.taskList) { + console.log(`${item.ssjjTaskInfo.name} ${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum || (item.ssjjTaskInfo.type === 1 ? 4: 1)}`) + } + for (let item of $.taskList) { + if (item.ssjjTaskInfo.type === 1) { + //邀请好友助力自己 + // await createAssistUser('1330186694770339842', item.ssjjTaskInfo.id) + $.createAssistUserID = item.ssjjTaskInfo.id; + console.log(`\n\n助力您的好友:${item.doneNum}人`) + } + if (item.ssjjTaskInfo.type === 2) { + //每日打卡 + if (item.doneNum === (item.ssjjTaskInfo.awardOfDayNum || 1)) { + console.log(`${item.ssjjTaskInfo.name}已完成(${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum || 1})`) + continue + } + await clock(item.ssjjTaskInfo.id, item.ssjjTaskInfo.awardWoB) + } + // 限时连连看 + if (item.ssjjTaskInfo.type === 3) { + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { + await game(item.ssjjTaskInfo.id, item.doneNum); + } + } + if (item.ssjjTaskInfo.type === 4) { + //关注店铺 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { + await followShops('followShops', item.ssjjTaskInfo.id);//一键关注店铺 + await queryDoneTaskRecord(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type); + } + } + if (item.ssjjTaskInfo.type === 5) { + //浏览店铺 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { + await browseChannels('browseShops', item.ssjjTaskInfo.id, item.browseId); + } + } + if (item.ssjjTaskInfo.type === 6) { + //关注4个频道 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + await doChannelsListTask(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type) + } + if (item.ssjjTaskInfo.type === 7) { + //浏览3个频道 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { + await browseChannels('browseChannels', item.ssjjTaskInfo.id, item.browseId); + } + } + isPurchaseShops = $.isNode() ? (process.env.PURCHASE_SHOPS ? process.env.PURCHASE_SHOPS : isPurchaseShops) : ($.getdata("isPurchaseShops") ? $.getdata("isPurchaseShops") : isPurchaseShops); + if (isPurchaseShops && item.ssjjTaskInfo.type === 9) { + //加购商品 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { + await followShops('purchaseCommodities', item.ssjjTaskInfo.id);//一键加购商品 + await queryDoneTaskRecord(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type); + } + } + if (item.ssjjTaskInfo.type === 10) { + //浏览商品 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { + await browseChannels('browseCommodities', item.ssjjTaskInfo.id, item.browseId); + } + } + if (item.ssjjTaskInfo.type === 11) { + //浏览会场 + if (item.doneNum === item.ssjjTaskInfo.awardOfDayNum) { + console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) + continue + } + for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { + await browseChannels('browseMeetings' ,item.ssjjTaskInfo.id, item.browseId); + } + // await browseChannels('browseMeetings' ,item.ssjjTaskInfo.id, item.browseId); + // await doAllTask(); + } + } +} +//获取需要关注的频道列表 +function queryChannelsList(taskId) { + return new Promise(resolve => { + $.get(taskUrl(`ssjj-task-channels/queryChannelsList/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + $.queryChannelsList = data.body; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//浏览频道,浏览会场,浏览商品,浏览店铺API +function browseChannels(functionID ,taskId, browseId) { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/${functionID}/${taskId}/${browseId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + console.log(`${functionID === 'browseChannels' ? '浏览频道' : functionID === 'browseMeetings' ? '浏览会场' : functionID === 'browseShops' ? '浏览店铺' : '浏览商品'}`, data) + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//记录已关注的频道 +function queryDoneTaskRecord(taskId, taskType) { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/queryDoneTaskRecord/${taskType}/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//一键关注店铺,一键加购商品API +function followShops(functionID, taskId) { + return new Promise(async resolve => { + $.get(taskUrl(`/ssjj-task-record/${functionID}/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + console.log(`${functionID === 'followShops'? '一键关注店铺': '一键加购商品'}结果:${data.head.msg}`); + // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//关注频道API +function followChannel(taskId, channelId) { + return new Promise(async resolve => { + $.get(taskUrl(`/ssjj-task-record/followChannel/${channelId}/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function createInviteUser() { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/createInviteUser`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + if (data.body.id) { + console.log(`\n您的${$.name}shareCode(每天都是变化的):【${data.body.id}】\n`); + $.shareCode = data.body.id; + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function createAssistUser(inviteId, taskId) { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/createAssistUser/${inviteId}/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + console.log(`\n给好友${data.body.inviteId}:【${data.head.msg}】\n`) + } + } else { + console.log(`助力失败${JSON.stringify(data)}}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function game(taskId, index, awardWoB = 100) { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/game/${index}/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + message += `【限时连连看】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function clock(taskId, awardWoB) { + return new Promise(resolve => { + $.get(taskUrl(`/ssjj-task-record/clock/${taskId}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + message += `【每日打卡】成功,活动${awardWoB}WO币\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function queryAllTaskInfo() { + return new Promise(resolve => { + $.get(taskUrl(`ssjj-task-info/queryAllTaskInfo/2`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + $.taskList = data.body; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//免费抽奖 +function drawRecord(id) { + return new Promise(resolve => { + $.get(taskUrl(`ssjj-draw-record/draw/${id}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + if (data.body) { + message += `【免费抽奖】获得:${data.body.name}\n`; + } else { + message += `【免费抽奖】未中奖\n`; + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//查询免费抽奖机会 +function queryDraw() { + return new Promise(resolve => { + $.get(taskUrl("ssjj-draw-center/queryDraw"), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + $.freeDrawCount = data.body.freeDrawCount;//免费抽奖次数 + $.lotteryId = data.body.center.id; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//查询是否开启了此活动 +function ssjjRooms() { + return new Promise(resolve => { + $.get(taskUrl("ssjj-rooms/info/%E5%AE%A2%E5%8E%85"), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.head.code === 200) { + $.isUnLock = data.body.isUnLock; + if (!$.isUnLock) { + console.log(`京东账号${$.index}${$.nickName}未开启此活动\n`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}未开启此活动\n点击弹窗去开启此活动( ̄▽ ̄)"`, {"open-url": "openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html%22%20%7D"}); + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function loginHome() { + return new Promise(resolve => { + const options = { + "url": "https://jdhome.m.jd.com/saas/framework/encrypt/pin?appId=6d28460967bda11b78e077b66751d2b0", + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Length": "0", + "Content-Type": "application/json", + "Cookie": cookie, + "Host": "jdhome.m.jd.com", + "Origin": "https://jdhome.m.jd.com", + "Referer": "https://jdhome.m.jd.com/dist/taro/index.html/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + await login(data.data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +function login(userName) { + return new Promise(resolve => { + const body = { + "body": { + "client": 2, + userName + } + }; + const options = { + "url": `${JD_API_HOST}/user-info/login`, + "body": JSON.stringify(body), + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json", + "Host": "lkyl.dianpusoft.cn", + "Origin": "https://lkyl.dianpusoft.cn", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.head.code === 200) { + $.token = data.head.token; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function updateInviteCode(url = 'https://raw.githubusercontent.com/lxk0301/updateTeam/master/jd_updateSmallHomeInviteCode.json') { + return new Promise(resolve => { + $.get({url}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + } else { + $.inviteCodes = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function updateInviteCodeCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam/master/jd_updateSmallHomeInviteCode.json') { + return new Promise(resolve => { + $.get({url}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.inviteCodes = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(url, body = {}) { + return { + url: `${JD_API_HOST}/${url}?body=${escape(body)}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9", + "Connection": "keep-alive", + "content-type": "application/json", + "Host": "lkyl.dianpusoft.cn", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html", + "token": $.token, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_speed.js b/jd_speed.js index 322a9ca..176230f 100644 --- a/jd_speed.js +++ b/jd_speed.js @@ -96,7 +96,7 @@ function jDSpeedUp(sourceId, doubleKey) { 'Host': 'api.m.jd.com', 'Accept': '*/*', 'Connection': 'keep-alive', - 'User-Agent': 'jdapp;iPhone;8.5.5;13.4;9b812b59e055cd226fd60ebb5fd0981c4d0d235d;network/wifi;supportApplePay/3;hasUPPay/0;pushNoticeIsOpen/0;model/iPhone9,2;addressid/138109592;hasOCPay/0;appBuild/167121;supportBestPay/0;jdSupportDarkMode/0;pv/104.43;apprpd/MyJD_GameMain;ref/MyJdGameEnterPageController;psq/9;ads/;psn/9b812b59e055cd226fd60ebb5fd0981c4d0d235d|272;jdv/0|direct|-|none|-|1583449735697|1583796810;adk/;app_device/IOS;pap/JA2015_311210|8.5.5|IOS 13.4;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Accept-Language': 'zh-cn', 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html?lng=116.845095&lat=39.957701&sid=ea687233c5e7d226b30940ed7382c5cw&un_area=5_274_49707_49973', 'Accept-Encoding': 'gzip, deflate, br' @@ -485,7 +485,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_split.js b/jd_split.js new file mode 100644 index 0000000..9ff7f6b --- /dev/null +++ b/jd_split.js @@ -0,0 +1,298 @@ +/* +金榜年终奖 +活动时间:2020-12-12日结束 +活动入口:京东APP首页右边浮动飘窗 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#金榜年终奖 +10 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_split.js, tag=年终奖, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_split.js,tag=年终奖 + +===============Surge================= +金榜年终奖 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_split.js + +============小火箭========= +金榜年终奖 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_split.js, cronexpr="10 0 * * *", timeout=200, enable=true + */ +const $ = new Env('金榜年终奖'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +$.newShareCodes = [`P04z54XCjVUnIaW5nJcXCCyoR8C6p8txXBH`, 'P04z54XCjVUnIaW5m9cZ2T6jChKki0Hfndla5k', 'P04z54XCjVUnIaW5u2ak7ZCdan1BT0NlbBGZ1-rnMYj', 'P04z54XCjVUnIaW5m9cZ2ariXVJwI64DaVTNXQ']; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await jdSplit() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdSplit() { + await helpFriends(); + await jdsplit_getTaskDetail(); + await doTask(); + await showMsg(); +} +function showMsg() { + return new Promise(resolve => { + message += `任务已做完:具体奖品去发活动页面查看\n活动入口:京东APP首页右边浮动飘窗`; + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + const helpRes = await jdsplit_collectScore(code,6,null); + if (helpRes.code === 0 && helpRes.data.bizCode === -7) { + console.log(`助力机会已耗尽,跳出`); + break + } + } +} +async function doTask() { + for (let item of $.taskVos) { + if (item.taskType === 8) { + //看看商品任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.productInfoVos) { + if (task.status === 1) { + await jdsplit_collectScore(task.taskToken,item.taskId,task.itemId,1); + await $.wait(4000) + await jdsplit_collectScore(task.taskToken,item.taskId,task.itemId,0); + } + } + await jdsplit_getLottery(item.taskId) + } else if(item.status!==4){ + await jdsplit_getLottery(item.taskId) + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 9) { + //逛会场任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.shoppingActivityVos) { + if (task.status === 1) { + await jdsplit_collectScore(task.taskToken,item.taskId,task.itemId,1); + await $.wait(4000) + await jdsplit_collectScore(task.taskToken,item.taskId,task.itemId,0); + } + } + await jdsplit_getLottery(item.taskId) + } else if(item.status!==4){ + await jdsplit_getLottery(item.taskId) + console.log(`${item.taskName}已做完`) + } + } + } +} + +//领取做完任务的奖励 +function jdsplit_collectScore(taskToken, taskId, itemId, actionType=0) { + return new Promise(resolve => { + let body = { "appId":"1EFRTwA","taskToken":taskToken,"taskId":taskId,"itemId":itemId,"actionType":actionType } + $.post(taskPostUrl("harmony_collectScore", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.data.bizCode === 1){ + console.log(`任务领取成功`); + } + else if (data.data.bizCode === 0) { + if(data.data.result.taskType===6){ + console.log(`助力好友:${data.data.result.itemId}成功!`) + }else + console.log(`任务完成成功`); + } else { + console.log(`${data.data.bizMsg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 抽奖 +function jdsplit_getLottery(taskId) { + return new Promise(resolve => { + let body = { "appId":"1EFRTwA","taskId":taskId} + $.post(taskPostUrl("splitHongbao_getLotteryResult", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`红包领取结果:${data.data.result.userAwardsCacheDto.redPacketVO.name}`); + } else { + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function jdsplit_getTaskDetail() { + return new Promise(resolve => { + $.post(taskPostUrl("splitHongbao_getHomeData", {"appId":"1EFRTwA","taskToken":""}, ), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + $.taskVos.map(item => { + if (item.taskType === 6) { + console.log(`\n您的${$.name}好友助力邀请码:${item.assistTaskDetailVo.taskToken}\n`) + } + }) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskPostUrl(function_id, body = {}, function_id2) { + let url = `${JD_API_HOST}`; + if (function_id2) { + url += `?functionId=${function_id2}`; + } + return { + url, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.1.0`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_superMarket.js b/jd_superMarket.js index cbdb85e..d72916e 100644 --- a/jd_superMarket.js +++ b/jd_superMarket.js @@ -2,26 +2,25 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-08-16 18:54:16 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-11-11 18:54:37 + * @Last Modified time: 2020-11-24 08:22:37 */ /* -京小超(活动入口:京东APP-》首页-》京东超市-》底部东东超市) -现有功能:每日签到,日常任务(分享游戏,逛会场,关注店铺,卖货能手),收取金币,收取蓝币,商圈活动 +东东超市(活动入口:京东APP-》首页-》京东超市-》底部东东超市) Some Functions Modified From https://github.com/Zero-S1/JD_tools/blob/master/JD_superMarket.py 支持京东双账号 京小超兑换奖品请使用此脚本 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js // QuantumultX [task_local] -#京小超 -11 1-23/5 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js, tag=京小超, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true +#东东超市 +11 1-23/5 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js, tag=东东超市, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true // Loon [Script] -cron "11 1-23/5 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js,tag=京小超 +cron "11 1-23/5 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js,tag=东东超市 // Surge -京小超 = type=cron,cronexp="11 1-23/5 * * *",wake-system=1,timeout=320,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js +东东超市 = type=cron,cronexp="11 1-23/5 * * *",wake-system=1,timeout=320,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js */ -const $ = new Env('京小超'); +const $ = new Env('东东超市'); //Node.js用户请在jdCookie.js处填写京东ck; //IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = '', jdSuperMarketShareArr = [], notify, newShareCodes; @@ -113,8 +112,8 @@ function showMsg() { async function drawLottery() { console.log(`\n注意⚠:京小超抽奖已改版,花费500蓝币抽奖一次,现在脚本默认已关闭抽奖功能\n`); drawLotteryFlag = $.getdata('jdSuperMarketLottery') ? $.getdata('jdSuperMarketLottery') : drawLotteryFlag; - if ($.isNode() && process.env.jdSuperMarketLottery) { - drawLotteryFlag = process.env.jdSuperMarketLottery; + if ($.isNode() && process.env.SUPERMARKET_LOTTERY) { + drawLotteryFlag = process.env.SUPERMARKET_LOTTERY; } if (`${drawLotteryFlag}` === 'true') { const smtg_lotteryIndexRes = await smtg_lotteryIndex(); @@ -311,18 +310,14 @@ async function businessCircleActivity() { const smtg_getTeamPkDetailInfoRes = await smtg_getTeamPkDetailInfo(); if (smtg_getTeamPkDetailInfoRes && smtg_getTeamPkDetailInfoRes.data.bizCode === 0) { const { joinStatus, pkStatus, inviteCount, inviteCode, currentUserPkInfo, pkUserPkInfo, prizeInfo, pkActivityId, teamId } = smtg_getTeamPkDetailInfoRes.data.result; - console.log(`joinStatus:${joinStatus}`); - console.log(`pkStatus:${pkStatus}`); - console.log(`inviteCode: [${inviteCode}]`); - console.log(`PK队伍teamId: [${teamId}]`); - console.log(`PK队伍名称: [${currentUserPkInfo && currentUserPkInfo.teamName}]`); - await updatePkActivityId(); - if (!$.updatePkActivityIdRes) await updatePkActivityIdCDN(); - console.log(`\nupdatePkActivityId[pkActivityId]:::${$.updatePkActivityIdRes.pkActivityId}`); - console.log(`\n京东服务器返回的[pkActivityId] ${pkActivityId}`); + console.log(`\njoinStatus:${joinStatus}`); + console.log(`pkStatus:${pkStatus}\n`); if (joinStatus === 0) { + console.log(`\n注:PK会在每天的七点自动随机加入lxk0301创建的队伍\n`) await updatePkActivityId(); if (!$.updatePkActivityIdRes) await updatePkActivityIdCDN(); + console.log(`\nupdatePkActivityId[pkActivityId]:::${$.updatePkActivityIdRes.pkActivityId}`); + console.log(`\n京东服务器返回的[pkActivityId] ${pkActivityId}`); if ($.updatePkActivityIdRes && ($.updatePkActivityIdRes.pkActivityId === pkActivityId)) { let Teams = [ { @@ -365,12 +360,17 @@ async function businessCircleActivity() { console.log('\nupdatePkActivityId请求返回的pkActivityId与京东服务器返回不一致,暂时不加入战队') } } else if (joinStatus === 1) { - console.log(`我邀请的人数:${inviteCount}\n`) - console.log(`\n我方战队战队 [${currentUserPkInfo.teamName}]/【${currentUserPkInfo.teamCount}】`); - console.log(`对方战队战队 [${pkUserPkInfo.teamName}]/【${pkUserPkInfo.teamCount}】\n`); + if (teamId) { + console.log(`inviteCode: [${inviteCode}]`); + console.log(`PK队伍teamId: [${teamId}]`); + console.log(`PK队伍名称: [${currentUserPkInfo && currentUserPkInfo.teamName}]`); + console.log(`我邀请的人数:${inviteCount}\n`) + console.log(`\n我方战队战队 [${currentUserPkInfo && currentUserPkInfo.teamName}]/【${currentUserPkInfo && currentUserPkInfo.teamCount}】`); + console.log(`对方战队战队 [${pkUserPkInfo && pkUserPkInfo.teamName}]/【${pkUserPkInfo && pkUserPkInfo.teamCount}】\n`); + } } if (pkStatus === 1) { - console.log(`商圈PK进行中`) + console.log(`商圈PK进行中\n`) } else if (pkStatus === 2) { console.log(`商圈PK结束了`) if (prizeInfo.pkPrizeStatus === 2) { @@ -391,11 +391,13 @@ async function businessCircleActivity() { } } } else if (prizeInfo.pkPrizeStatus === 1) { - console.log(`商圈PK奖励已经领取`) + console.log(`商圈PK奖励已经领取\n`) } } else if (pkStatus === 3) { - console.log(`商圈PK暂停中`) + console.log(`商圈PK暂停中\n`) } + } else { + console.log(`\n${JSON.stringify(smtg_getTeamPkDetailInfoRes)}\n`) } return const businessCirclePKDetailRes = await smtg_businessCirclePKDetail(); @@ -547,8 +549,8 @@ async function unlockProductByCategory(category) { //升级货架和商品 async function upgrade() { superMarketUpgrade = $.getdata('jdSuperMarketUpgrade') ? $.getdata('jdSuperMarketUpgrade') : superMarketUpgrade; - if ($.isNode() && process.env.jdSuperMarketUpgrade) { - superMarketUpgrade = process.env.jdSuperMarketUpgrade; + if ($.isNode() && process.env.SUPERMARKET_UPGRADE) { + superMarketUpgrade = process.env.SUPERMARKET_UPGRADE; } if (`${superMarketUpgrade}` === 'false') { console.log(`\n自动升级: 您设置的是关闭自动升级\n`); @@ -722,7 +724,7 @@ function updatePkActivityId(url = 'https://raw.githubusercontent.com/lxk0301/upd }) }) } -function updatePkActivityIdCDN(url = 'https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_updateTeam.json') { +function updatePkActivityIdCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam/master/jd_updateTeam.json') { return new Promise(resolve => { //https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_updateTeam.json //https://raw.githubusercontent.com/lxk0301/updateTeam/master/jd_updateTeam.json @@ -1390,7 +1392,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -1422,7 +1424,7 @@ function taskUrl(function_id, body = {}) { return { url: `${JD_API_HOST}?functionId=${function_id}&appid=jdsupermarket&clientVersion=8.0.0&client=m&body=${escape(JSON.stringify(body))}&t=${Date.now()}`, headers: { - 'User-Agent': 'jdapp;iPhone;9.0.8;13.6;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Host': 'api.m.jd.com', 'Cookie': cookie, 'Referer': 'https://jdsupermarket.jd.com/game', diff --git a/jd_syj.js b/jd_syj.js new file mode 100644 index 0000000..06720e0 --- /dev/null +++ b/jd_syj.js @@ -0,0 +1,202 @@ +/* + * @Author: lxk0301 https://github.com/lxk0301 + * @Date: 2020-11-27 09:19:21 + * @Last Modified by: lxk0301 + * @Last Modified time: 2020-11-27 09:58:02 + */ +/* +十元街脚本,一周签到下来可获得30京豆,一天任意时刻运行一次即可 +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js +参考github@jidesheng6修改而来 +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#十元街 +10 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, tag=十元街, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_syj.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, tag=十元街 + +===============Surge================= +十元街 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js + +============小火箭========= +十元街 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('十元街'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr.push(...[$.getdata('CookieJD'), $.getdata('CookieJD2')]); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + await userSignIn(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +let signFlag = 0; +function userSignIn() { + return new Promise(resolve => { + const body = {"activityId":"8d6845fe2e77425c82d5078d314d33c5","inviterId":"VMIQlLQqjQyjZokQmv5bIDgq011L0Ov8","channel":"MiniProgram"}; + $.get(taskUrl('userSignIn', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + signFlag = 0; + console.log(`${$.name}今日签到成功`); + if (data.data) { + let { alreadySignDays, beanTotalNum, todayPrize, eachDayPrize } = data.data; + message += `【第${alreadySignDays}日签到】成功,获得${todayPrize.beanAmount}京豆 🐶\n`; + if (alreadySignDays === 7) alreadySignDays = 0; + message += `【明日签到】可获得${eachDayPrize[alreadySignDays].beanAmount}京豆 🐶\n`; + message += `【累计获得】${beanTotalNum}京豆 🐶\n`; + } + } else if (data.code === 81) { + console.log(`今日已签到`) + message += `【签到】失败,今日已签到`; + } else if (data.code === 6) { + //此处有时会遇到 服务器繁忙 导致签到失败,故重复三次签到 + $.log(`${$.name}签到失败${signFlag}:${data.msg}`); + if (signFlag < 3) { + signFlag ++; + await userSignIn(); + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=swat_miniprogram&osVersion=5.0.0&clientVersion=3.1.3&fromType=wxapp×tamp=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://servicewechat.com/wxa5bf5ee667d91626/108/page-frame.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + } + } +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_unsubscribe.js b/jd_unsubscribe.js index 3809343..7e04f0a 100644 --- a/jd_unsubscribe.js +++ b/jd_unsubscribe.js @@ -1,6 +1,6 @@ /* 脚本:取关京东店铺和商品 -更新时间:2020-11-03 +更新时间:2020-11-22 因种豆得豆和宠汪汪以及NobyDa大佬的京东签到脚本会关注店铺和商品,故此脚本用来取消已关注的店铺和商品 默认每运行一次脚本取消关注10个商品,10个店铺。可结合boxjs自定义取消多少个(目前测试通过最大数量是一次性取消300个商品无异常,大于300请自行测试,建议尽量不要一次性全部取消以免出现问题)。 建议此脚本运行时间在 种豆得豆和宠汪汪脚本运行之后 再执行 @@ -61,8 +61,6 @@ const JD_API_HOST = 'https://wq.jd.com/fav'; } continue } - message = ''; - subTitle = ''; await requireConfig(); await jdUnsubscribe(); await showMsg(); @@ -104,7 +102,7 @@ function unsubscribeGoods() { console.log(`是否匹配::${item.commTitle.indexOf(stopGoods.replace(/\ufffc|\s*/g, ''))}`) - if (stopGoods && item.commTitle.indexOf(stopGoods.replace(/\ufffc|\s*/g, '')) === 0) { + if (stopGoods && item.commTitle.indexOf(stopGoods.replace(/\ufffc|\s*/g, '')) > -1) { console.log(`匹配到了您设定的商品--${stopGoods},不在进行取消关注商品`) break; } @@ -138,7 +136,7 @@ function getFollowGoods() { "Accept": "*/*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://wqs.jd.com/my/fav/goods_fav.shtml?ptag=37146.4.1&sceneval=2&jxsid=15963530166144677970", "Accept-Encoding": "gzip, deflate, br" @@ -165,7 +163,7 @@ function unsubscribeGoodsFun(commId) { "Host": "wq.jd.com", "Accept": "*/*", "Connection": "keep-alive", - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Referer': 'https://wqs.jd.com/my/fav/goods_fav.shtml?ptag=37146.4.1&sceneval=2&jxsid=15963530166144677970', 'Cookie': cookie, "Accept-Language": "zh-cn", @@ -229,7 +227,7 @@ function getFollowShops() { "Accept": "*/*", "Connection": "keep-alive", "Cookie": cookie, - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), "Accept-Language": "zh-cn", "Referer": "https://wqs.jd.com/my/fav/shop_fav.shtml?sceneval=2&jxsid=15963530166144677970&ptag=7155.1.9", "Accept-Encoding": "gzip, deflate, br" @@ -255,7 +253,7 @@ function unsubscribeShopsFun(shopId) { "Host": "wq.jd.com", "Accept": "*/*", "Connection": "keep-alive", - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), 'Referer': 'https://wqs.jd.com/my/fav/shop_fav.shtml?sceneval=2&jxsid=15960121319555534107&ptag=7155.1.9', 'Cookie': cookie, "Accept-Language": "zh-cn", @@ -285,7 +283,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { diff --git a/jd_xtg.js b/jd_xtg.js index ffc150f..4621585 100644 --- a/jd_xtg.js +++ b/jd_xtg.js @@ -278,7 +278,7 @@ function doSupport(shareId) { "Cookie": cookie, "Host": "urvsaggpt.m.jd.com", "Referer": "https://urvsaggpt.m.jd.com/static/index.html", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -310,7 +310,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -352,7 +352,7 @@ function getDayPrizeStatus(prizeType, prizeId, status) { "Cookie": cookie, "Host": "urvsaggpt.m.jd.com", "Referer": "https://urvsaggpt.m.jd.com/static/index.html", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } $.post(options, (err, resp, data) => { @@ -385,7 +385,7 @@ function taskPostUrl(type, id, status) { "Cookie": cookie, "Host": "urvsaggpt.m.jd.com", "Referer": "https://urvsaggpt.m.jd.com/static/index.html", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } } @@ -411,7 +411,7 @@ function taskUrl(function_id) { "Cookie": cookie, "Host": "urvsaggpt.m.jd.com", "Referer": "https://urvsaggpt.m.jd.com/static/index.html", - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1" + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") } } } diff --git a/lxk0301.boxjs.json b/lxk0301.boxjs.json index a1ae6c0..eb3edd6 100644 --- a/lxk0301.boxjs.json +++ b/lxk0301.boxjs.json @@ -9,6 +9,11 @@ "id": "JD_Cookies", "name": "京东多账号 Ck 管理", "keys": ["CookiesJD"], + "descs_html": [ + "请勿随意在输入框修改内容,建议通过脚本去获取cookie,若要修改,请按照JSON 格式修改。", + "脚本地址【京东多 CK获取】,并按照此脚本注释进行配置", + "使用方式【个人中心】获取对应的数据Code" + ], "settings": [ { "id": "CookiesJD", @@ -28,6 +33,28 @@ "repo": "https://github.com/dompling/Script", "script": "https://raw.githubusercontent.com/dompling/Script/master/jd/JD_extra.js" }, + { + "id": "JD_UA", + "name": "自定义京东脚本的UserAgent", + "keys": [ + "JDUA" + ], + "settings": [ + { + "id": "JDUA", + "name": "自定义京东脚本的UserAgent", + "val": "", + "type": "text", + "desc": "不懂不知不会UserAgent的请不要随意填写内容" + } + ], + "author": "@lxk0301", + "repo": "https://github.com/lxk0301/jd_scripts", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/jd.png", + "https://raw.githubusercontent.com/Orz-3/task/master/jd.png" + ] + }, { "id": "jd_fruit", "name": "东东农场", @@ -379,10 +406,31 @@ }, { "id": "joyRunFlag", - "name": "是否参加双人赛跑(默认参加)", + "name": "是否参加赛跑(默认参加)", "val": true, "type": "boolean", - "desc": "开启脚本将会为您自动参加双人赛跑" + "desc": "开启脚本将会为您自动参加赛跑(默认参加双人赛跑)" + }, + { + "id": "JOY_TEAM_LEVEL", + "name": "宠汪汪赛跑级别选择", + "val": "2", + "type": "radios", + "desc": "参加多少人的赛跑比赛,其中2代表参加双人PK赛,10代表参加10人突围赛,50代表参加50人挑战赛", + "items": [ + { + "key": "2", + "label": "双人PK赛" + }, + { + "key": "10", + "label": "10人突围赛" + }, + { + "key": "50", + "label": "50人挑战赛" + } + ] }, { "id": "joyFeedCount", @@ -540,13 +588,6 @@ "val": true, "type": "boolean", "desc": "运行京东摇钱树脚本时不发出系统弹窗通知" - }, - { - "id": "jdMoneyTreeNoticeTimes", - "name": "通知频率", - "val": 2, - "type": "number", - "desc": "脚本运行多少次后弹窗通知(默认2次,如果开启静默运行,此设置失效)" } ], "author": "@lxk0301", @@ -633,16 +674,7 @@ { "id": "jd_SuperMarket", "name": "京小超", - "keys": [ - "jd_supermarket_name", - "jd_supermarket1", - "jd_supermarket2", - "jd_supermarket3", - "j2_supermarket_name", - "jd2_supermarket1", - "jd2_supermarket2", - "jd2_supermarket3" - ], + "keys": [], "settings": [ { "id": "jdSuperMarketNotify", @@ -671,62 +703,6 @@ "val": false, "type": "boolean", "desc": "运行脚本消耗金币进行抽奖,默认抽奖" - }, - { - "id": "jd_supermarket_name", - "name": "京东账号一昵称", - "val": "", - "type": "text", - "desc": "京东账号昵称,用于区分自己的京东账号(非必填,建议多个京东账号使用)" - }, - { - "id": "jd_supermarket1", - "name": "京东账号一互助码1", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" - }, - { - "id": "jd_supermarket2", - "name": "京东账号一互助码2", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" - }, - { - "id": "jd_supermarket3", - "name": "京东账号一互助码3", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" - }, - { - "id": "jd2_supermarket_name", - "name": "京东账号二昵称", - "val": "", - "type": "text", - "desc": "京东账号昵称,用于区分自己的京东账号(非必填,建议多个京东账号使用)" - }, - { - "id": "jd2_supermarket1", - "name": "京东账号二互助码1", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" - }, - { - "id": "jd2_supermarket2", - "name": "京东账号二互助码2", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" - }, - { - "id": "jd2_supermarket3", - "name": "京东账号二互助码3", - "val": "", - "type": "text", - "desc": "京小超商圈互助码" } ], "author": "@lxk0301", @@ -863,6 +839,29 @@ "https://raw.githubusercontent.com/58xinian/icon/master/xmyd_mini.png", "https://raw.githubusercontent.com/58xinian/icon/master/xmyd.png" ] + }, + { + "id": "lxk_jdfactory", + "name": "东东工厂", + "keys": [ + "FACTORAY_WANTPRODUCT_NAME" + ], + "settings": [ + { + "id": "FACTORAY_WANTPRODUCT_NAME", + "name": "心仪商品名称", + "val": "", + "type": "text", + "desc": "请尽量填写完整和别的商品有区分度" + } + ], + "author": "@lxk0301", + "repo": "https://github.com/lxk0301/jd_scripts", + "script": "https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jd_factory_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png" + ] } ] } diff --git a/sendNotify.js b/sendNotify.js index 6a7d86c..99c30e1 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -81,7 +81,7 @@ async function sendNotify(text, desp, params = {}) { await iGotNotify(text, desp, params); } -function serverNotify(text, desp) { +function serverNotify(text, desp, timeout = 2100) { return new Promise(resolve => { if (SCKEY) { //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 @@ -93,25 +93,29 @@ function serverNotify(text, desp) { 'Content-Type': 'application/x-www-form-urlencoded' } } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log('\n发送通知调用API失败!!\n') - console.log(err); - } else { - data = JSON.parse(data); - if (data.errno === 0) { - console.log('\nserver酱发送通知消息成功\n') - } else if (data.errno === 1024) { - console.log('\nPUSH_KEY 错误\n') + setTimeout(() => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('\n发送通知调用API失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.errno === 0) { + console.log('\nserver酱发送通知消息成功\n') + } else if (data.errno === 1024) { + console.log('\nPUSH_KEY 错误\n') + } else { + console.log(`server酱发送通知消息异常\n${JSON.stringify(data)}`) + } } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) + }) + }, timeout) } else { console.log('\n您未提供server酱的SCKEY,取消微信推送消息通知\n'); resolve() diff --git a/serverless.yml b/serverless.yml new file mode 100644 index 0000000..8c4e03b --- /dev/null +++ b/serverless.yml @@ -0,0 +1,81 @@ +# serverless.yml + +#组件信息 +component: scf # (必选) 组件名称,在该实例中为scf +name: jdscript # (必选) 组件实例名称。 + +#组件参数配置 +inputs: + name: scf-${name} # 云函数名称,默认为 ${name}-${stage}-${app} + enableRoleAuth: true # 默认会尝试创建 SCF_QcsRole 角色,如果不需要配置成 false 即可 + src: ./ + handler: index.main_handler #入口 + runtime: Nodejs12.16 # 运行环境 默认 Nodejs10.15 + region: ap-hongkong # 函数所在区域 + description: This is a function in ${app} application. + memorySize: 128 # 内存大小,单位MB + timeout: 900 # 超时时间,单位秒 + events: # 触发器 + - timer: # 签到 + parameters: + name: jd_bean_sign + cronExpression: "0 0 0,7 * * * *" + enable: true + argument: jd_bean_sign + - timer: # 京小超兑换奖品# 摇京豆 + parameters: + name: jd_blueCoin_jd_club_lottery + cronExpression: "0 0 0 * * * *" + enable: true + argument: jd_blueCoin&jd_club_lottery + - timer: # 东东农场# 东东萌宠 + parameters: + name: jd_fruit_jd_pet + cronExpression: "0 5 6-18/6 * * * *" + enable: true + argument: jd_fruit&jd_pet + - timer: # 宠汪汪喂食# 宠汪汪# 摇钱树# 京东种豆得豆# 京喜工厂 #东东工厂 + parameters: + name: joy_feedPets_joy_moneyTree_plantBean_dreamFactory_jdfactory + cronExpression: "0 3 */1 * * * *" + enable: true + argument: jd_joy_feedPets&jd_joy&jd_moneyTree&jd_plantBean&jd_dreamFactory&jd_jdfactory + - timer: # 宠汪汪积分兑换奖品# 宠汪汪偷好友积分与狗# 点点券 + parameters: + name: jd_joy_reward_jd_joy_steal_jd_necklace + cronExpression: "0 0 0-16/8 * * * *" + enable: true + argument: jd_joy_reward&jd_joy_steal&jd_necklace + - timer: # 京东全民开红包 # 进店领豆 # 取关京东店铺商品# 京东抽奖机# 东东小窝# 秒杀红包雨# 健康抽奖机 + parameters: + name: redPacket_shop_unsubscribe_lotteryMachine_small_home_ms_redrain_health + cronExpression: "0 10 0 * * * *" + enable: true + argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_lotteryMachine&jd_small_home&jd_ms_redrain&jd_health + - timer: # 京东天天加速# 天天提鹅 + parameters: + name: jd_speed_jd_daily_egg + cronExpression: "0 8 */3 * * * *" + enable: true + argument: jd_speed&jd_daily_egg + - timer: # 东东超市 + parameters: + name: jd_superMarket + cronExpression: "0 15 * * * * *" + enable: true + argument: jd_superMarket + - timer: # 京豆变动通知 # 京东排行榜 # 领京豆额外奖励 # 京东汽车 + parameters: + name: bean_change_rankingList_bean_home_car + cronExpression: "0 0 10 * * * *" + enable: true + argument: jd_bean_change&jd_rankingList&jd_bean_home&jd_car + - timer: # 金融养猪#十元街# 京东快递 + parameters: + name: pigPet_syj_kd + cronExpression: "0 3 2 * * * *" + enable: true + argument: jd_pigPet&jd_syj&jd_kd + environment: # 环境变量 + variables: # 环境变量对象 + AAA: BBB # 不要删除,用来格式化对齐追加的变量的 diff --git a/tencentscf.md b/tencentscf.md new file mode 100644 index 0000000..30c04ca --- /dev/null +++ b/tencentscf.md @@ -0,0 +1,128 @@ + +# 云函数快速部署京东脚本 +> +> - 本地安装依赖使用serverless部署,[点这里](tencentscf.md#1-安装-nodejs-环境) +> - Github Action 部署[点这里](tencentscf.md#github-action-部署) + +## 1. 安装 Node.js 环境 + +Node.js 环境 [下载地址](https://nodejs.org/zh-tw/download/) ,根据自己的操作系统下载和安装。 + +## 2. 下载代码 + +点击红框处下载压缩包 +![下载代码](https://imgbed-bucket-1251971143.cos.ap-guangzhou.myqcloud.com/1605497672397-zip.png) + +## 3. 安装依赖,配置 cookie + +### 3.1 安装依赖 + +压缩包解压后进入项目文件夹 + +- Windows 用户按住 **shift** 点击右键,点击 **在此处打开命令窗口** +- Mac 用户通过终端,自行进入该文件夹 + +在命令行内输入 `npm i `,等待运行完成。 + +此时,项目文件夹内会多出一个 `node_modules`文件夹 + +### 3.2 配置 cookie + +打开项目文件内的 `jdCookie.js` + +在最上面的 `CookieJDs`里写入 cookie ,多个账号以逗号分隔 + +例如 + +```javascript +let CookieJDs = [ + 'pt_key=xxx;pt_pin=xxx;', + 'pt_key=zzz;pt_pin=zzz;', + 'pt_key=aaa;pt_pin=xxxaaa' +] +``` + +> 注:获取京东 cookie 教程参考 [浏览器获取京东cookie教程](https://github.com/lxk0301/jd_scripts/blob/master/backUp/GetJdCookie.md) , [插件获取京东cookie教程](https://github.com/lxk0301/jd_scripts/blob/master/backUp/GetJdCookie2.md) + + +## 4. 部署到云函数 + +### 4.1 开通服务 + +依次登录 [SCF 云函数控制台](https://console.cloud.tencent.com/scf) 和 [SLS 控制台](https://console.cloud.tencent.com/sls) 开通相关服务,确保账户下已开通服务并创建相应[服务角色](https://console.cloud.tencent.com/cam/role) **SCF_QcsRole、SLS_QcsRole** + +> 注意!为了确保权限足够,获取这两个参数时不要使用子账户!此外,腾讯云账户需要[实名认证](https://console.cloud.tencent.com/developer/auth)。 + +### 4.2 工具部署 + +下载 Serverless 工具,快速部署函数 +``` +npm install -g serverless +``` + +执行部署命令 +``` +serverless deploy +``` + +如果已经配置了永久秘钥,则可以直接部署,如果没有,可以直接**微信扫码**登录腾讯云,并且授权部署。 + +过几秒后,查看输出,可以看到函数和定时触发器都已经配置完成。 +``` +serverless ⚡framework +Action: "deploy" - Stage: "dev" - App: "jdscript" - Instance: "jdscript" + +functionName: scf-jdscript +description: This is a function in jdscript application. +namespace: default +runtime: Nodejs12.16 +handler: index.main_handler +memorySize: 64 +lastVersion: $LATEST +traffic: 1 +triggers: + timer: + - timer-jdscript-dev + +36s › jdscript › Success +``` + +## 5. 查看和测试 + +登录后,在 [腾讯云函数地址](https://console.cloud.tencent.com/scf/index) 点击管理控制台,查看最新部署的函数。 + +在左侧栏的日志查询中,可以查看到触发的日志,包括是否打卡成功等。 + +![测试函数](https://user-images.githubusercontent.com/6993269/99628053-5a9eea80-2a70-11eb-906f-f1d5ea2bfa3a.png) + +> 如果需要配置永久秘钥,则可以在[访问秘钥页面](https://console.cloud.tencent.com/cam/capi)获取账号的 TENCENT_SECRET_ID,TENCENT_SECRET_KEY,并配置在代码根目录 .env 文件中。 + + +# Github Action 部署 +## 1. 开通服务 + +依次登录 [SCF 云函数控制台](https://console.cloud.tencent.com/scf) 和 [SLS 控制台](https://console.cloud.tencent.com/sls) 开通相关服务,确保账户下已开通服务并创建相应[服务角色](https://console.cloud.tencent.com/cam/role) **SCF_QcsRole、SLS_QcsRole** + +> 注意!为了确保权限足够,获取这两个参数时不要使用子账户!此外,腾讯云账户需要[实名认证](https://console.cloud.tencent.com/developer/auth)。 + +## 2. 在这里新建一个访问密钥[新建密钥](https://console.cloud.tencent.com/cam/capi) +> 将SecretId和SecretKey分别配置在仓库的secrets变量里面, TENCENT_SECRET_ID对应你的SecretId的值,TENCENT_SECRET_KEY对应你的SecretKey的值 + +## 3. 配置自己需要secrets变量[参考这里](githubAction.md#下方提供使用到的-secrets全集合) +### __重要的说三遍__ +### 如果涉及一个变量配置多个值,如多个cookie,多个取消订阅关键字,去掉里面的 *__[空格]()__* 和 __*[换行]()*__ 使用 `&` 连接 +### 如果涉及一个变量配置多个值,如多个cookie,多个取消订阅关键字,去掉里面的 *__[空格]()__* 和 __*[换行]()*__ 使用 `&` 连接 +### 如果涉及一个变量配置多个值,如多个cookie,多个取消订阅关键字,去掉里面的 *__[空格]()__* 和 __*[换行]()*__ 使用 `&` 连接 +> 排查问题第一步先看自己[腾讯云函数](https://console.cloud.tencent.com/scf/list-detail?rid=5&ns=default&id=scf-jdscript)那边的环境变量跟自己在仓库配置的 `secrets` 是否一致 +![image](https://user-images.githubusercontent.com/6993269/99937191-06617680-2da0-11eb-99ea-033f2c655683.png) + + +## 4.执行action workflow进行部署,workflow未报错即部署成功 +![image](https://user-images.githubusercontent.com/6993269/99513289-6a152980-29c5-11eb-9266-3f56ba13d3b2.png) +## 5. 查看和测试 +登录后,在 [腾讯云函数地址](https://console.cloud.tencent.com/scf/index) 点击管理控制台,查看最新部署的函数。 + +在左侧栏的日志查询中,可以查看到触发的日志,包括是否打卡成功等。 + +![测试函数](https://user-images.githubusercontent.com/6993269/99628053-5a9eea80-2a70-11eb-906f-f1d5ea2bfa3a.png) +## 6. 设置触发器[看这里](iCloud.md#5设置触发器) 或者看这里的[注释说明](https://github.com/iouAkira/jd_scripts/blob/patch-1/index.js#L4) diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 58175ab..0000000 --- a/yarn.lock +++ /dev/null @@ -1,1349 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@sindresorhus/is@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" - integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow== - -"@sindresorhus/is@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.0.0.tgz#2ff674e9611b45b528896d820d3d7a812de2f0e4" - integrity sha512-FyD2meJpDPjyNQejSjvnhpgI/azsQkA4lGbuu5BQZfjvJ9cbRZXzeWL2HceCekW4lixO9JPesIIQkSoLjeJHNQ== - -"@szmarczak/http-timer@^4.0.5": - version "4.0.5" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.5.tgz#bfbd50211e9dfa51ba07da58a14cdfd333205152" - integrity sha512-PyRA9sm1Yayuj5OIoJ1hGt2YISX45w9WcFbh6ddT0Z/0yaFxOtGLInr4jUfU1EAFVs0Yfyfev4RNwBlUaHdlDQ== - dependencies: - defer-to-connect "^2.0.0" - -"@types/cacheable-request@^6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976" - integrity sha512-ykFq2zmBGOCbpIXtoVbz4SKY5QriWPh3AjyU4G74RYbtt5yOc5OfaY75ftjg7mikMOla1CTGpX3lLbuJh8DTrQ== - dependencies: - "@types/http-cache-semantics" "*" - "@types/keyv" "*" - "@types/node" "*" - "@types/responselike" "*" - -"@types/http-cache-semantics@*": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a" - integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A== - -"@types/keyv@*": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7" - integrity sha512-MPtoySlAZQ37VoLaPcTHCu1RWJ4llDkULYZIzOYxlhxBqYPB0RsRlmMU0R6tahtFe27mIdkHV+551ZWV4PLmVw== - dependencies: - "@types/node" "*" - -"@types/node@*": - version "14.14.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.6.tgz#146d3da57b3c636cc0d1769396ce1cfa8991147f" - integrity sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw== - -"@types/responselike@*", "@types/responselike@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" - integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== - dependencies: - "@types/node" "*" - -ajv@^6.12.3: - version "6.12.6" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -archive-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/archive-type/-/archive-type-4.0.0.tgz#f92e72233056dfc6969472749c267bdb046b1d70" - integrity sha1-+S5yIzBW38aWlHJ0nCZ72wRrHXA= - dependencies: - file-type "^4.2.0" - -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" - integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= - -async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== - dependencies: - lodash "^4.17.14" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= - -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== - -base64-js@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" - integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== - -basic-auth@^1.0.3: - version "1.1.0" - resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-1.1.0.tgz#45221ee429f7ee1e5035be3f51533f1cdfd29884" - integrity sha1-RSIe5Cn37h5QNb4/UVM/HN/SmIQ= - -bcrypt-pbkdf@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" - -bl@^1.0.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7" - integrity sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -buffer-alloc-unsafe@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" - integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg== - -buffer-alloc@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" - integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow== - dependencies: - buffer-alloc-unsafe "^1.1.0" - buffer-fill "^1.0.0" - -buffer-crc32@~0.2.3: - version "0.2.13" - resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" - integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= - -buffer-fill@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" - integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= - -buffer@^5.2.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -cacheable-lookup@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.3.tgz#049fdc59dffdd4fc285e8f4f82936591bd59fec3" - integrity sha512-W+JBqF9SWe18A72XFzN/V/CULFzPm7sBXzzR6ekkE+3tLG72wFZrBiBZhrZuDoYexop4PHJVdFAKb/Nj9+tm9w== - -cacheable-request@^2.1.1: - version "2.1.4" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-2.1.4.tgz#0d808801b6342ad33c91df9d0b44dc09b91e5c3d" - integrity sha1-DYCIAbY0KtM8kd+dC0TcCbkeXD0= - dependencies: - clone-response "1.0.2" - get-stream "3.0.0" - http-cache-semantics "3.8.1" - keyv "3.0.0" - lowercase-keys "1.0.0" - normalize-url "2.0.1" - responselike "1.0.2" - -cacheable-request@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.1.tgz#062031c2856232782ed694a257fa35da93942a58" - integrity sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^4.0.0" - lowercase-keys "^2.0.0" - normalize-url "^4.1.0" - responselike "^2.0.0" - -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= - -clone-response@1.0.2, clone-response@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" - integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= - dependencies: - mimic-response "^1.0.0" - -colors@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== - -combined-stream@^1.0.6, combined-stream@~1.0.6: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -commander@^2.8.1: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -content-disposition@^0.5.2: - version "0.5.3" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" - integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g== - dependencies: - safe-buffer "5.1.2" - -core-util-is@1.0.2, core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - -corser@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/corser/-/corser-2.0.1.tgz#8eda252ecaab5840dcd975ceb90d9370c819ff87" - integrity sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c= - -crypto-js@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc" - integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg== - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" - -debug@^3.1.1: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - -decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= - -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= - dependencies: - mimic-response "^1.0.0" - -decompress-response@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" - integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== - dependencies: - mimic-response "^3.1.0" - -decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1" - integrity sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ== - dependencies: - file-type "^5.2.0" - is-stream "^1.1.0" - tar-stream "^1.5.2" - -decompress-tarbz2@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" - integrity sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A== - dependencies: - decompress-tar "^4.1.0" - file-type "^6.1.0" - is-stream "^1.1.0" - seek-bzip "^1.0.5" - unbzip2-stream "^1.0.9" - -decompress-targz@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" - integrity sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w== - dependencies: - decompress-tar "^4.1.1" - file-type "^5.2.0" - is-stream "^1.1.0" - -decompress-unzip@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69" - integrity sha1-3qrM39FK6vhVePczroIQ+bSEj2k= - dependencies: - file-type "^3.8.0" - get-stream "^2.2.0" - pify "^2.3.0" - yauzl "^2.4.2" - -decompress@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/decompress/-/decompress-4.2.1.tgz#007f55cc6a62c055afa37c07eb6a4ee1b773f118" - integrity sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ== - dependencies: - decompress-tar "^4.0.0" - decompress-tarbz2 "^4.0.0" - decompress-targz "^4.0.0" - decompress-unzip "^4.0.1" - graceful-fs "^4.1.10" - make-dir "^1.0.0" - pify "^2.3.0" - strip-dirs "^2.0.0" - -defer-to-connect@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.0.tgz#83d6b199db041593ac84d781b5222308ccf4c2c1" - integrity sha512-bYL2d05vOSf1JEZNx5vSAtPuBMkX8K9EUutg7zlKvTqKXHt7RhWJFbmd7qakVuf13i+IkGmp6FwSsONOf6VYIg== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= - -download@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/download/-/download-8.0.0.tgz#afc0b309730811731aae9f5371c9f46be73e51b1" - integrity sha512-ASRY5QhDk7FK+XrQtQyvhpDKanLluEEQtWl/J7Lxuf/b+i8RYh997QeXvL85xitrmRKVlx9c7eTrcRdq2GS4eA== - dependencies: - archive-type "^4.0.0" - content-disposition "^0.5.2" - decompress "^4.2.1" - ext-name "^5.0.0" - file-type "^11.1.0" - filenamify "^3.0.0" - get-stream "^4.1.0" - got "^8.3.1" - make-dir "^2.1.0" - p-event "^2.1.0" - pify "^4.0.1" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - -ecstatic@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/ecstatic/-/ecstatic-3.3.2.tgz#6d1dd49814d00594682c652adb66076a69d46c48" - integrity sha512-fLf9l1hnwrHI2xn9mEDT7KIi22UDqA2jaCwyCbSUJh9a1V+LEUSL/JO/6TIz/QyuBURWUHrFL5Kg2TtO1bkkog== - dependencies: - he "^1.1.1" - mime "^1.6.0" - minimist "^1.1.0" - url-join "^2.0.5" - -end-of-stream@^1.0.0, end-of-stream@^1.1.0: - version "1.4.4" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" - integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== - dependencies: - once "^1.4.0" - -escape-string-regexp@^1.0.2: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= - -eventemitter3@^4.0.0: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -ext-list@^2.0.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/ext-list/-/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37" - integrity sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA== - dependencies: - mime-db "^1.28.0" - -ext-name@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ext-name/-/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6" - integrity sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ== - dependencies: - ext-list "^2.0.0" - sort-keys-length "^1.0.0" - -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" - integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= - -fast-deep-equal@^3.1.1: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - -fd-slicer@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" - integrity sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4= - dependencies: - pend "~1.2.0" - -file-type@^11.1.0: - version "11.1.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-11.1.0.tgz#93780f3fed98b599755d846b99a1617a2ad063b8" - integrity sha512-rM0UO7Qm9K7TWTtA6AShI/t7H5BPjDeGVDaNyg9BjHAj3PysKy7+8C8D137R88jnR3rFJZQB/tFgydl5sN5m7g== - -file-type@^3.8.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" - integrity sha1-JXoHg4TR24CHvESdEH1SpSZyuek= - -file-type@^4.2.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-4.4.0.tgz#1b600e5fca1fbdc6e80c0a70c71c8dba5f7906c5" - integrity sha1-G2AOX8ofvcboDApwxxyNul95BsU= - -file-type@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" - integrity sha1-LdvqfHP/42No365J3DOMBYwritY= - -file-type@^6.1.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" - integrity sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg== - -filename-reserved-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229" - integrity sha1-q/c9+rc10EVECr/qLZHzieu/oik= - -filenamify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-3.0.0.tgz#9603eb688179f8c5d40d828626dcbb92c3a4672c" - integrity sha512-5EFZ//MsvJgXjBAFJ+Bh2YaCTRF/VP1YOmGrgt+KJ4SFRLjI87EIdwLLuT6wQX0I4F9W41xutobzczjsOKlI/g== - dependencies: - filename-reserved-regex "^2.0.0" - strip-outer "^1.0.0" - trim-repeated "^1.0.0" - -follow-redirects@^1.0.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" - integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.6" - mime-types "^2.1.12" - -from2@^2.1.1: - version "2.3.0" - resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af" - integrity sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8= - dependencies: - inherits "^2.0.1" - readable-stream "^2.0.0" - -fs-constants@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" - integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== - -get-stream@3.0.0, get-stream@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" - integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= - -get-stream@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" - integrity sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4= - dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" - -get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - -get-stream@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" - integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== - dependencies: - pump "^3.0.0" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" - -got@^11.5.1: - version "11.8.0" - resolved "https://registry.yarnpkg.com/got/-/got-11.8.0.tgz#be0920c3586b07fd94add3b5b27cb28f49e6545f" - integrity sha512-k9noyoIIY9EejuhaBNLyZ31D5328LeqnyPNXJQb2XlJZcKakLqN5m6O/ikhq/0lw56kUYS54fVm+D1x57YC9oQ== - dependencies: - "@sindresorhus/is" "^4.0.0" - "@szmarczak/http-timer" "^4.0.5" - "@types/cacheable-request" "^6.0.1" - "@types/responselike" "^1.0.0" - cacheable-lookup "^5.0.3" - cacheable-request "^7.0.1" - decompress-response "^6.0.0" - http2-wrapper "^1.0.0-beta.5.2" - lowercase-keys "^2.0.0" - p-cancelable "^2.0.0" - responselike "^2.0.0" - -got@^8.3.1: - version "8.3.2" - resolved "https://registry.yarnpkg.com/got/-/got-8.3.2.tgz#1d23f64390e97f776cac52e5b936e5f514d2e937" - integrity sha512-qjUJ5U/hawxosMryILofZCkm3C84PLJS/0grRIpjAwu+Lkxxj5cxeCU25BG0/3mDSpXKTyZr8oh8wIgLaH0QCw== - dependencies: - "@sindresorhus/is" "^0.7.0" - cacheable-request "^2.1.1" - decompress-response "^3.3.0" - duplexer3 "^0.1.4" - get-stream "^3.0.0" - into-stream "^3.1.0" - is-retry-allowed "^1.1.0" - isurl "^1.0.0-alpha5" - lowercase-keys "^1.0.0" - mimic-response "^1.0.0" - p-cancelable "^0.4.0" - p-timeout "^2.0.1" - pify "^3.0.0" - safe-buffer "^5.1.1" - timed-out "^4.0.1" - url-parse-lax "^3.0.0" - url-to-options "^1.0.1" - -graceful-fs@^4.1.10: - version "4.2.4" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" - integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= - -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== - dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" - -has-symbol-support-x@^1.4.1: - version "1.4.2" - resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" - integrity sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw== - -has-to-string-tag-x@^1.2.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" - integrity sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw== - dependencies: - has-symbol-support-x "^1.4.1" - -he@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - -http-cache-semantics@3.8.1: - version "3.8.1" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2" - integrity sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w== - -http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== - -http-proxy@^1.18.0: - version "1.18.1" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" - integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== - dependencies: - eventemitter3 "^4.0.0" - follow-redirects "^1.0.0" - requires-port "^1.0.0" - -http-server@^0.12.3: - version "0.12.3" - resolved "https://registry.yarnpkg.com/http-server/-/http-server-0.12.3.tgz#ba0471d0ecc425886616cb35c4faf279140a0d37" - integrity sha512-be0dKG6pni92bRjq0kvExtj/NrrAd28/8fCXkaI/4piTwQMSDSLMhWyW0NI1V+DBI3aa1HMlQu46/HjVLfmugA== - dependencies: - basic-auth "^1.0.3" - colors "^1.4.0" - corser "^2.0.1" - ecstatic "^3.3.2" - http-proxy "^1.18.0" - minimist "^1.2.5" - opener "^1.5.1" - portfinder "^1.0.25" - secure-compare "3.0.1" - union "~0.5.0" - -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= - dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http2-wrapper@^1.0.0-beta.5.2: - version "1.0.0-beta.5.2" - resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.0-beta.5.2.tgz#8b923deb90144aea65cf834b016a340fc98556f3" - integrity sha512-xYz9goEyBnC8XwXDTuC/MZ6t+MrKVQZOk4s7+PaDkwIsQd8IwqvM+0M6bA/2lvG8GHXcPdf+MejTUeO2LCPCeQ== - dependencies: - quick-lru "^5.1.1" - resolve-alpn "^1.0.0" - -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inherits@^2.0.1, inherits@~2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -into-stream@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/into-stream/-/into-stream-3.1.0.tgz#96fb0a936c12babd6ff1752a17d05616abd094c6" - integrity sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY= - dependencies: - from2 "^2.1.1" - p-is-promise "^1.1.0" - -is-natural-number@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" - integrity sha1-q5124dtM7VHjXeDHLr7PCfc0zeg= - -is-object@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470" - integrity sha1-iVJojF7C/9awPsyF52ngKQMINHA= - -is-plain-obj@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" - integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= - -is-retry-allowed@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" - integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== - -is-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= - -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - -isurl@^1.0.0-alpha5: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" - integrity sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w== - dependencies: - has-to-string-tag-x "^1.2.0" - is-object "^1.0.1" - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - -json-buffer@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" - integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= - -json-buffer@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" - integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== - -json-schema-traverse@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= - -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - -keyv@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.0.0.tgz#44923ba39e68b12a7cec7df6c3268c031f2ef373" - integrity sha512-eguHnq22OE3uVoSYG0LVWNP+4ppamWr9+zWBe1bsNcovIMy6huUJFPgy4mGwCd/rnl3vOLGW1MTlu4c57CT1xA== - dependencies: - json-buffer "3.0.0" - -keyv@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.0.3.tgz#4f3aa98de254803cafcd2896734108daa35e4254" - integrity sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA== - dependencies: - json-buffer "3.0.1" - -lodash@^4.17.14: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== - -lowercase-keys@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" - integrity sha1-TjNms55/VFfjXxMkvfb4jQv8cwY= - -lowercase-keys@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== - -lowercase-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" - integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== - -make-dir@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" - integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== - dependencies: - pify "^3.0.0" - -make-dir@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" - integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== - dependencies: - pify "^4.0.1" - semver "^5.6.0" - -mime-db@1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" - integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== - -mime-db@^1.28.0: - version "1.45.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea" - integrity sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w== - -mime-types@^2.1.12, mime-types@~2.1.19: - version "2.1.27" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" - integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== - dependencies: - mime-db "1.44.0" - -mime@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" - integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== - -mimic-response@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" - integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== - -mimic-response@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" - integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== - -minimist@^1.1.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== - -mkdirp@^0.5.5: - version "0.5.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" - integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== - dependencies: - minimist "^1.2.5" - -ms@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -normalize-url@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-2.0.1.tgz#835a9da1551fa26f70e92329069a23aa6574d7e6" - integrity sha512-D6MUW4K/VzoJ4rJ01JFKxDrtY1v9wrgzCX5f2qj/lzH1m/lW6MhUZFKerVsnyjOhOsYzI9Kqqak+10l4LvLpMw== - dependencies: - prepend-http "^2.0.0" - query-string "^5.0.1" - sort-keys "^2.0.0" - -normalize-url@^4.1.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" - integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== - -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -once@^1.3.1, once@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -opener@^1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" - integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A== - -p-cancelable@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.4.1.tgz#35f363d67d52081c8d9585e37bcceb7e0bbcb2a0" - integrity sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ== - -p-cancelable@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.0.0.tgz#4a3740f5bdaf5ed5d7c3e34882c6fb5d6b266a6e" - integrity sha512-wvPXDmbMmu2ksjkB4Z3nZWTSkJEb9lqVdMaCKpZUGJG9TMiNp9XcbG3fn9fPKjem04fJMJnXoyFPk2FmgiaiNg== - -p-event@^2.1.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/p-event/-/p-event-2.3.1.tgz#596279ef169ab2c3e0cae88c1cfbb08079993ef6" - integrity sha512-NQCqOFhbpVTMX4qMe8PF8lbGtzZ+LCiN7pcNrb/413Na7+TRoe1xkKUzuWa/YEJdGQ0FvKtj35EEbDoVPO2kbA== - dependencies: - p-timeout "^2.0.1" - -p-finally@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" - integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= - -p-is-promise@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-1.1.0.tgz#9c9456989e9f6588017b0434d56097675c3da05e" - integrity sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4= - -p-timeout@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-2.0.1.tgz#d8dd1979595d2dc0139e1fe46b8b646cb3cdf038" - integrity sha512-88em58dDVB/KzPEx1X0N3LwFfYZPyDc4B6eF38M1rk9VTZMbxXXgjugz8mmwpS9Ox4BDZ+t6t3QP5+/gazweIA== - dependencies: - p-finally "^1.0.0" - -pend@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" - integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= - -pify@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= - -pify@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= - -pify@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" - integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= - -portfinder@^1.0.25: - version "1.0.28" - resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" - integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA== - dependencies: - async "^2.6.2" - debug "^3.1.1" - mkdirp "^0.5.5" - -prepend-http@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" - integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= - -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - -psl@^1.1.28, psl@^1.1.33: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - -pump@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" - integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -qs@^6.4.0: - version "6.9.4" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.4.tgz#9090b290d1f91728d3c22e54843ca44aea5ab687" - integrity sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ== - -qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - -query-string@^5.0.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" - integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== - dependencies: - decode-uri-component "^0.2.0" - object-assign "^4.1.0" - strict-uri-encode "^1.0.0" - -quick-lru@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" - integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== - -readable-stream@^2.0.0, readable-stream@^2.3.0, readable-stream@^2.3.5: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - -request@^2.88.2: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= - -resolve-alpn@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.0.0.tgz#745ad60b3d6aff4b4a48e01b8c0bdc70959e0e8c" - integrity sha512-rTuiIEqFmGxne4IovivKSDzld2lWW9QCjqv80SYjPgf+gS35eaCAjaP54CCwGAwBtnCsvNLYtqxe1Nw+i6JEmA== - -responselike@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" - integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= - dependencies: - lowercase-keys "^1.0.0" - -responselike@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.0.tgz#26391bcc3174f750f9a79eacc40a12a5c42d7723" - integrity sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw== - dependencies: - lowercase-keys "^2.0.0" - -safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" - integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - -secure-compare@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/secure-compare/-/secure-compare-3.0.1.tgz#f1a0329b308b221fae37b9974f3d578d0ca999e3" - integrity sha1-8aAymzCLIh+uN7mXTz1XjQypmeM= - -seek-bzip@^1.0.5: - version "1.0.6" - resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.6.tgz#35c4171f55a680916b52a07859ecf3b5857f21c4" - integrity sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ== - dependencies: - commander "^2.8.1" - -semver@^5.6.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -sort-keys-length@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sort-keys-length/-/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188" - integrity sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg= - dependencies: - sort-keys "^1.0.0" - -sort-keys@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad" - integrity sha1-RBttTTRnmPG05J6JIK37oOVD+a0= - dependencies: - is-plain-obj "^1.0.0" - -sort-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-2.0.0.tgz#658535584861ec97d730d6cf41822e1f56684128" - integrity sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg= - dependencies: - is-plain-obj "^1.0.0" - -sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -strict-uri-encode@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" - integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= - -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - -strip-dirs@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5" - integrity sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g== - dependencies: - is-natural-number "^4.0.1" - -strip-outer@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" - integrity sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg== - dependencies: - escape-string-regexp "^1.0.2" - -tar-stream@^1.5.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555" - integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A== - dependencies: - bl "^1.0.0" - buffer-alloc "^1.2.0" - end-of-stream "^1.0.0" - fs-constants "^1.0.0" - readable-stream "^2.3.0" - to-buffer "^1.1.1" - xtend "^4.0.0" - -through@^2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -timed-out@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= - -to-buffer@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" - integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== - -tough-cookie@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" - integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.1.2" - -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - -trim-repeated@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" - integrity sha1-42RqLqTokTEr9+rObPsFOAvAHCE= - dependencies: - escape-string-regexp "^1.0.2" - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - -unbzip2-stream@^1.0.9: - version "1.4.3" - resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz#b0da04c4371311df771cdc215e87f2130991ace7" - integrity sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg== - dependencies: - buffer "^5.2.1" - through "^2.3.8" - -union@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/union/-/union-0.5.0.tgz#b2c11be84f60538537b846edb9ba266ba0090075" - integrity sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA== - dependencies: - qs "^6.4.0" - -universalify@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" - integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== - -uri-js@^4.2.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" - integrity sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g== - dependencies: - punycode "^2.1.0" - -url-join@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/url-join/-/url-join-2.0.5.tgz#5af22f18c052a000a48d7b82c5e9c2e2feeda728" - integrity sha1-WvIvGMBSoACkjXuCxenC4v7tpyg= - -url-parse-lax@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" - integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= - dependencies: - prepend-http "^2.0.0" - -url-to-options@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" - integrity sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k= - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= - -xtend@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - -yauzl@^2.4.2: - version "2.10.0" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" - integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk= - dependencies: - buffer-crc32 "~0.2.3" - fd-slicer "~1.1.0"