diff --git a/.github/workflows/deploy_tencent_scf.yml b/.github/workflows/deploy_tencent_scf.yml index 78ff553..100db47 100644 --- a/.github/workflows/deploy_tencent_scf.yml +++ b/.github/workflows/deploy_tencent_scf.yml @@ -70,6 +70,7 @@ jobs: 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 [ $JDZZ_SHARECODES ]; then sed -i "/variables/a\ JDZZ_SHARECODES: $JDZZ_SHARECODES" serverless.yml; fi; + if [ $JDJOY_SHARECODES ]; then sed -i "/variables/a\ JDJOY_SHARECODES: $JDJOY_SHARECODES" 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; @@ -124,6 +125,7 @@ jobs: DDFACTORY_SHARECODES: ${{ secrets.DDFACTORY_SHARECODES}} DREAM_FACTORY_SHARE_CODES: ${{ secrets.DREAM_FACTORY_SHARE_CODES}} JDZZ_SHARECODES: ${{ secrets.JDZZ_SHARECODES}} + JDJOY_SHARECODES: ${{ secrets.JDJOY_SHARECODES}} TG_PROXY_HOST: ${{ secrets.TG_PROXY_HOST}} TG_PROXY_PORT: ${{ secrets.TG_PROXY_PORT}} MONEY_TREE_SELL_FRUIT: ${{ secrets.MONEY_TREE_SELL_FRUIT}} diff --git a/JD_extra_cookie.js b/JD_extra_cookie.js index f1eed49..504eda2 100644 --- a/JD_extra_cookie.js +++ b/JD_extra_cookie.js @@ -7,11 +7,10 @@ Github: https://github.com/dompling =================== 特别说明: -1.获取多个京东cookie文件,不和野比大佬的文件冲突。暂不支持野比大佬脚本签到。 -2.若是要使用京东多合一签到,请使用修改版地址:https://raw.githubusercontent.com/dompling/Script/master/jd/JD_extra.js +1.获取多个京东cookie的脚本,不和NobyDa的京东cookie冲突。 =================== =================== -使用方式:复制 https://home.m.jd.com/myJd/newhome.action 到浏览器打开 ,在个人中心自动获取 cookie, +使用方式:在代理软件配置好下方配置后,复制 https://home.m.jd.com/myJd/newhome.action 到浏览器打开 ,在个人中心自动获取 cookie, 若弹出成功则正常使用。否则继续再此页面继续刷新一下试试 =================== diff --git a/Loon/lxk0301_LoonTask.conf b/Loon/lxk0301_LoonTask.conf index d2fbd7a..13ff0c4 100644 --- a/Loon/lxk0301_LoonTask.conf +++ b/Loon/lxk0301_LoonTask.conf @@ -37,7 +37,7 @@ cron "3 */5 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scri cron "11 1-23/2 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js,tag=京小超 # 京小超兑换奖品 -cron "0 0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js,tag=京小超兑换奖品 +cron "0,30 0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js,tag=京小超兑换奖品 # 取关京东店铺商品 cron "55 23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js,tag=取关京东店铺商品 @@ -91,13 +91,13 @@ http-response ^https:\/\/jdjoy\.jd\.com\/pet\/getPetTreasureBox|^https:\/\/draw\ 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 # 京东代属 -cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属 +# cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属 # 京东快递 cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, tag=京东快递签到 # 京东汽车 -cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车 +cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车 # 领京豆额外奖励 cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, tag=领京豆额外奖励 @@ -107,17 +107,19 @@ cron "3 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script # 京东赚赚 cron "10 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, tag=京东赚赚 # 京东秒杀红包雨 -cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨 +# cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨 #注销京东店铺会员卡 cron "23 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unbind.js, tag=注销京东店铺会员卡 # 京东直播 cron "10-20/5 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, tag=京东直播 # 京东看一看 -cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, tag=京东看一看 +# cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, tag=京东看一看 #直播红包雨 -cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 +# cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 # 金融打卡领年终奖 -cron "10 6 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=金融打卡领年终奖 +# cron "10 6 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=金融打卡领年终奖 # 健康抽奖机 -cron "10 0 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 \ No newline at end of file +cron "10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 +# 疯狂的joy日常任务 +cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js,tag=疯狂的joy日常任务 diff --git a/QuantumultX/lxk0301_gallery.json b/QuantumultX/lxk0301_gallery.json index bc4aee1..913a5b0 100644 --- a/QuantumultX/lxk0301_gallery.json +++ b/QuantumultX/lxk0301_gallery.json @@ -13,7 +13,7 @@ "15 */5 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_moneyTree.js , tag=京东摇钱树 , img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyqs.png", "5 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_club_lottery.js , tag=摇京豆 , img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyjd.png", "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", - "0 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js , tag=京小超兑换奖品 , img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png", + "0,30 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js , tag=京小超兑换奖品 , img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png", "55 23 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js , tag=取关京东店铺商品 , img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png", "10 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_shop.js , tag=进店领豆 , img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_shop.png", "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", @@ -24,19 +24,14 @@ "13 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, tag=东东小窝, img-url=https://github.com/58xinian/icon/raw/master/ddxw.png", "10 * * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js, tag=东东工厂, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png", "0 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, tag=十元街, img-url=https://github.com/58xinian/icon/raw/master/jd_syj.png", - "15 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png", "10 6 * * * 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", - "20 7 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_car.png", + "0 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_car.png", "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", - "30 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", "30 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, tag=健康抽奖机, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png", - "40 9,10 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, tag=京东看一看, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_watch.png", "10-20/5 12 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, tag=京东直播, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_live_redrain.png", - "10 8 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js, tag=京东健康, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_jdh.png", "14 11 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, tag=京东赚赚, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzz.png", "44 12 * * 6 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unbind.js, tag=注销京东店铺会员卡, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind.png", - "1 0,20,9-23/2 15-31 12 * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_live_redrain.png", - "10 12 1-31 12 * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=京东金融打卡, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png", + "30 8 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, tag=crazyJoy任务, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png", "15 17 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/xmSports.js, tag=小米运动, img-url=https://raw.githubusercontent.com/58xinian/icon/master/xmyd.png" ] } diff --git a/README.md b/README.md index a9bf204..68c4d18 100644 --- a/README.md +++ b/README.md @@ -20,36 +20,44 @@ > ***您使用或者复制了本仓库且本人制作的任何脚本,则视为`已接受`此声明,请仔细阅读*** ## Script脚本列表 +#### 说明 +1. 其中 [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) +2. 短期任务仅在特定时间有效,请自行在京东APP上查阅,恕不再另行说明。 -1. 京东水果([jd_fruit.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_fruit.js)) -2. 东东萌宠([jd_pet.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pet.js)) -4. 种豆得豆([jd_plantBean.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_plantBean.js)) -5. 天天加速([jd_speed.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_speed.js)) -6. 摇钱树([jd_moneyTree.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_moneyTree.js)) -6. 宠汪汪([jd_joy.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy.js)) -7. 宠汪汪偷好友狗粮与积分([jd_joy_steal.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_steal.js)) -8. 宠汪汪单独喂食([jd_joy_feedPets.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_feedPets.js)) -9. 宠汪汪兑换奖品([jd_joy_reward.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_reward.js)) -10. 宠汪汪强制为好友助力(刷好友)([jd_joy_help.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js)) -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)) -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) 】 -20. 京豆变动通知([jd_bean_change.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.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)) +| 活动时长 | 名称 | 脚本 | +| ---- | ------------------------------ | -------------------------------------------------------------------------------------------------------- | +| 长期 | 疯狂的joy | [jd_crazy_joy.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js) | +| 长期 | 京豆变动通知 | [jd_bean_change.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.js) | +| 长期 | 京东多合一签到 | [jd_bean_sign.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_sign.js) | +| 长期 | 东东超市兑换奖品 | [jd_blueCoin.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js) | +| 长期 | 摇京豆 | [jd_club_lottery.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_club_lottery.js) | +| 长期 | 东东农场 | [jd_fruit.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_fruit.js) | +| 长期 | 宠汪汪 | [jd_joy.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy.js) | +| 长期 | 宠汪汪单独喂食 | [jd_joy_feedPets.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_feedPets.js) | +| 长期 | 宠汪汪强制为好友助力(iOS端专用) | [jd_joy_help.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_help.js) | +| 长期 | 宠汪汪聚宝盆辅助脚本(iOS端专用) | [jd_petTreasureBox.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_petTreasureBox.js) | +| 长期 | 宠汪汪兑换奖品 | [jd_joy_reward.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_reward.js) | +| 长期 | 宠汪汪赛跑助力 | [jd_joy_run.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_run.js) | +| 长期 | 宠汪汪偷好友狗粮与积分 | [jd_joy_steal.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_joy_steal.js) | +| 长期 | 摇钱树 | [jd_moneyTree.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_moneyTree.js) | +| 长期 | 东东萌宠 | [jd_pet.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pet.js) | +| 长期 | 金融养猪 | [jd_pigPet.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pigPet.js) | +| 长期 | 天天提鹅 | [jd_daily_egg.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_daily_egg.js) | +| 长期 | 种豆得豆 | [jd_plantBean.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_plantBean.js) | +| 长期 | 全民开红包 | [jd_redPacket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_redPacket.js) | +| 长期 | 进店领豆 | [jd_shop.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_shop.js) | +| 长期 | 天天加速 | [jd_speed.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_speed.js) | +| 长期 | 京东快递 | [jd_kd.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js) | +| 长期 | 东东超市 | [jd_superMarket.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js) | +| 长期 | 京喜工厂 | [jd_dreamFactory.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_dreamFactory.js) | +| 长期 | 东东工厂 | [jd_jdfactory.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdfactory.js) | +| 长期 | 东东小窝 | [jd_small_home.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js) | +| 长期 | 点点券 | [jd_necklace.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_necklace.js) | +| 长期 | 十元街 | [jd_syj.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js) | +| 长期 | 京东代属 | [jd_ds.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js) | +| 长期 | 取关京东店铺和商品 | [jd_unsubscribe.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js) | +| 短期 | 星推官 | [jd_xtg.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_xtg.js) | +| 短期 | 手机狂欢城 | [jd_818.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_818.js) | 搬运脚本 1. 【[@yangtingxiao](https://github.com/yangtingxiao)】京东抽奖机([jd_lotteryMachine.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_lotteryMachine.js)) @@ -58,10 +66,13 @@ **脚本兼容: [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] 所有活动互助码在一个脚本打印 +- [ ] 京喜工厂添加预测N天后可兑换功能 -- [ ] 东东工厂相互助力 -- [ ] 京喜工厂相互助力 - +## 邀请码互助 + - [邀请码互助入口](https://github.com/lxk0301/jd_scripts/discussions) + - [获取各类活动互助码脚本 jd_get_share_code.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js) + - [邀请码使用规范](githubAction.md#互助码类环境变量)(仅限云端) ## 食用方法 ### 方法一:本地安装Node.js,下载本库脚本 @@ -77,9 +88,9 @@ ### 方法二:云服务器、腾讯云函数等等 - 需自行有云服务器,云函数等 - - 腾讯云云函数 [快速部署教程](tencentscf.md)(免费) - - 腾讯云云函数控制台使用 [教程说明](iCloud.md) - - 腾讯云云函数 [GitHub Action部署教程](tencentscf.md#github-action-部署) + - 腾讯云云函数 [快速部署教程](./backUp/tencentscf.md)(免费) + - 腾讯云云函数控制台使用 [教程说明](./backUp/iCloud.md) + - 腾讯云云函数 [GitHub Action部署教程](./backUp/tencentscf.md#github-action-部署) ### 方法三:Docker(NAS或VPS用户) @@ -99,26 +110,7 @@ ### 方法四:iOS系统的代理软件(QuantumultX, Surge, Loon, 小火箭) -#### 以下内容只针对iOS用户 - -#### ios使用多个京东账号,需要使用BoxJs保存多会话进行切换 - -##### BoxJs简单说明可看作者[BoxJs仓库地址](https://github.com/chavyleung/scripts/) - -使用box可以实现远程订阅助力好友(需订阅此 [链接](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/lxk0301.boxjs.json)) - -- [BoxJs使用教程](https://chavyleung.gitbook.io/boxjs/) - -- [BoxJs教程视频](https://youtu.be/eIpBrRxiy0w) - - -【用box订阅的好处】 - - 1、脚本也可以远程挂载。京东活动助力功能的分享码只需在box里面填写。以后只需远程更新就行。 - - 2、所有脚本的cookie都可以备份,方便你迁移到其他支持box的软件。 - - 3、box可以支持多账号 + - [京东cookie获取脚本 JD_extra_cookie.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/JD_extra_cookie.js) ### 赞赏码(开发维护不易,请赏杯茶水费)
diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index 5a277b2..0598357 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -32,7 +32,7 @@ cron "5 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script #京小超 cron "11 1-23/5 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_superMarket.js,timeout=530, wake-system=1, tag=京小超 京小超兑换奖品 -cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js,timeout=130, wake-system=1, tag=京小超兑换奖品 +cron "0,30 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_blueCoin.js,timeout=130, wake-system=1, tag=京小超兑换奖品 #取关京东店铺商品 cron "55 23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js,timeout=250, wake-system=1, tag=取关京东店铺商品 #进店领豆 @@ -53,31 +53,25 @@ cron "40 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scrip cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, timeout=650, wake-system=1, tag=东东小窝 #十元街 cron "40 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, timeout=650, wake-system=1, tag=十元街 -#京东代属(仅京东学生认证用户可用) -cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, timeout=650, wake-system=1, tag=京东代属 #领京豆额外奖励 cron "30 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, timeout=750, wake-system=1, tag=领京豆额外奖励 #京东汽车 -cron "30 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, timeout=750, wake-system=1, tag=京东汽车 +cron "0 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, timeout=750, wake-system=1, tag=京东汽车 +#京东汽车积分兑换京豆 +cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange.js, timeout=2750, wake-system=1, tag=京东汽车积分兑换京豆 #京东快递签到 cron "20 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, timeout=750, wake-system=1, tag=京东快递签到 #京东直播(活动结束时间未知) cron "20 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, timeout=750, wake-system=1, tag=京东直播 -#京东看一看 -cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, timeout=7750, wake-system=1, tag=京东看一看 #京东健康 cron "20 23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js, timeout=750, wake-system=1, tag=京东健康 #京东赚赚 cron "20 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, timeout=750, wake-system=1, tag=京东赚赚 #注销京东店铺会员卡 cron "20 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unbind.js, timeout=750, wake-system=1, tag=注销京东店铺会员卡 +#疯狂的joy日常任务 +cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, timeout=1750, wake-system=1, tag=疯狂的joy日常任务 #以下为短期活动 -#金融打卡领年终奖 -cron "30 7 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, timeout=750, wake-system=1, tag=金融打卡领年终奖 #健康抽奖机 -cron "30 2 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, timeout=750, wake-system=1, tag=健康抽奖机 -#直播红包雨(2020-12-31活动结束) -cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, timeout=750, wake-system=1, tag=直播红包雨 -#秒杀红包雨(2020-12-31活动结束) -cron "20 9 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, timeout=750, wake-system=1, tag=秒杀红包雨 +cron "30 2 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, timeout=750, wake-system=1, tag=健康抽奖机 diff --git a/activity/jd_apple_live.js b/activity/jd_apple_live.js index 2602281..e2d0410 100644 --- a/activity/jd_apple_live.js +++ b/activity/jd_apple_live.js @@ -283,7 +283,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_ds.js b/activity/jd_ds.js similarity index 96% rename from jd_ds.js rename to activity/jd_ds.js index aa5bac6..46381bf 100644 --- a/jd_ds.js +++ b/activity/jd_ds.js @@ -87,8 +87,15 @@ const JD_API_HOST = 'https://api.m.jd.com/'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + // $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } diff --git a/jd_jdh.js b/activity/jd_jdh.js similarity index 100% rename from jd_jdh.js rename to activity/jd_jdh.js diff --git a/activity/jd_jxstory.js b/activity/jd_jxstory.js index cd46e3e..45c7994 100644 --- a/activity/jd_jxstory.js +++ b/activity/jd_jxstory.js @@ -498,7 +498,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_live_redrain.js b/activity/jd_live_redrain.js similarity index 94% rename from jd_live_redrain.js rename to activity/jd_live_redrain.js index f13c7e3..4de7cad 100644 --- a/jd_live_redrain.js +++ b/activity/jd_live_redrain.js @@ -21,7 +21,18 @@ cron "0 0,9,11,13,15,17,19,20,21,23 * * *" script-path=https://raw.githubusercon 直播红包雨 = 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('直播红包雨'); - +let ids = { + '0': 'RRA3S6TRRbnNNuGN43oHMA5okbcXmRY', + '9': 'RRA3vyGH4MRwCJELDwV7p24mNAByiSk', + '11': 'RRAnabmRSnpzSSZicXUhSFGBvFXs5c', + '13': 'RRA4RhWMc159kA62qLbaEa88evE7owb', + '15': 'RRA2CnovS9KVTTwBD9NV7o4kc3P8PTN', + '17': 'RRA2nFXT2oSQM3KaYX9uhBC1hBijDey', + '19': 'RRA3SQpuSAAJq1ckoPr4TXaxwbLG73k', + '20': 'RRA2cHV3KXqvHAZGboTTryr8JMYZd5j', + '21': 'RRA3SPs4XrDEXXwQjEFGrBLtMpjtkMV', + '23': 'RRA3dFHoZXGThSnctvtAf69dmVyEDfm', +} const notify = $.isNode() ? require('./sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; @@ -67,12 +78,23 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); return; } + $.log(`=====远程红包雨信息=====`) await getRedRain(); if(!$.activityId) return let nowTs = new Date().getTime() if (!($.st <= nowTs && nowTs < $.ed)) { - console.log(`不在红包雨时间之内`) - return + $.log(`远程红包雨配置获取错误,从本地读取配置`) + $.log(`\n`) + let hour = (new Date().getUTCHours() + 8) %24 + if (ids[hour]){ + $.activityId = ids[hour] + $.log(`本地红包雨配置获取成功`) + } else{ + $.log(`无法从本地读取配置,请检查运行时间`) + return + } + } else{ + $.log(`远程红包雨配置获取成功`) } for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { @@ -81,7 +103,7 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; $.index = i + 1; $.isLogin = true; $.nickName = ''; - message = `【${new Date($.st).getHours()}点${$.name}】` + message = `【${new Date().getUTCHours()+8}点${$.name}】` await TotalBean(); console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); if (!$.isLogin) { @@ -163,6 +185,7 @@ function receiveRedRain() { message += `领取失败,已领过\n`; } else { console.log(`异常:${JSON.stringify(data)}`) + message += `暂无红包雨\n`; } } } diff --git a/jd_ms_redrain.js b/activity/jd_ms_redrain.js similarity index 96% rename from jd_ms_redrain.js rename to activity/jd_ms_redrain.js index c0e8258..c2ea858 100644 --- a/jd_ms_redrain.js +++ b/activity/jd_ms_redrain.js @@ -83,8 +83,14 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } diff --git a/activity/jd_pubg.js b/activity/jd_pubg.js index bed15df..cc22b60 100644 --- a/activity/jd_pubg.js +++ b/activity/jd_pubg.js @@ -330,7 +330,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_watch.js b/activity/jd_watch.js similarity index 99% rename from jd_watch.js rename to activity/jd_watch.js index 499a2fe..f1f9f25 100644 --- a/jd_watch.js +++ b/activity/jd_watch.js @@ -188,6 +188,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; continue } await jdHealth() + await showMsg(); } } })() @@ -200,8 +201,8 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; async function jdHealth() { $.bean = 0 await getTaskList() - console.log(`${$.name}浏览次数:${$.task.times}/${$.task.maxTimes}`) if($.task) { + console.log(`${$.name}浏览次数:${$.task.times}/${$.task.maxTimes}`) let i = 0, j = $.task.times while(j < $.task.maxTimes) { if (!acceptBody[i]) break @@ -220,8 +221,15 @@ async function jdHealth() { } function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + return new Promise(async resolve => { + // $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } @@ -237,7 +245,9 @@ function getTaskList() { } else { if (safeGet(data)) { data = JSON.parse(data); - $.task = data['data']['discTasks'][1] + if (data.busiCode === '0') { + $.task = data['data']['discTasks'][1] + } } } } catch (e) { diff --git a/jr_sign.js b/activity/jr_sign.js similarity index 95% rename from jr_sign.js rename to activity/jr_sign.js index b7e6089..40c9a01 100644 --- a/jr_sign.js +++ b/activity/jr_sign.js @@ -78,8 +78,14 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + } resolve() }) } @@ -96,6 +102,7 @@ function sign() { if (safeGet(data)) { data = JSON.parse(data); console.log(data.resultData.message) + message += `${data.resultData.message}` } } } catch (e) { diff --git a/backUp/iCloud.md b/backUp/iCloud.md new file mode 100644 index 0000000..2269620 --- /dev/null +++ b/backUp/iCloud.md @@ -0,0 +1,208 @@ +## 1.安装 Node.js 环境 + +[下载地址](https://nodejs.org/zh-tw/download/ ) + +根据自己的操作系统下载 + +傻瓜式安装,一直下一步即可。 + + + +## 2.下载源码 + +![BclSld.png](https://s1.ax1x.com/2020/11/04/BclSld.png) + +点击红框处下载压缩包 + +## 3.安装依赖、增加入口文件、增加cookie + +压缩包解压后进入项目文件夹 + +- Windows 用户按住 **shift** 点击右键,点击 **在此处打开命令窗口** +- Mac 用户通过终端,自行进入该文件夹 + +在命令行内输入 `npm i `,等待运行完成。 + +此时,项目文件夹内会多出一个 `node_modules`文件夹 + + **增加入口文件** + +方案一:同一个仓库下同一个时间,执行多个脚本 + +在项目文件夹内新建 `index.js` + +编辑文件 + +```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') //这里写你想要的脚本 +} + +``` +此时,同一时间点下,会同时执行多个脚本,触发器触发后,index.js文件中require()下的所有脚本都会被执行 + +**优点**:同一时间下可以同时执行多个脚本,适合脚本种类少的repository,对脚本数量少的repository推荐使用此方案
**缺点**:多个脚本不同时间点运行无法满足 + +方案二:同一个仓库下不同的时间点,分别执行不同的脚本(类似GitHub Action执行机制) + +在项目文件夹内新建 `index.js` + +编辑文件 + +```javascript +'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`) + } +} + +``` + +此时触发管理按照下图中进行设置,附加信息选择“是”,内容填写需要传递执行的具体脚本文件名,以回车键换行。触发器触发后,附加信息栏内的脚本会被执行,设置多个不同时间点的触发器达到类似GitHub Action的效果 + +**优点**:可以满足个性化需求,同一个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文件中使用,同一个仓库下,二者只能选择其一。
+Ⅱ感谢[issues#115](https://github.com/lxk0301/jd_scripts/issues/115)中的解决方案,目前云函数连续测试已经可以规避热启动问题了。
+Ⅲ在确保完全按照本教程设置的情况下测试云函数运行情况,对于部分人运行日志中出现某些脚本运行失败其他正常,并且错误提示带有strict字样的,请自行删除index.js中的```'use strict';```,再做测试
+ + **增加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' +] +``` + + + +## 4.上传至腾讯云 + +[腾讯云函数地址]( https://console.cloud.tencent.com/scf/index ) + +编写函数 + +登录后,点击管理控制台 + +单击左侧导航栏**函数服务**,进入“函数服务”页面。 +在页面上方选择一个地域,最好选择离你常用地区近点的,不至于导致账号异常。单击**新建**。如下图所示: + +![iCloud1](../icon/iCloud1.png) + +在“新建函数”页面填写函数基础信息,单击**下一步**。如下图所示: + +![iCloud2](../icon/iCloud2.png) + +**函数名称**:可以自定义,比如为jd。
**运行环境**:选择 “Nodejs 12.16”。
**创建方式**:选择 “空白函数”。 + +确保环境为Nodejs 12.16,执行方法改为:index.main_handler,提交方式建议选本地文件夹,然后从GitHub项目克隆Zip压缩包,解压成文件夹,然后点击这个上传把文件夹上传进来(记得node_modules文件夹一并上传或者将node_modules文件夹上传到“层”,之后选择“函数管理”-“层管理”绑定上传好的层),完了后点击下面的高级设置。 + +![iCloud3](../icon/iCloud3.png) + +内存用不了太大,64MB就够了(64M内存,免费时长6,400,000秒,内存与免费时长大致关系可以参看云函数官方说明),超时时间改为最大的900秒,然后点击最下面的完成。 + +![iCloud4](../icon/iCloud4.png) + +## 5.设置触发器 + +点击刚创建的函数 + +![BcGa8O.png](https://s1.ax1x.com/2020/11/04/BcGa8O.png) + +点击如图所示 + +![BcGvM4.png](https://s1.ax1x.com/2020/11/04/BcGvM4.png) + +创建触发器 + +![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个以内,以下设置仅供参考
+ +| **JavaScript** | **脚本名称** | **活动时间** | **原Repository UTC时间** | **适用于云函数的北京时间** | **serverless.yml** | +| :----------------------: | :----------------------: | :----------: | :-----------------------: | :-------------------------: | :----------------: | +| `jd_bean_change` | 京豆变动通知 | 长期 | 0 2 * * * | 0 1 */1 * * | 30 7 * * * | +| `jd_bean_home` | 领京豆额外奖励 | 长期 | / | 0 1 */1 * * | 30 7 * * * | +| `jd_bean_sign` | 京豆签到 | 长期 | 0 16 * * * | 0 0 */1 * * | 0 0 * * * | +| `jd_blueCoin` | 京小超兑换奖品 | 长期 | 0 16 * * * | 0 1 */1 * * | 0 0 * * * | +| `jd_car` | 京东汽车 | 长期 | / | 0 0 */1 * * | 0 0 * * * | +| `jd_club_lottery` | 摇京豆 | 长期 | 0 16 * * * | 0 0 */1 * * | 0 0 * * * | +| `jd_crazy_joy` | 疯狂的joy | 长期 | / | / | 30 7 * * * | +| `jd_crazy_joy_coin` | 疯狂的joy挂机 | 长期 | / | / | / | +| `jd_daily_egg` | 京东金融-天天提额 | 长期 | 10 */3 * * * | 0-12/3 */3 * * * | 8 */3 * * * | +| `jd_dreamFactory` | 京喜工厂 | 长期 | / | */30 * * * * | 3 */1 * * * | +| `jd_ds` | 京东代属(校园用户) | 长期 | / | / | / | +| `jd_fruit` | 东东农场 | 长期 | 20 23,4,10 * * * | 0,5,10 8,9,12,18,23,0 * * * | 5 6-18/6 * * * | +| `jd_health` | 健康抽奖机 | 短期 | / | 0 0 */1 * * | 10 0 * * * | +| `jd_jdfactory` | 东东工厂 | 长期 | / | */30 * * * * | 3 */1 * * * | +| `jd_jdh` | 京东健康APP | 短期 | / | / | 30 7 * * * | +| `jd_jdzz` | 京东赚赚 | 长期 | / | / | 3 1 * * * | +| `jd_joy` | 宠汪汪 | 长期 | 0 0,1,4,10,15,16 * * * | 0,5,10 8,9,12,18,23,0 * * * | 3 */1 * * * | +| `jd_joy_feedPets` | 宠汪汪单独喂食 | 长期 | */20 */1 * * * | 0-12/3 */3 * * * | 3 */1 * * * | +| `jd_joy_help` | 宠汪汪强制为别人助力 | 长期 | / | / | / | +| `jd_joy_reward` | 宠汪汪兑换奖品 | 长期 | 0 0,4,8,16 * * * | 0 8,12,16,0 */1 * * | 0 0-16/8,20 * * * | +| `jd_joy_run` | 宠汪汪邀请助力与赛跑助力 | 长期 | / | / | / | +| `jd_joy_steal` | 宠汪汪偷好友狗粮与积分 | 长期 | 0 16,22 * * * | 0 0,6,20 */1 * * | 0 0-16/8,20 * * * | +| `jd_kd` | 京东快递 | 长期 | / | 0 1 */1 * * | 3 1 * * * | +| `jd_live` | 京东直播18豆 | 长期 | / | / | 0 0-16/8,20 * * * | +| `jd_live_redrain` | 超级直播间红包雨 | 短期 | / | 0 0,20,9-23/2 * * MON-FRI | / | +| `jd_lotteryMachine` | 京东抽奖机 | 长期 | 11 17 * * * | 0 0 */1 * * | 10 0 * * * | +| `jd_moneyTree` | 摇钱树 | 长期 | 40 */3 * * * | 0-12/3 */3 * * * | 3 */1 * * * | +| `jd_ms_redrain` | 秒杀红包雨 | 短期 | / | 0 1 */1 * * | 10 0 * * * | +| `jd_necklace` | 点点券 | 长期 | / | 0 0,6,20 */1 * * | 0 0-16/8,20 * * * | +| `jd_pet` | 东东萌宠 | 长期 | 35 23,4,10 * * * | 0,5,10 8,9,12,18,23,0 * * * | 5 6-18/6 * * * | +| `jd_petTreasureBox` | 宠汪汪聚宝盆 | 长期 | / | / | / | +| `jd_pigPet` | 京东金融-养猪猪 | 长期 | / | 0-12/3 */3 * * * | 3 1 * * * | +| `jd_plantBean` | 种豆得豆 | 长期 | 0 23,0-14/1 * * * | 0-12/3 */3 * * * | 3 */1 * * * | +| `jd_rankingList` | 京东排行榜 | 长期 | 11 18 * * * | 0 0 */1 * * | 30 7 * * * | +| `jd_redPacket` | 全民开红包 | 长期 | 0 17 * * * | 0 1 */1 * * | 10 0 * * * | +| `jd_shop` | 进店领豆 | 长期 | 0 16 * * * | 0 0 */1 * * | 10 0 * * * | +| `jd_small_home` | 东东小窝 | 长期 | / | 0 0,6,20 */1 * * | 10 0 * * * | +| `jd_speed` | 天天加速 | 长期 | 33 */3 * * * | 0-12/3 */3 * * * | 8 */3 * * * | +| `jd_superMarket` | 东东超市 | 长期 | 15 * * * * | */30 * * * * | 15 * * * * | +| `jd_syj` | 十元街 | 长期 | / | 0 1 */1 * * | 3 1 * * * | +| `jd_unbind` | 注销京东会员卡 | 长期 | / | / | 10 0 * * * | +| `jd_unsubscribe` | 取关京东店铺和商品 | 长期 | 45 15 * * * | 0 1 */1 * * | 10 0 * * * | +| `jd_watch` | 发现-看一看 | 长期 | / | / | 3 1 * * * | +| `jr_sign` | 金融打卡年终奖 | 短期 | / | / | 3 1 * * * | +| `jd_818` | 京东手机狂欢城 | 短期 | 0 1,4,7,10,12,16,22 * * * | 0 9,12,15,16,20,0,6 */1 * * | / | +| `jd_apple_live` | 苹果抽奖机 | 短期 | / | / | / | +| `jd_collectProduceScore` | 双十一活动领金币 | 短期 | 30 * * * * | */30 * * * * | / | +| `jd_digital_floor` | 数码加购京豆 | 短期 | / | / | / | +| `jd_jxstory` | 京喜故事 | 短期 | / | / | / | +| `jd_mohe` | 热8超级魔盒 | 短期 | / | / | / | +| `jd_pubg` | PUBG | 短期 | / | / | / | +| `jd_split` | 金榜年终奖 | 短期 | / | / | / | +| `jd_xtg` | 双十一星推官 | 短期 | 0 16 * * * | 0 0 */1 * * | / | + +点击提交,所有流程就结束了。 diff --git a/backUp/iOS_Weather_AQI_Standard.js b/backUp/iOS_Weather_AQI_Standard.js new file mode 100644 index 0000000..dfb2294 --- /dev/null +++ b/backUp/iOS_Weather_AQI_Standard.js @@ -0,0 +1,138 @@ +// Developed by Hackl0us (https://github.com/hackl0us) + +// STEP 1: 前往 https://aqicn.org/data-platform/token/ 注册账户,将申请的 API Token 填入下方 +let aqicnToken = '' +// STEP 2: 参考下方配置片段,在代理工具的配置文件中添加对应的配置。注意:script-path 后应该替换为添加 apicnToken 值后的脚本路径 +/* +===============Surge================= +[Script] +AQI-US = type=http-response, pattern=https://weather-data.apple.com/v1/weather/[\w-]+/[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\?, requires-body=true, script-path=/path/to/iOS_Weather_AQI_Standard.js + +[MITM] +hostname = weather-data.apple.com +*/ +const $ = new Env('牛逼天气'); +aqicnToken = $.getdata('hackl0us_aqi_token'); + +const AirQualityStandard = { + CN: 'HJ6332012.1', + US: 'EPA_NowCast.1' +} + +const AirQualityLevel = { + GOOD: 1, + MODERATE: 2, + UNHEALTHY_FOR_SENSITIVE: 3, + UNHEALTHY: 4, + VERY_UNHEALTHY: 5, + HAZARDOUS: 6 +} + +const coordRegex = /https:\/\/weather-data\.apple\.com\/v1\/weather\/[\w-]+\/([0-9]+\.[0-9]+)\/([0-9]+\.[0-9]+)\?/ +const [_, lat, lng] = $request.url.match(coordRegex) + +function classifyAirQualityLevel(aqiIndex) { + if (aqiIndex >= 0 && aqiIndex <= 50) { + return AirQualityLevel.GOOD; + } else if (aqiIndex >= 51 && aqiIndex <= 100) { + return AirQualityLevel.MODERATE; + } else if (aqiIndex >= 101 && aqiIndex <= 150) { + return AirQualityLevel.UNHEALTHY_FOR_SENSITIVE; + } else if (aqiIndex >= 151 && aqiIndex <= 200) { + return AirQualityLevel.UNHEALTHY; + } else if (aqiIndex >= 201 && aqiIndex <= 300) { + return AirQualityLevel.VERY_UNHEALTHY; + } else if (aqiIndex >= 301 && aqiIndex <= 500) { + return AirQualityLevel.HAZARDOUS; + } +} + +function modifyWeatherResp(weatherRespBody, aqicnRespBody) { + let weatherRespJson = JSON.parse(weatherRespBody) + let aqicnRespJson = JSON.parse(aqicnRespBody).data + weatherRespJson.air_quality = constructAirQuailityNode(aqicnRespJson) + return JSON.stringify(weatherRespJson) +} + +function getPrimaryPollutant(pollutant) { + switch (pollutant) { + case 'co': + return 'CO2'; + case 'so2': + return 'SO2'; + case 'no2': + return 'NO2'; + case 'pm25': + return 'PM2.5'; + case 'pm10': + return 'PM10'; + case 'o3': + return 'OZONE'; + default: + console.log('Unknown pollutant ' + pollutant); + } +} + +function constructAirQuailityNode(aqicnData) { + let airQualityNode = { "source": "", "learnMoreURL": "", "isSignificant": true, "airQualityCategoryIndex": 1, "airQualityScale": "", "airQualityIndex": 0, "pollutants": { "CO": { "name": "CO", "amount": 0, "unit": "μg/m3" }, "SO2": { "name": "SO2", "amount": 0, "unit": "μg/m3" }, "NO2": { "name": "NO2", "amount": 0, "unit": "μg/m3" }, "PM2.5": { "name": "PM2.5", "amount": 0, "unit": "μg/m3" }, "OZONE": { "name": "OZONE", "amount": 0, "unit": "μg/m3" }, "PM10": { "name": "PM10", "amount": 0, "unit": "μg/m3" } }, "metadata": { "reported_time": 0, "longitude": 0, "provider_name": "aqicn.org", "expire_time": 2, "provider_logo": "https://i.loli.net/2020/12/27/UqW23eZLFAIbxGV.png", "read_time": 2, "latitude": 0, "v": 1, "language": "", "data_source": 0 }, "name": "AirQuality", "primaryPollutant": "" } + const aqicnIndex = aqicnData.aqi + airQualityNode.source = aqicnData.city.name + airQualityNode.learnMoreURL = aqicnData.city.url + '/cn/m' + airQualityNode.airQualityCategoryIndex = classifyAirQualityLevel(aqicnIndex) + airQualityNode.airQualityScale = AirQualityStandard.US + airQualityNode.airQualityIndex = aqicnIndex + airQualityNode.pollutants.CO.amount = aqicnData.iaqi.co?.v || -1 + airQualityNode.pollutants.SO2.amount = aqicnData.iaqi.so2?.v || -1 + airQualityNode.pollutants.NO2.amount = aqicnData.iaqi.no2?.v || -1 + airQualityNode.pollutants["PM2.5"].amount = aqicnData.iaqi.pm25?.v || -1 + airQualityNode.pollutants.OZONE.amount = aqicnData.iaqi.o3?.v || -1 + airQualityNode.pollutants.PM10.amount = aqicnData.iaqi.pm10?.v || -1 + airQualityNode.metadata.latitude = aqicnData.city.geo[0] + airQualityNode.metadata.longitude = aqicnData.city.geo[1] + airQualityNode.metadata.read_time = roundHours(new Date(), 'down') + airQualityNode.metadata.expire_time = roundHours(new Date(), 'up') + airQualityNode.metadata.reported_time = aqicnData.time.v + //airQualityNode.metadata.language = $request.headers['Accept-Language'] + airQualityNode.primaryPollutant = getPrimaryPollutant(aqicnData.dominentpol) + return airQualityNode +} + +function roundHours(time, method) { + switch (method) { + case 'up': + time.setHours(time.getHours() + Math.ceil(time.getMinutes() / 60)); + break; + case 'down': + time.setHours(time.getHours() + Math.floor(time.getMinutes() / 60)); + break; + default: + console.log("Error rounding method"); + } + time.setMinutes(2, 0, 0); + return time; +} + +// $httpClient.get(`https://api.waqi.info/feed/geo:${lat};${lng}/?token=${aqicnToken}`, function (error, _response, data) { +// if (error) { +// let body = $response.body +// $done({ body }) +// } else { +// let body = modifyWeatherResp($response.body, data) +// $done({ body }) +// } +// }); +$.get({ url: `https://api.waqi.info/feed/geo:${lat};${lng}/?token=${aqicnToken}`, headers: $request.headers },(err, resp, data) => { + try { + if (err) { + $.logErr(err, resp); + } else { + console.log(`${JSON.stringify(resp.body)}`); + let body = modifyWeatherResp($response.body, resp.body); + $.done({body}); + } + } catch (e) { + $.logErr(e, resp); + $.done(); + } +}); +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)} \ No newline at end of file diff --git a/backUp/qqread.js b/backUp/qqread.js index e2db6bd..abb07af 100644 --- a/backUp/qqread.js +++ b/backUp/qqread.js @@ -14,27 +14,6 @@ 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 @@ -62,7 +41,9 @@ const jsname = '企鹅读书' const $ = Env(jsname) let task = '', config, ssr2 = '', wktime, day = 0; console.log(`\n========= 脚本执行时间(TM):${new Date(new Date().getTime() + 0 * 60 * 60 * 1000).toLocaleString('zh', {hour12: false})} =========\n`) -const notify = require('../sendNotify'); + +const notify = $.isNode() ? require('../sendNotify') : ''; + const logs = 1; //0为关闭日志,1为开启 const TIME = 30//单次时长上传限制,默认5分钟 @@ -78,6 +59,7 @@ let qqreadtimeurlVal = $.getdata(qqreadtimeurlKey) const qqreadtimeheaderKey = 'qqreadtimehd' let qqreadtimeheaderVal = $.getdata(qqreadtimeheaderKey) +let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); //云函数使用在下面填写 let QQ_READ_COOKIES = [ { @@ -177,7 +159,7 @@ function GetCookie() { async function QQ_READ() { for (let i = 0; i < QQ_READ_COOKIES.length; i++) { $.log(`\n*************开始QQ账号${i + 1}**************\n`); - tz = ''; + $.isLogin = true; if (!QQ_READ_COOKIES[i]["qqreadbodyVal"] || !QQ_READ_COOKIES[i]['qqreadtimeurlVal'] || !QQ_READ_COOKIES[i]['qqreadtimeheaderVal']) { $.log(`账号${i + 1}暂未提供脚本执行所需的cookie`); continue @@ -186,6 +168,13 @@ async function QQ_READ() { qqreadtimeurlVal = QQ_READ_COOKIES[i]['qqreadtimeurlVal']; qqreadtimeheaderVal = QQ_READ_COOKIES[i]['qqreadtimeheaderVal']; await qqreadinfo();//用户名 + if (!$.isLogin) { + $.log(`企鹅阅读账号${i + 1} cookie过期`); + if (nowTimes.getHours() % 12 === 0 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify(`企鹅阅读账号${i + 1} cookie过期`, '请及时更新 QQ_READ_TIME_HEADER_VAL') + } + continue + } await qqreadwktime();//周时长查询 await qqreadtrack(); await qqreadconfig();//时长查询 @@ -229,13 +218,12 @@ async function QQ_READ() { if (task.data.user.amount >= 100000) { await qqreadwithdraw(); } - await showmsg();//通知 } + await showmsg();//通知 } function showmsg() { return new Promise(async resolve => { - let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); - if (nowTimes.getHours() === 22 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 20)) { + if (nowTimes.getHours() === 22 && (nowTimes.getMinutes() > 45 && nowTimes.getMinutes() <= 59)) { await notify.sendNotify(jsname, tz); } $.msg(jsname, "", tz); @@ -326,6 +314,13 @@ function qqreadinfo() { $.get(toqqreadinfourl, (error, response, data) => { if (logs) $.log(`${jsname}, 用户名: ${data}`); let info = JSON.parse(data); + if (info.code === 0) { + $.isLogin = info.data['isLogin']; + if (!$.isLogin) { + resolve(); + return + } + } kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; diff --git a/backUp/qqreadOpenBox.js b/backUp/qqreadOpenBox.js new file mode 100644 index 0000000..5182b6e --- /dev/null +++ b/backUp/qqreadOpenBox.js @@ -0,0 +1,293 @@ +/* +lxk0301修改自用,单独开宝箱 +****************************************************************************** +本人github地址 https://github.com/ziye12/JavaScript +转载请备注个名字,谢谢 + +1.5 调整宝箱策略,20分钟运行一次就行 +*/ +const $ = Env(`企鹅读书开宝箱`) +const notify = $.isNode() ? require("../sendNotify") : ""; +const logs = 1; //0为关闭日志,1为开启 + +let task, tz = '', kz, config = '', CASH = '', COOKIES_SPLIT = '' ; +let dk,ljyd,sp,ydrw,wktime; + +let qqreadbodyVal = ``; +let qqreadtimeurlVal = ``; +let qqreadtimeheaderVal = ``; +let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); +//云函数使用在下面填写 +let QQ_READ_COOKIES = [ + { + "qqreadbodyVal": ``, + "qqreadtimeurlVal": ``, + "qqreadtimeheaderVal": `` + } +] + +!(async () => { + await getNodeCookie(); + await open_box(); +})() +.catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') +}) +.finally(() => { + $.done(); +}) + +async function open_box() { + for (let i = 0; i < QQ_READ_COOKIES.length; i++) { + $.log(`\n*************开始QQ账号${i + 1}**************\n`); + // tz = ''; + $.isLogin = true; + if (!QQ_READ_COOKIES[i]["qqreadbodyVal"] || !QQ_READ_COOKIES[i]['qqreadtimeurlVal'] || !QQ_READ_COOKIES[i]['qqreadtimeheaderVal']) { + $.log(`账号${i + 1}暂未提供脚本执行所需的cookie`); + continue + } + qqreadbodyVal = QQ_READ_COOKIES[i]['qqreadbodyVal']; + qqreadtimeurlVal = QQ_READ_COOKIES[i]['qqreadtimeurlVal']; + qqreadtimeheaderVal = QQ_READ_COOKIES[i]['qqreadtimeheaderVal']; + await qqreadinfo();//用户名 + if (!$.isLogin) { + $.log(`企鹅阅读账号${i + 1} cookie过期`); + if (nowTimes.getHours() % 12 === 0 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify(`企鹅阅读账号${i + 1} cookie过期`, '请及时更新 QQ_READ_TIME_HEADER_VAL') + } + continue + } + //单独开宝箱 + if (nowTimes.getHours() === 0 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 59)) { + await qqreadtrack();//更新 + } + await qqreadtask();//任务列表 + if (task.data && ljyd.doneFlag == 0) { + await qqreaddayread();//阅读任务 + } + if (task.data && task.data.treasureBox.timeInterval <= 10000) { + await $.wait(task.data.treasureBox.timeInterval) + await qqreadbox();//宝箱 + } + if (task.data && task.data.treasureBox.timeInterval - 600000 <= 10000) { + await $.wait(task.data.treasureBox.timeInterval - 600000) + await qqreadbox2();//宝箱翻倍 + } + } + await showmsg();//通知 +} + + +function showmsg() { + return new Promise(async resolve => { + if (nowTimes.getHours() === 23 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify($.name, tz); + } + $.msg($.name, "", tz); + resolve() + }) +} + + +// 更新 +function qqreadtrack() { + return new Promise((resolve, reject) => { + const body = qqreadbodyVal.replace(new RegExp(/"dis":[0-9]{13}/), `"dis":${new Date().getTime()}`) + const toqqreadtrackurl = { + url: "https://mqqapi.reader.qq.com/log/v4/mqq/track", + headers: JSON.parse(qqreadtimeheaderVal), + body: body, + timeout: 60000, + }; + $.post(toqqreadtrackurl, (error, response, data) => { + if (logs) $.log(`更新: ${data}`); + let track = JSON.parse(data); + const date = new Date(JSON.parse(qqreadbodyVal).dataList[0].dis) + let Y = date.getFullYear() + '-'; + let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; + let D = date.getDate() + ' '; + let h = date.getHours() + ':'; + let m = date.getMinutes() + ':'; + let s = date.getSeconds(); + let time = Y + M + D + h + m + s; + tz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; + kz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; + resolve(); + }); + }); +} +// 用户名 +function qqreadinfo() { + return new Promise((resolve, reject) => { + const toqqreadinfourl = { + url: "https://mqqapi.reader.qq.com/mqq/user/init", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadinfourl, (error, response, data) => { + if (logs) $.log(`用户名: ${data}`); + const info = JSON.parse(data); + if (info.code === 0) { + $.isLogin = info.data['isLogin']; + if (!$.isLogin) { + resolve(); + return + } + } + kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; + tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; + + resolve(); + }); + }); +} +// 任务列表 +function qqreadtask() { + return new Promise((resolve, reject) => { + const toqqreadtaskurl = { + url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/page?fromGuid=", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadtaskurl, (error, response, data) => { + if (logs) $.log(`任务列表: ${data}`); + task = JSON.parse(data); + dk = task.data.taskList.find(item => item.type === 200); + ljyd = task.data.taskList.find(item => item.type === 210); + ydrw = task.data.taskList.find(item => item.type === 220); + sp = task.data.taskList.find(item => item.type === 230); + + if (task.data.invite.nextInviteConfig) { + 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` + + `【${dk.title}】:${dk.amount}金币,${dk.actionText}\n` + + `【${ljyd.title}】:${ljyd.amount}金币,${ljyd.actionText}\n` + + `【${ydrw.title}】:${ydrw.amount}金币,${ydrw.actionText}\n` + + `【${sp.title}】:${sp.amount}金币,${sp.actionText}\n` + + `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 + }秒后领取\n` + + `【${task.data.fans.title}】:${task.data.fans.fansCount}个好友,${task.data.fans.todayAmount}金币\n`; + } + + kz += + `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + + `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 + }秒后领取\n` + + `【已开宝箱】:${task.data.treasureBox.count}个\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(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreaddayreadurl, (error, response, data) => { + if (logs) $.log(`每日阅读: ${data}`); + let dayread = JSON.parse(data); + if (dayread.code == 0) { + tz += `【每日阅读】:获得${dayread.data.amount}金币\n`; + kz += `【每日阅读】:获得${dayread.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(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadboxurl, (error, response, data) => { + if (logs) $.log(`宝箱奖励: ${data}`); + let box = JSON.parse(data); + if (box.code == 0 && box.data.amount) { + tz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; + kz += `【宝箱奖励${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(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadbox2url, (error, response, data) => { + if (logs) $.log(`宝箱奖励翻倍: ${data}`); + let box2 = JSON.parse(data); + if (box2.code == 0 && box2.data.amount) { + tz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; + kz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; + } + resolve(); + }); + }); +} +function getNodeCookie() { + if ($.isNode()) { + let QQ_READ_BODY_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_BODY_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_BODY_VAL = process.env.QQ_READ_HEADER_VAL.split('\n'); + } else { + QQ_READ_BODY_VAL = [process.env.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_BODY_VAL && QQ_READ_BODY_VAL.length > 0) QQ_READ_COOKIES = []; + for (let i = 0; i < QQ_READ_BODY_VAL.length; i ++) { + QQ_READ_COOKIES.push({ + "qqreadbodyVal": QQ_READ_BODY_VAL[i] || "", + "qqreadtimeurlVal": QQ_READ_TIME_URL_VAL[i] || "", + "qqreadtimeheaderVal": QQ_READ_TIME_HEADER_VAL[i] || "" + }) + } + // console.log(`${JSON.stringify(QQ_READ_COOKIES)}`) + } +} +// 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/tencentscf.md b/backUp/tencentscf.md similarity index 100% rename from tencentscf.md rename to backUp/tencentscf.md diff --git a/docker/Readme.md b/docker/Readme.md index beb0330..922a84a 100644 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -1,4 +1,24 @@ ### Usage +```diff ++ 2021-01-03更新 增加 CUSTOM_SHELL_FILE 参数配置执行自定义shell脚本 ++ 例1:配置远程shell脚本, 我自己写了一个shell脚本https://raw.githubusercontent.com/iouAkira/someDockerfile/master/jd_scripts/shell_script_mod.sh 内容很简单下载惊喜农场并添加定时任务 ++ CUSTOM_SHELL_FILE=https://raw.githubusercontent.com/iouAkira/someDockerfile/master/jd_scripts/shell_script_mod.sh ++ ++ 例2:配置docker挂载本地自定义shell脚本,/scripts/docker/shell_script_mod.sh 为你在docker-compose.yml里面挂载到容器里面绝对路径 ++ CUSTOM_SHELL_FILE=/scripts/docker/shell_script_mod.sh ++ ++ tip:如果使用远程自定义,请保证网络畅通或者选择合适的国内仓库,例如有部分人的容器里面就下载不到github的raw文件,那就可以把自己的自定义shell写在gitee上,或者换本地挂载 ++ 如果是 docker 挂载本地,请保重文件挂载进去了,并且配置的是绝对路径。 ++ 自定义 shell 脚本里面如果要加 crontab 任务请使用 echo 追加到 /scripts/docker/merged_list_file.sh 里面否者不生效 ++ 注⚠️ 建议无shell能力的不要轻易使用,当然你可以找别人写好适配了这个docker镜像的脚本直接远程配置 ++ 上面写了这么多如果还看不懂,不建议使用该变量功能。 +_____ +! ⚠️⚠️⚠️2020-12-11更新镜像启动方式,虽然兼容旧版的运行启动方式,但是强烈建议更新镜像和配置后使用 +! 更新后`command:`指令配置不再需要 +! 更新后可以使用自定义任务文件追加在默任务文件之后,比以前的完全覆盖多一个选择 +! - 新的自定两个环境变量为 `CUSTOM_LIST_MERGE_TYPE`:自定文件的生效方式可选值为`append`,`overwrite`默认为`append` ; `CUSTOM_LIST_FILE`: 自定义文件的名字 +! 更新镜像增减镜像更新通知,以后镜像如果更新之后,会通知用户更新 +``` > 推荐使用`docker-compose`所以这里只介绍`docker-compose`使用方式 - `docker-compose` 安装(群晖nas docker自带安装了docker-compose) @@ -21,12 +41,6 @@ pip install docker-compose ### 如果需要使用 docker 多个账户独立并发执行定时任务,[参考这里](https://github.com/iouAkira/scripts/blob/patch-1/docker/docker%E5%A4%9A%E8%B4%A6%E6%88%B7%E4%BD%BF%E7%94%A8%E7%8B%AC%E7%AB%8B%E5%AE%B9%E5%99%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md#%E4%BD%BF%E7%94%A8%E6%AD%A4%E6%96%B9%E5%BC%8F%E8%AF%B7%E5%85%88%E7%90%86%E8%A7%A3%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8docker%E5%8A%9E%E6%B3%95%E4%B8%80%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) -⚠️⚠️⚠️2020-12-11更新镜像启动方式,虽然兼容旧版的运行启动方式,但是强烈建议更新镜像和配置后使用 -- 更新后`command:`指令配置不再需要 -- 更新后可以使用自定义任务文件追加在默任务文件之后,比以前的完全覆盖多一个选择 -- - 新的自定两个环境变量为 `CUSTOM_LIST_MERGE_TYPE`:自定文件的生效方式可选值为`append`,`overwrite`默认为`append` ; `CUSTOM_LIST_FILE`: 自定义文件的名字 -- 更新镜像增减镜像更新通知,以后镜像如果更新之后,会通知用户更新 - > 注⚠️:前提先理解学会使用这下面的教程 ### 创建一个目录`jd_scripts`用于存放备份配置等数据,迁移重装的时候只需要备份整个jd_scripts目录即可 需要新建的目录文件结构参考如下: diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index c2510d1..d1aa138 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -4,24 +4,14 @@ 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## -# 秒杀红包雨(2020.12.31活动过期) -40 8 1-31 12 * node /scripts/jd_ms_redrain.js >> /scripts/logs/jd_ms_redrain.log 2>&1 -# 健康抽奖机(2020.12.31活动过期) -10 0 1-31 12 * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 -# 直播红包雨(2020.12.31活动过期) -1 0,20,9-23/2 15-31 12 * node /scripts/jd_live_redrain.js >> /scripts/logs/jd_live_redrain.log 2>&1 -# 京东金融打卡领年终奖(2020.12.31活动过期) -10 6 1-31 12 * node /scripts/jr_sign.js >> /scripts/logs/jr_sign.log 2>&1 -# 京东健康APP集汪汪卡瓜分百万红包(2021.1.6活动过期) -10 8 * * * node /scripts/jd_jdh.js >> /scripts/logs/jd_jdh.log 2>&1 -# crazyJoy自动每日任务 -10 7 * * * node /scripts/jd_crazy_joy.js >> /scripts/logs/jd_crazy_joy.log 2>&1 +# 健康抽奖机 +10 0 * * * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 ##############长期活动############## # 签到 -0 0,12,18 * * * cd /scripts && node jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 +0 0,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 +0,30 0 * * * node /scripts/jd_blueCoin.js >> /scripts/logs/jd_blueCoin.log 2>&1 # 摇京豆 0 0 * * * node /scripts/jd_club_lottery.js >> /scripts/logs/jd_club_lottery.log 2>&1 # 东东农场 @@ -71,11 +61,11 @@ # 十元街 36 8,18 * * * 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 +# 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 +0 0 * * * 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 # 京东直播(每日18豆) @@ -84,7 +74,11 @@ 10 11 * * * node /scripts/jd_jdzz.js >> /scripts/logs/jd_jdzz.log 2>&1 # 宠汪汪邀请助力 10 10,11 * * * node /scripts/jd_joy_run.js >> /scripts/logs/jd_joy_run.log 2>&1 -# 京东发现-看一看,看40个视频领80京豆(非常耗时) -13 11,14 * * * node /scripts/jd_watch.js >> /scripts/logs/jd_watch.log 2>&1 # 注销京东已开的店铺会员,不是注销京东plus会员,个别店铺无法注销 44 4 * * 6 node /scripts/jd_unbind.js >> /scripts/logs/jd_unbind.log 2>&1 +# crazyJoy自动每日任务 +10 7 * * * node /scripts/jd_crazy_joy.js >> /scripts/logs/jd_crazy_joy.log 2>&1 +# 京东汽车旅程赛点兑换金豆 +0 0 * * * node /scripts/jd_car_exchange.js >> /scripts/logs/jd_car_exchange.log 2>&1 +# 导到所有互助码 +47 7 * * * node /scripts/jd_get_share_code.js >> /scripts/logs/jd_get_share_code.log 2>&1 diff --git a/docker/default_task.sh b/docker/default_task.sh index caf4f6d..26da7f0 100644 --- a/docker/default_task.sh +++ b/docker/default_task.sh @@ -107,7 +107,7 @@ if [ $(grep -c "default_task.sh" $mergedListFile) -eq '0' ]; then echo "52 */1 * * * sh /scripts/docker/default_task.sh |ts >> /scripts/logs/default_task.log 2>&1" >>$mergedListFile fi -if [ $RANDOM_DELAY_MAX ];then +if [ $RANDOM_DELAY_MAX ]; then if [ $RANDOM_DELAY_MAX -ge 1 ]; then echo "已设置随机延迟为 $RANDOM_DELAY_MAX , 设置延迟任务中... " sed -i "/\(jd_bean_sign.js\|jd_blueCoin.js\|jd_joy_reward.js\|jd_joy_steal.js\|jd_joy_feedPets.js\)/!s/node/sleep \$((RANDOM % \$RANDOM_DELAY_MAX)); node/g" $mergedListFile @@ -116,6 +116,27 @@ else echo "未配置随即延迟对应的环境变量,故不设置延迟任务" fi +##增加自定义shell脚本 +if [ 0"$CUSTOM_SHELL_FILE" = "0" ]; then + echo "未配置自定shell脚本文件,跳过执行。" +else + if expr "$CUSTOM_SHELL_FILE" : 'http.*' &>/dev/null; then + echo "自定义shell脚本为远程脚本,开始下在自定义远程脚本。" + wget -O /scripts/docker/shell_script_mod.sh $CUSTOM_SHELL_FILE + echo "下载完成,开始执行..." + sh -x /scripts/docker/shell_script_mod.sh + echo "自定义远程shell脚本下载并执行结束。" + else + if [ !$CUSTOM_SHELL_FILE ]; then + echo "自定义shell脚本为docker挂载脚本文件,但是指定挂载文件不存在,跳过执行。" + else + echo "docker挂载的自定shell脚本,开始执行..." + sh -x $CUSTOM_SHELL_FILE + echo "docker挂载的自定shell脚本,执行结束。" + fi + fi +fi + echo "加载最新的定时任务文件..." crontab $mergedListFile diff --git a/githubAction.md b/githubAction.md index c730ea0..415242e 100644 --- a/githubAction.md +++ b/githubAction.md @@ -118,9 +118,9 @@ Apple京东自营旗舰店 100&100&iPhone12&Apple京东自营旗舰店 ``` -#### 关于脚本推送通知(微信server酱推送通知,bark app推送通知,telegram机器人推送通知,钉钉机器人推送通知,iGot聚合推送) +#### 关于脚本推送通知频率 - > 如果你填写了上面五种推送通知方式中的某一个通知所需secret,那么脚本通知情况如下: + > 如果你填写了推送通知方式中的某一种通知所需环境变量,那么脚本通知情况如下: > 目前默认只有jd_fruit.js,jd_pet.js,jd_bean_sign.js,jd_818.js四个脚本每次运行后都通知 diff --git a/iCloud.md b/iCloud.md deleted file mode 100644 index 4066d16..0000000 --- a/iCloud.md +++ /dev/null @@ -1,154 +0,0 @@ -## 1.安装 Node.js 环境 - -[下载地址](https://nodejs.org/zh-tw/download/ ) - -根据自己的操作系统下载 - -傻瓜式安装,一直下一步即可。 - - - -## 2.下载源码 - -![BclSld.png](https://s1.ax1x.com/2020/11/04/BclSld.png) - -点击红框处下载压缩包 - -## 3.安装依赖、增加入口文件、增加cookie - -压缩包解压后进入项目文件夹 - -- Windows 用户按住 **shift** 点击右键,点击 **在此处打开命令窗口** -- Mac 用户通过终端,自行进入该文件夹 - -在命令行内输入 `npm i `,等待运行完成。 - -此时,项目文件夹内会多出一个 `node_modules`文件夹 - - **增加入口文件** - -方案一:同一个仓库下同一个时间,执行多个脚本 - -在项目文件夹内新建 `index.js` - -编辑文件 - -```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') //这里写你想要的脚本 -} - -``` -此时,同一时间点下,会同时执行多个脚本,触发器触发后,index.js文件中require()下的所有脚本都会被执行 - -**优点**:同一时间下可以同时执行多个脚本,适合脚本种类少的repository,对脚本数量少的repository推荐使用此方案
**缺点**:多个脚本不同时间点运行无法满足 - -方案二:同一个仓库下不同的时间点,分别执行不同的脚本(类似GitHub Action执行机制) - -在项目文件夹内新建 `index.js` - -编辑文件 - -```javascript -'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`) - } -} - -``` - -此时触发管理按照下图中进行设置,附加信息选择“是”,内容填写需要传递执行的具体脚本文件名,以回车键换行。触发器触发后,附加信息栏内的脚本会被执行,设置多个不同时间点的触发器达到类似GitHub Action的效果 - -**优点**:可以满足个性化需求,同一个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文件中使用,同一个仓库下,二者只能选择其一。
-Ⅱ感谢[issues#115](https://github.com/lxk0301/jd_scripts/issues/115)中的解决方案,目前云函数连续测试已经可以规避热启动问题了。
-Ⅲ在确保完全按照本教程设置的情况下测试云函数运行情况,对于部分人运行日志中出现某些脚本运行失败其他正常,并且错误提示带有strict字样的,请自行删除index.js中的```'use strict';```,再做测试
- - **增加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' -] -``` - - - -## 4.上传至腾讯云 - -[腾讯云函数地址]( https://console.cloud.tencent.com/scf/index ) - -编写函数 - -登录后,点击管理控制台 - -单击左侧导航栏**函数服务**,进入“函数服务”页面。 -在页面上方选择一个地域,最好选择离你常用地区近点的,不至于导致账号异常。单击**新建**。如下图所示: - -![iCloud1](./icon/iCloud1.png) - -在“新建函数”页面填写函数基础信息,单击**下一步**。如下图所示: - -![iCloud2](./icon/iCloud2.png) - -**函数名称**:可以自定义,比如为jd。
**运行环境**:选择 “Nodejs 12.16”。
**创建方式**:选择 “空白函数”。 - -确保环境为Nodejs 12.16,执行方法改为:index.main_handler,提交方式建议选本地文件夹,然后从GitHub项目克隆Zip压缩包,解压成文件夹,然后点击这个上传把文件夹上传进来(记得node_modules文件夹一并上传或者将node_modules文件夹上传到“层”,之后选择“函数管理”-“层管理”绑定上传好的层),完了后点击下面的高级设置。 - -![iCloud3](./icon/iCloud3.png) - -内存用不了太大,64MB就够了(64M内存,免费时长6,400,000秒,内存与免费时长大致关系可以参看云函数官方说明),超时时间改为最大的900秒,然后点击最下面的完成。 - -![iCloud4](./icon/iCloud4.png) - -## 5.设置触发器 - -点击刚创建的函数 - -![BcGa8O.png](https://s1.ax1x.com/2020/11/04/BcGa8O.png) - -点击如图所示 - -![BcGvM4.png](https://s1.ax1x.com/2020/11/04/BcGvM4.png) - -创建触发器 - -![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/jdCookie.js b/jdCookie.js index 4eb2bb7..0dcadb2 100644 --- a/jdCookie.js +++ b/jdCookie.js @@ -15,19 +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]; } - 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`) } +CookieJDs = [...new Set(CookieJDs.filter(item => item !== "" && item !== null && item !== undefined))] +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`) for (let i = 0; i < CookieJDs.length; i++) { const index = (i + 1 === 1) ? '' : (i + 1); - exports['CookieJD' + index] = CookieJDs[i]; + exports['CookieJD' + index] = CookieJDs[i].trim(); } diff --git a/jdDreamFactoryShareCodes.js b/jdDreamFactoryShareCodes.js index 6114855..8092924 100644 --- a/jdDreamFactoryShareCodes.js +++ b/jdDreamFactoryShareCodes.js @@ -11,7 +11,7 @@ let shareCodes = [ 'V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=@Bo-jnVs_m9uBvbRzraXcSA==@-OvElMzqeyeGBWazWYjI1Q==',//账号一的好友shareCode,不同好友中间用@符号隔开 '1uzRU5HkaUgvy0AB5Q9VUg==@PDPM257r_KuQhil2Y7koNw==@-OvElMzqeyeGBWazWYjI1Q==',//账号二的好友shareCode,不同好友中间用@符号隔开 ] -// 判断github action里面是否有东东萌宠互助码 +// 判断github action里面是否有京喜工厂互助码 if (process.env.DREAM_FACTORY_SHARE_CODES) { if (process.env.DREAM_FACTORY_SHARE_CODES.indexOf('&') > -1) { console.log(`您的互助码选择的是用&隔开\n`) @@ -28,4 +28,4 @@ if (process.env.DREAM_FACTORY_SHARE_CODES) { 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/jdFruitShareCodes.js b/jdFruitShareCodes.js index 4ddbd3d..d06c92d 100644 --- a/jdFruitShareCodes.js +++ b/jdFruitShareCodes.js @@ -1,5 +1,5 @@ /* -水果互助码 +东东农场互助码 此文件为Node.js专用。其他用户请忽略 支持京东N个账号 */ @@ -11,7 +11,7 @@ let FruitShareCodes = [ '0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3@6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@56db8e7bc5874668ba7d5195230d067a',//账号一的好友shareCode,不同好友中间用@符号隔开 '6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@9c52670d52ad4e1a812f894563c746ea@8175509d82504e96828afc8b1bbb9cb3',//账号二的好友shareCode,不同好友中间用@符号隔开 ] -// 判断github action里面是否有水果互助码 +// 判断github action里面是否有东东农场互助码 if (process.env.FRUITSHARECODES) { if (process.env.FRUITSHARECODES.indexOf('&') > -1) { console.log(`您的东东农场互助码选择的是用&隔开\n`) diff --git a/jdPlantBeanShareCodes.js b/jdPlantBeanShareCodes.js index 3894909..faba2b6 100644 --- a/jdPlantBeanShareCodes.js +++ b/jdPlantBeanShareCodes.js @@ -11,7 +11,7 @@ let PlantBeanShareCodes = [ '66j4yt3ebl5ierjljoszp7e4izzbzaqhi5k2unz2afwlyqsgnasq@olmijoxgmjutyrsovl2xalt2tbtfmg6sqldcb3q@e7lhibzb3zek27amgsvywffxx7hxgtzstrk2lba@olmijoxgmjutyx55upqaqxrblt7f3h26dgj2riy',//账号一的好友shareCode,不同好友中间用@符号隔开 '4npkonnsy7xi3p6pjfxg6ct5gll42gmvnz7zgoy@6dygkptofggtp6ffhbowku3xgu@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy@mlrdw3aw26j3wgzjipsxgonaoyr2evrdsifsziy',//账号二的好友shareCode,不同好友中间用@符号隔开 ] -// 判断github action里面是否有东东萌宠互助码 +// 判断github action里面是否有种豆得豆互助码 if (process.env.PLANT_BEAN_SHARECODES) { if (process.env.PLANT_BEAN_SHARECODES.indexOf('&') > -1) { console.log(`您的种豆互助码选择的是用&隔开\n`) @@ -28,4 +28,4 @@ if (process.env.PLANT_BEAN_SHARECODES) { for (let i = 0; i < PlantBeanShareCodes.length; i++) { const index = (i + 1 === 1) ? '' : (i + 1); exports['PlantBeanShareCodes' + index] = PlantBeanShareCodes[i]; -} \ No newline at end of file +} diff --git a/jd_bean_home.js b/jd_bean_home.js index a4109d7..666ad74 100644 --- a/jd_bean_home.js +++ b/jd_bean_home.js @@ -111,11 +111,63 @@ const JD_API_HOST = 'https://api.m.jd.com/'; }) async function jdBeanHome() { + $.doneState = false + // for (let i = 0; i < 3; ++i) { + // await doTask2() + // await $.wait(1000) + // if ($.doneState) break + // } + do { + await doTask2() + await $.wait(3000) + } while (!$.doneState) + await $.wait(1000) + await award("feeds") + await $.wait(1000) await getUserInfo() + await $.wait(1000) await getTaskList() await showMsg(); } +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; +} +function doTask2() { + return new Promise(resolve => { + const body = {"awardFlag": false, "skuId": `${getRandomInt(10000000,20000000)}`, "source": "feeds", "type": '1'}; + $.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.code === '0' && data.data){ + console.log(`任务完成进度:${data.data.taskProgress} / ${data.data.taskThreshold}`) + if(data.data.taskProgress === data.data.taskThreshold) + $.doneState = true + } else if (data.code === '0' && data.errorCode === 'HT201') { + $.doneState = true + } else { + //HT304风控用户 + $.doneState = true + console.log(`做任务异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + function getAuthorShareCode() { return new Promise(resolve => { $.get({url: "https://gitee.com/shylocks/updateTeam/raw/main/jd_bean_home",headers:{ @@ -164,18 +216,20 @@ function getUserInfo() { } else { if (safeGet(data)) { data = JSON.parse(data); - $.actId = data.data.jklInfo.keyId - let {shareCode, groupCode} = data.data - if (!shareCode) { - console.log(`未获取到助力码,去开团`) - await hitGroup() - } else { - console.log(shareCode, groupCode) - // 去做逛会场任务 - if (data.data.beanActivityVisitVenue.taskStatus === '0') { - await help(shareCode, groupCode, 1) + if(data.data.jklInfo) { + $.actId = data.data.jklInfo.keyId + let {shareCode, groupCode} = data.data + if (!shareCode) { + console.log(`未获取到助力码,去开团`) + await hitGroup() + } else { + console.log(shareCode, groupCode) + // 去做逛会场任务 + if (data.data.beanActivityVisitVenue.taskStatus === '0') { + await help(shareCode, groupCode, 1) + } + $.newShareCodes.push([shareCode, groupCode]) } - $.newShareCodes.push([shareCode, groupCode]) } } } @@ -328,9 +382,9 @@ function receiveTask(itemId = "zddd", type = "3") { } -function award() { +function award(source="home") { return new Promise(resolve => { - const body = {"awardFlag": true, "source": "home"}; + const body = {"awardFlag": true, "source": source}; $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { try { if (err) { diff --git a/jd_bean_sign.js b/jd_bean_sign.js index accf599..bf57c6d 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-12-21 +更新时间:2021-1-7 从 github @ruicky改写而来 version v0.0.1 create by ruicky @@ -17,6 +17,7 @@ const download = require('download'); let resultPath = "./result.txt"; let JD_DailyBonusPath = "./JD_DailyBonus.js"; let outPutUrl = './'; +let NodeSet = 'CookieSet.json'; let cookiesArr = [], cookie = ''; if ($.isNode()) { @@ -75,7 +76,7 @@ async function execSign() { 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.BARK_PUSH || 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); @@ -130,6 +131,7 @@ async function downFile () { async function changeFile (content) { console.log(`开始替换变量`) let newContent = content.replace(/var Key = ''/, `var Key = '${cookie}'`); + newContent = newContent.replace(/const NodeSet = 'CookieSet.json'/, `const NodeSet = '${NodeSet}'`) if (process.env.JD_BEAN_STOP && process.env.JD_BEAN_STOP !== '0') { newContent = newContent.replace(/var stop = 0/, `var stop = ${process.env.JD_BEAN_STOP * 1}`); } @@ -219,6 +221,7 @@ function requireConfig() { resultPath = err ? '/tmp/result.txt' : resultPath; JD_DailyBonusPath = err ? '/tmp/JD_DailyBonus.js' : JD_DailyBonusPath; outPutUrl = err ? '/tmp/' : outPutUrl; + NodeSet = err ? '/tmp/CookieSet.json' : NodeSet; resolve() }); }) diff --git a/jd_car_exchange.js b/jd_car_exchange.js new file mode 100644 index 0000000..c203e2d --- /dev/null +++ b/jd_car_exchange.js @@ -0,0 +1,194 @@ +/* +京东汽车兑换,500赛点兑换500京豆 +长期活动 + +活动入口 +京东APP:首页👉京东汽车兑换👉屏幕右中部,车主福利 +活动网页地址:https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html#/journey + +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东汽车兑换 +0 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange, tag=京东汽车兑换, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange, tag=京东汽车兑换 + +===============Surge================= +京东汽车兑换 = type=cron,cronexp="0 0 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange + +============小火箭========= +京东汽车兑换 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car_exchange, cronexpr="0 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 { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = jsonParse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => item !== "" && item !== null && item !== undefined); +} +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 j = 0; j < 20; ++j) + 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; + console.log(`京东账号${$.index} ${$.UserName}`) + $.isLogin = true; + $.nickName = ''; + message = ''; + await jdCar(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdCar() { + await exchange() +} + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function exchange() { + return new Promise(resolve => { + $.post(taskUrl('v1/user/exchange/bean'), (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + console.log(`兑换结果:${JSON.stringify(data)}`) + } + } + } 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", + 'activityid': '39443aee3ff74fcb806a6f755240d127', + 'origin': 'https://h5.m.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 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; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// 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_crazy_joy.js b/jd_crazy_joy.js index f85bb81..f1d1f5d 100644 --- a/jd_crazy_joy.js +++ b/jd_crazy_joy.js @@ -16,10 +16,10 @@ crazyJoy任务 cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js,tag=crazyJoy任务 ===============Surge================= -crazyJoy任务 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js +crazyJoy任务 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js ============小火箭========= -crazyJoy任务 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, cronexpr="10 * * * *", timeout=200, enable=true +crazyJoy任务 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, cronexpr="10 7 * * *", timeout=200, enable=true */ @@ -36,7 +36,7 @@ const inviteCodes = [ 'EdLPh8A6X5G1iWXu-uPYfA==@0gUO7F7N-4HVDh9mdQC2hg==@fUJTgR9z26fXdQgTvt_bgqt9zd5YaBeE@nCQQXQHKGjPCb7jkd8q2U-aCTjZMxL3s@2boGLV7TonMex8-nrT6EGat9zd5YaBeE', 'EdLPh8A6X5G1iWXu-uPYfA==@0gUO7F7N-4HVDh9mdQC2hg==@fUJTgR9z26fXdQgTvt_bgqt9zd5YaBeE@nCQQXQHKGjPCb7jkd8q2U-aCTjZMxL3s@2boGLV7TonMex8-nrT6EGat9zd5YaBeE' ]; -const randomCount = 5; +const randomCount = $.isNode() ? 10 : 5; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { @@ -175,7 +175,8 @@ if ($.isNode()) { return; } await requireConfig(); - $.nextCode = "EdLPh8A6X5G1iWXu-uPYfA==" + $.nextCode = ["EdLPh8A6X5G1iWXu-uPYfA==", "nCQQXQHKGjPCb7jkd8q2U-aCTjZMxL3s"]; + $.nextCode = $.nextCode[randomNumber(0, $.nextCode.length)]; $.selfCodes = [] for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { @@ -184,6 +185,8 @@ if ($.isNode()) { $.index = i + 1; $.isLogin = true; $.nickName = ''; + message = ''; + $.GROWTH_REWARD_BEAN = 0;//解锁等级奖励的京豆 await TotalBean(); console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); if (!$.isLogin) { @@ -258,22 +261,26 @@ async function jdCrazyJoy() { $.bean = 0 await getUserInfo($.nextCode) await doSign() - // 帮助作者 + // 助力好友 await helpFriends() await doTasks() + await getGrowthReward();//领取解锁的等级奖励 await getCoin() await getUserBean() - console.log(`当前信息:${$.bean} 京豆,${$.coin} 金币`) if ( applyJdBean!==0 && applyJdBean<=$.bean){ await $.wait(1000) console.log(`检测您打开了自动兑换开关,去兑换京豆`) await doApplyJdBean(applyJdBean) } + await showMsg(); } async function doTasks() { await getTaskInfo() for (let j = 0; j < $.taskList.length; ++j) { - let task = $.taskList[j] + let task = $.taskList[j]; + if (task['taskTypeId'] === 102) { + message += `${task.taskTitle}:${task['doneTimes']}/${task.ext.count}\n`; + } if (task.status === 0 && task.taskTypeId === 103) for (let i = task.doneTimes; i < task.ext.count; ++i) { await doTask(task.taskId) @@ -294,10 +301,12 @@ function doApplyJdBean(bean = 1000) { } else { if (safeGet(data)) { data = JSON.parse(data); - if (data.success) + if (data.success) { console.log(`兑换${bean}京豆成功`) - else + message += `兑换京豆:${bean}京豆成功\n`; + } else { console.log(`兑换${bean}京豆失败,错误信息:${data.resultTips||data.message}`) + } } } } catch (e) { @@ -323,6 +332,7 @@ function getUserInfo(code = "EdLPh8A6X5G1iWXu-uPYfA==") { console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${data.data.userInviteCode}`) $.selfCodes.push(data.data.userInviteCode) $.nextCode = data.data.userInviteCode + message += `${data.data['nickName']}:${data.data['userTopLevelJoyId']}级JOY\n`; } else console.log(`用户信息获取失败`) @@ -359,7 +369,7 @@ function getTaskInfo() { if (safeGet(data)) { data = JSON.parse(data); if (data.success && data.data && data.data.length) { - $.taskList = data.data + $.taskList = data.data; } else { console.log(`任务信息获取失败`) } @@ -495,7 +505,13 @@ function helpFriend(code) { } else { if (safeGet(data)) { data = JSON.parse(data); - console.log(data.resultTips) + if (data['resultCode'] ==='0') { + console.log(`助力结果:${JSON.stringify(data)}`); + } else if (data['resultCode'] === '2000402') { + console.log(data.resultTips) + } else { + console.log(`助力异常:${JSON.stringify(data)}`); + } } } } catch (e) { @@ -542,8 +558,9 @@ function getCoin() { } else { if (safeGet(data)) { data = JSON.parse(data); - if (data.data && data.data.totalCoinAmount) - $.coin = data.data.totalCoinAmount + if (data.data && data.data.totalCoinAmount) { + $.coin = data.data.totalCoinAmount; + } } } } catch (e) { @@ -554,8 +571,71 @@ function getCoin() { }) }) } - - +//领取解锁等级奖励(京豆) +function getGrowthReward() { + return new Promise(async resolve => { + const body = { "paramData":{"eventType":"GROWTH_REWARD"} }; + $.get(taskUrl('crazyJoy_event_getGrowthAndSceneState', JSON.stringify(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['resultCode'] === '0') { + if (data.data) { + for (let item of data.data) { + if (item.status === 1) { + if (item.eventRecordId) await obtainAward(item.eventRecordId); + } + } + if ($.GROWTH_REWARD_BEAN > 0) { + message += `解锁等级奖励:获得${$.GROWTH_REWARD_BEAN}京豆\n`; + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function obtainAward(eventRecordId) { + return new Promise(async resolve => { + const body = {"eventType": "GROWTH_REWARD", eventRecordId}; + $.get(taskUrl('crazyJoy_event_obtainAward', JSON.stringify(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['resultCode'] === '0') { + $.GROWTH_REWARD_BEAN += data.data['beans']; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function showMsg() { + return new Promise(async resolve => { + message += `当前信息:${$.bean}京豆,${$.coin}金币` + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`) + resolve() + }) +} function taskUrl(functionId, body = '') { let t = Date.now().toString().substr(0, 10) let e = body || "" @@ -586,7 +666,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } @@ -719,5 +799,13 @@ function jsonParse(str) { } } } +/** + * 生成随机数字 + * @param {number} min 最小值(包含) + * @param {number} max 最大值(不包含) + */ +function randomNumber(min = 0, max = 100) { + return Math.min(Math.floor(min + Math.random() * (max - min)), max); +} // 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_crazy_joy_coin.js b/jd_crazy_joy_coin.js index 00f394b..8824b85 100644 --- a/jd_crazy_joy_coin.js +++ b/jd_crazy_joy_coin.js @@ -204,6 +204,12 @@ async function jdJxStory() { await $.wait(1000) await getJoyShop() await $.wait(1000) + if ($.joyIds && $.joyIds.length > 0) { + $.log('当前JOY分布情况') + $.log(`\n${$.joyIds[0]} ${$.joyIds[1]} ${$.joyIds[2]} ${$.joyIds[3]}`) + $.log(`${$.joyIds[4]} ${$.joyIds[5]} ${$.joyIds[6]} ${$.joyIds[7]}`) + $.log(`${$.joyIds[8]} ${$.joyIds[9]} ${$.joyIds[10]} ${$.joyIds[11]}\n`) + } for (let i = 0; i < $.joyIds.length; ++i) { if (!$.canBuy) { $.log(`金币不足,跳过购买`) @@ -280,8 +286,14 @@ function getJoyShop() { data = JSON.parse(data); if (data.success && data.data && data.data.shop) { const shop = data.data.shop.filter(vo => vo.status === 1) || [] - $.buyJoyLevel = shop.length ? shop[shop.length - 1]['joyId'] : 1 - $.cost = shop.length ? shop[shop.length - 1]['coins'] : Infinity + $.buyJoyLevel = shop.length ? shop[shop.length - 1]['joyId'] : 1;//可购买的最大等级 + if ($.isNode() && process.env.BUY_JOY_LEVEL) { + $.log(`当前可购买的最高JOY等级为${$.buyJoyLevel}级\n`) + $.buyJoyLevel = (process.env.BUY_JOY_LEVEL * 1) > $.buyJoyLevel ? $.buyJoyLevel : process.env.BUY_JOY_LEVEL * 1; + $.cost = shop[$.buyJoyLevel - 1]['coins'] + } else { + $.cost = shop.length ? shop[shop.length - 1]['coins'] : Infinity + } } } } catch (e) { @@ -412,12 +424,17 @@ function getCoin() { if (data.data && data.data.tryMoneyJoyBeans) { console.log(`分红狗生效中,预计获得 ${data.data.tryMoneyJoyBeans} 京豆奖励`) } - if (data.data && data.data.totalCoinAmount) - $.coin = data.data.totalCoinAmount + if (data.data && data.data.totalCoinAmount) { + $.coin = data.data.totalCoinAmount; + } else { + $.coin = `获取当前金币数量失败` + } if (data.data && data.data.luckyBoxRecordId) { await openBox('LUCKY_BOX_DROP',data.data.luckyBoxRecordId) - } else - $.log(`产出金币信息获取失败`) + } + if (data.data) { + $.log(`此次在线收益:获得 ${data.data['coins']} 金币`) + } } } } catch (e) { @@ -430,7 +447,6 @@ function getCoin() { } function openBox(eventType = 'LUCKY_BOX_DROP', boxId) { - console.log(`openBox:${eventType}`) let body = { eventType, "eventRecordId": boxId} return new Promise(async resolve => { $.get(taskUrl('crazyJoy_event_getVideoAdvert', JSON.stringify(body)), async (err, resp, data) => { diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index ba26199..713a46f 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -1,6 +1,6 @@ /* 京东京喜工厂 -更新时间:2020-12-07 +更新时间:2020-12-27 活动入口 :京东APP->游戏与互动->查看更多->京喜工厂 或者: 京东APP首页搜索 "玩一玩" ,造物工厂即可 @@ -31,10 +31,10 @@ 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 = `6S9y4sJUfA2vPQP6TLdVIQ==`; +let tuanActiveId = `6S9y4sJUfA2vPQP6TLdVIQ==`; 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==", '-OvElMzqeyeGBWazWYjI1Q==', 'GFwo6PntxDHH95ZRzZ5uAg==']; +const inviteCodes = ['V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=@0WtCMPNq7jekehT6d3AbFw==', 'PDPM257r_KuQhil2Y7koNw==', "gB99tYLjvPcEFloDgamoBw==", '-OvElMzqeyeGBWazWYjI1Q==', 'GFwo6PntxDHH95ZRzZ5uAg==']; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { @@ -565,7 +565,12 @@ function userInfo() { // $.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->游戏与互动->查看更多->京喜工厂 选择商品`); + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); + if (nowTimes.getHours() % 12 === 0) { + //如按每小时运行一次,则此处将一天推送2次提醒 + $.msg($.name, '提醒⏰', `京东账号${$.index}[${$.nickName}]京喜工厂未选择商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选择商品`); + if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index}[${$.nickName}]京喜工厂未选择商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选择商品`) + } } } } else { @@ -1013,17 +1018,19 @@ function CreateTuan() { }) } async function joinLeaderTuan() { - await updateTuanIds(); - if (!$.tuanIdS) await updateTuanIdsCDN('https://gitee.com/lxk0301/updateTeam/raw/master/jd_updateFactoryTuanId.json'); - if (!$.tuanIdS) await updateTuanIdsCDN('https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_updateFactoryTuanId.json'); - for (let tuanId of $.tuanIdS.tuanIds) { - if (!tuanId) continue - await JoinTuan(tuanId); + if ($.tuanIdS && $.tuanIdS.tuanIds) { + for (let tuanId of $.tuanIdS.tuanIds) { + if (!tuanId) continue + await JoinTuan(tuanId); + } } + $.tuanIdS = null; if (!$.tuanIdS) await updateTuanIdsCDN('https://gitee.com/shylocks/updateTeam/raw/main/jd_updateFactoryTuanId.json'); - for (let tuanId of $.tuanIdS.tuanIds) { - if (!tuanId) continue - await JoinTuan(tuanId); + if ($.tuanIdS && $.tuanIdS.tuanIds) { + for (let tuanId of $.tuanIdS.tuanIds) { + if (!tuanId) continue + await JoinTuan(tuanId); + } } } function JoinTuan(tuanId) { @@ -1248,17 +1255,17 @@ async function exchangeProNotify() { // 一:在兑换超时这一天(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 }) + if ($.isNode()) 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 }) + if ($.isNode()) 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 }) + if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请重新选择商品生产\n【兑换截止时间】${$.exchangeEndTime}`, { url: jxOpenUrl }) } } } @@ -1298,7 +1305,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } @@ -1333,8 +1340,15 @@ function shareCodesFormat() { }) } function requireConfig() { - return new Promise(resolve => { + return new Promise(async resolve => { + await updateTuanIdsCDN('https://gitee.com/lxk0301/updateTeam/raw/master/jd_updateFactoryTuanId.json'); + if (!$.tuanIdS) await updateTuanIds(); + if (!$.tuanIdS) await updateTuanIdsCDN('https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_updateFactoryTuanId.json'); + if ($.tuanIdS && $.tuanIdS.tuanActiveId) { + tuanActiveId = $.tuanIdS.tuanActiveId; + } console.log(`开始获取${$.name}配置文件\n`); + console.log(`tuanActiveId: ${tuanActiveId}`) //Node.js用户请在jdCookie.js处填写京东ck; const shareCodes = $.isNode() ? require('./jdDreamFactoryShareCodes.js') : ''; console.log(`共${cookiesArr.length}个京东账号\n`); diff --git a/jd_fruit.js b/jd_fruit.js index 4f2eaa5..0b4b3ba 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-12-15 +更新时间:2021-1-5 东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -29,9 +29,9 @@ let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify, n //下面给出两个账号的填写示例(iOS只支持2个京东账号) let shareCodes = [ // 这个列表填入你要助力的好友的shareCode //账号一的好友shareCode,不同好友的shareCode中间用@符号隔开 - '0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3@6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@56db8e7bc5874668ba7d5195230d067a', + '0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3@6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@56db8e7bc5874668ba7d5195230d067a@', //账号二的好友shareCode,不同好友的shareCode中间用@符号隔开 - 'b1638a774d054a05a30a17d3b4d364b8@f92cb56c6a1349f5a35f0372aa041ea0@9c52670d52ad4e1a812f894563c746ea@8175509d82504e96828afc8b1bbb9cb3', + 'b1638a774d054a05a30a17d3b4d364b8@f92cb56c6a1349f5a35f0372aa041ea0@9c52670d52ad4e1a812f894563c746ea@8175509d82504e96828afc8b1bbb9cb3@2673c3777d4443829b2a635059953a28', ] let message = '', subTitle = '', option = {}, isFruitFinished = false; const retainWater = 100;//保留水滴大于多少g,默认100g; @@ -279,7 +279,7 @@ async function doTenWater() { } if (isFruitFinished) { option['open-url'] = urlSchema; - $.msg($.name, `【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取`, '请去京东APP或微信小程序查看\n点击弹窗即达', option); + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); $.done(); if ($.isNode()) { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); @@ -403,7 +403,7 @@ async function doTenWaterAgain() { } if (isFruitFinished) { option['open-url'] = urlSchema; - $.msg($.name, `【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取`, '请去京东APP或微信小程序查看\n点击弹窗即达', option); + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); $.done(); if ($.isNode()) { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); @@ -431,7 +431,7 @@ async function doTenWaterAgain() { } if (isFruitFinished) { option['open-url'] = urlSchema; - $.msg($.name, `【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取`, '请去京东APP或微信小程序查看\n点击弹窗即达', option); + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); $.done(); if ($.isNode()) { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); @@ -771,24 +771,31 @@ async function clockInIn() { // async function getAwardInviteFriend() { 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`); + console.log(`查询好友列表数据:${JSON.stringify($.friendList)}\n`) + if ($.friendList) { + console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); + console.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`); + if ($.friendList.friends && $.friendList.friends.length > 0) { + 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('开始领取邀请好友的奖励'); - await awardInviteFriendForFarm(); - console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); + await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 + if ($.friendList.inviteFriendCount > 0) { + if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { + console.log('开始领取邀请好友的奖励'); + await awardInviteFriendForFarm(); + console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); + } + } else { + console.log('今日未邀请过好友') } } else { - console.log('今日未邀请过好友') + console.log(`查询好友列表失败\n`); } } //给好友浇水 @@ -1239,7 +1246,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取个${randomCount}码放到您固定的互助码后面`) + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_get_share_code.js b/jd_get_share_code.js new file mode 100644 index 0000000..8a6e1ed --- /dev/null +++ b/jd_get_share_code.js @@ -0,0 +1,699 @@ +/* +一键获取我仓库所有需要互助类脚本的互助码(邀请码)(其中京东赚赚jd_jdzz.js如果今天达到5人助力则不能提取互助码) +没必要设置(cron)定时执行,需要的时候,自己手动执行一次即可 + +更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#获取互助码 +20 13 * * 6 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js, tag=获取互助码, enabled=true + +================Loon============== +[Script] +cron "20 13 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js, tag=获取互助码 + +===============Surge================= +获取互助码 = type=cron,cronexp="20 13 * * 6",wake-system=1,timeout=120,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js + +============小火箭========= +获取互助码 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js, cronexpr="20 13 * * 6", timeout=200, enable=true + */ +const $ = new Env("获取互助码"); +const JD_API_HOST = "https://api.m.jd.com/client.action"; +let cookiesArr = [], cookie = '', message; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +!function (n) { + "use strict"; + + function t(n, t) { + var r = (65535 & n) + (65535 & t); + return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r + } + + function r(n, t) { + return n << t | n >>> 32 - t + } + + function e(n, e, o, u, c, f) { + return t(r(t(t(e, n), t(u, f)), c), o) + } + + function o(n, t, r, o, u, c, f) { + return e(t & r | ~t & o, n, t, u, c, f) + } + + function u(n, t, r, o, u, c, f) { + return e(t & o | r & ~o, n, t, u, c, f) + } + + function c(n, t, r, o, u, c, f) { + return e(t ^ r ^ o, n, t, u, c, f) + } + + function f(n, t, r, o, u, c, f) { + return e(r ^ (t | ~o), n, t, u, c, f) + } + + function i(n, r) { + n[r >> 5] |= 128 << r % 32, + n[14 + (r + 64 >>> 9 << 4)] = r; + var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; + for (e = 0; e < n.length; e += 16) + i = l, + a = g, + d = v, + h = m, + g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), + l = t(l, i), + g = t(g, a), + v = t(v, d), + m = t(m, h); + return [l, g, v, m] + } + + function a(n) { + var t, r = "", e = 32 * n.length; + for (t = 0; t < e; t += 8) + r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); + return r + } + + function d(n) { + var t, r = []; + for (r[(n.length >> 2) - 1] = void 0, + t = 0; t < r.length; t += 1) + r[t] = 0; + var e = 8 * n.length; + for (t = 0; t < e; t += 8) + r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; + return r + } + + function h(n) { + return a(i(d(n), 8 * n.length)) + } + + function l(n, t) { + var r, e, o = d(n), u = [], c = []; + for (u[15] = c[15] = void 0, + o.length > 16 && (o = i(o, 8 * n.length)), + r = 0; r < 16; r += 1) + u[r] = 909522486 ^ o[r], + c[r] = 1549556828 ^ o[r]; + return e = i(u.concat(d(t)), 512 + 8 * t.length), + a(i(c.concat(e), 640)) + } + + function g(n) { + var t, r, e = ""; + for (r = 0; r < n.length; r += 1) + t = n.charCodeAt(r), + e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); + return e + } + + function v(n) { + return unescape(encodeURIComponent(n)) + } + + function m(n) { + return h(v(n)) + } + + function p(n) { + return g(m(n)) + } + + function s(n, t) { + return l(v(n), v(t)) + } + + function C(n, t) { + return g(s(n, t)) + } + + function A(n, t, r) { + return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) + } + + $.md5 = A +}(this); +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = jsonParse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => item !== "" && item !== null && item !== undefined); +} +!(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(); + if (!$.isLogin) { + continue + } + await getShareCode() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +function getJdFactory() { + return new Promise(resolve => { + $.post( + taskPostUrl("jdfactory_getTaskDetail", {}, "jdfactory_getTaskDetail"), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`$东东工厂 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( + `【账号${$.index}(${$.nickName || $.UserName})东东工厂】${item.assistTaskDetailVo.taskToken}` + ); + } + }); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + } + ); + }) +} +function getJxFactory(){ + const JX_API_HOST = "https://m.jingxi.com"; + + function JXGC_taskurl(functionId, body = "") { + return { + url: `${JX_API_HOST}/dreamfactory/${functionId}?zone=dream_factory&${body}&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now()}`, + headers: { + Cookie: cookie, + Host: "m.jingxi.com", + Accept: "*/*", + Connection: "keep-alive", + "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", + }, + }; + } + + return new Promise(resolve => { + $.get( + JXGC_taskurl( + "userinfo/GetUserInfo", + `pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=` + ), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`惊喜工厂 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; + console.log(`【账号${$.index}(${$.nickName || $.UserName})惊喜工厂】${data.user.encryptPin}`); + } + } else { + $.unActive = false; //标记是否开启了京喜活动或者选购了商品进行生产 + if (!data.factoryList) { + console.log( + `【提示】京东账号${$.index}[${$.nickName}]京喜工厂活动未开始请手动去京东APP->游戏与互动->查看更多->京喜工厂 开启活动` + ); + } else if (data.factoryList && !data.productionList) { + console.log( + `【提示】京东账号${$.index}[${$.nickName}]京喜工厂未选购商品请手动去京东APP->游戏与互动->查看更多->京喜工厂 选购` + ); + } + } + } else { + console.log(`GetUserInfo异常:${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + } + ); + }) +} +function getJdPet(){ + const JDPet_API_HOST = "https://api.m.jd.com/client.action"; + + function jdPet_Url(function_id, body = {}) { + body["version"] = 2; + body["channel"] = "app"; + return { + url: `${JDPet_API_HOST}?functionId=${function_id}`, + body: `body=${escape( + JSON.stringify(body) + )}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`, + 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", + Host: "api.m.jd.com", + "Content-Type": "application/x-www-form-urlencoded", + }, + }; + } + return new Promise(resolve => { + $.post(jdPet_Url("initPetTown"), async (err, resp, data) => { + try { + if (err) { + console.log("东东萌宠: API查询请求失败 ‼️‼️"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + data = JSON.parse(data); + + const initPetTownRes = data; + + message = `【京东账号${$.index}】${$.nickName}`; + if ( + initPetTownRes.code === "0" && + initPetTownRes.resultCode === "0" && + initPetTownRes.message === "success" + ) { + $.petInfo = initPetTownRes.result; + if ($.petInfo.userStatus === 0) { + /*console.log( + `【提示】京东账号${$.index}${$.nickName}萌宠活动未开启请手动去京东APP开启活动入口:我的->游戏与互动->查看更多开启` + );*/ + return; + } + + console.log( + `【账号${$.index}(${$.nickName || $.UserName})京东萌宠】${$.petInfo.shareCode}` + ); + + } else if (initPetTownRes.code === "0") { + console.log(`初始化萌宠失败: ${initPetTownRes.message}`); + } else { + console.log("shit"); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }) +} +async function getJdZZ() { + const JDZZ_API_HOST = "https://api.m.jd.com/client.action"; + + function getUserInfo() { + return new Promise(resolve => { + $.get(taskZZUrl("interactIndex"), 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.shareTaskRes) { + console.log(`【账号${$.index}(${$.nickName || $.UserName})京东赚赚】${data.data.shareTaskRes.itemId}`); + } else { + //console.log(`已满5人助力,暂时看不到您的京东赚赚好友助力码`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) + } + + function taskZZUrl(functionId, body = {}) { + return { + url: `${JDZZ_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.1.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Connection': 'keep-alive', + 'Content-Type': 'application/json', + 'Referer': 'http://wq.jd.com/wxapp/pages/hd-interaction/index/index', + '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', + } + } + } + + await getUserInfo() +} +async function getPlantBean() { + const JDplant_API_HOST = "https://api.m.jd.com/client.action"; + + async function plantBeanIndex() { + $.plantBeanIndexResult = await plant_request("plantBeanIndex"); //plantBeanIndexBody + } + + function plant_request(function_id, body = {}) { + return new Promise(async (resolve) => { + $.post(plant_taskUrl(function_id, body), (err, resp, data) => { + try { + if (err) { + console.log("种豆得豆: API查询请求失败 ‼️‼️"); + console.log(`function_id:${function_id}`); + $.logErr(err); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }); + } + + function plant_taskUrl(function_id, body) { + body["version"] = "9.0.0.1"; + body["monitor_source"] = "plant_app_plant_index"; + body["monitor_refer"] = ""; + return { + url: JDplant_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 getParam(url, name) { + const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); + const r = url.match(reg); + if (r != null) return unescape(r[2]); + return null; + } + + async function jdPlantBean() { + await plantBeanIndex(); + // console.log(plantBeanIndexResult.data.taskList); + if ($.plantBeanIndexResult.code === "0") { + const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl; + $.myPlantUuid = getParam(shareUrl, "plantUuid"); + console.log(`【账号${$.index}(${$.nickName || $.UserName})种豆得豆】${$.myPlantUuid}`); + + } else { + console.log( + `种豆得豆-初始失败: ${JSON.stringify($.plantBeanIndexResult)}` + ); + } + } + + await jdPlantBean(); +} +async function getJDFruit() { + async function initForFarm() { + return new Promise((resolve) => { + const option = { + url: `${JD_API_HOST}?functionId=initForFarm`, + body: `body=${escape( + JSON.stringify({version: 4}) + )}&appid=wh5&clientVersion=9.1.0`, + headers: { + accept: "*/*", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cache-control": "no-cache", + cookie: cookie, + origin: "https://home.m.jd.com", + pragma: "no-cache", + referer: "https://home.m.jd.com/myJd/newhome.action", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "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", + }, + }; + $.post(option, (err, resp, data) => { + try { + if (err) { + console.log("东东农场: API查询请求失败 ‼️‼️"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.farmInfo = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + async function jdFruit() { + await initForFarm(); + if ($.farmInfo.farmUserPro) { + console.log( + `【账号${$.index}(${$.nickName || $.UserName})京东农场】${$.farmInfo.farmUserPro.shareCode}` + ); + + } else { + /*console.log( + `初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify( + $.farmInfo + )}` + );*/ + } + } + + await jdFruit(); +} +async function getJoy(){ + function taskUrl(functionId, body = '') { + let t = Date.now().toString().substr(0, 10) + let e = body || "" + e = $.md5("aDvScBv$gGQvrXfva8dG!ZC@DA70Y%lX" + e + t) + e = e + Number(t).toString(16) + return { + url: `${JD_API_HOST}?uts=${e}&appid=crazy_joy&functionId=${functionId}&body=${escape(body)}&t=${t}`, + 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-cn', + 'Referer': 'https://crazy-joy.jd.com/', + 'origin': 'https://crazy-joy.jd.com', + 'Accept-Encoding': 'gzip, deflate, br', + } + } + } + let body = {"paramData": {}} + return new Promise(async resolve => { + $.get(taskUrl('crazyJoy_user_gameState', JSON.stringify(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.success && data.data && data.data.userInviteCode) { + console.log(`【账号${$.index}(${$.nickName || $.UserName})crazyJoy】${data.data.userInviteCode}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function getShareCode() { + console.log(`======账号${$.index}开始======`) + await getJdFactory() + await getJxFactory() + await getJdPet() + await getPlantBean() + await getJDFruit() + await getJdZZ() + await getJoy() + console.log(`======账号${$.index}结束======\n`) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +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 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} +// 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_health.js b/jd_health.js index ee4ffe9..b05005d 100644 --- a/jd_health.js +++ b/jd_health.js @@ -265,7 +265,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_jdfactory.js b/jd_jdfactory.js index b1d7a45..546b710 100644 --- a/jd_jdfactory.js +++ b/jd_jdfactory.js @@ -2,7 +2,7 @@ * @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 + * @Last Modified time: 2020-12-26 22:58:02 */ /* 东东工厂,不是京喜工厂 @@ -108,8 +108,8 @@ function showMsg() { } else { $.log(`京东账号${$.index}${$.nickName}\n${message}`); } - if (new Date().getHours() === 23) { - $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + if (new Date().getHours() === 12) { + $.msg($.name, '', `${message}`); } resolve() }) @@ -181,6 +181,7 @@ async function algorithm() { } } else { console.log(`\n此账号${$.index}${$.nickName}暂未选择商品\n`); + message += `京东账号${$.index} ${$.nickName}\n`; message += `已选商品:暂无\n`; message += `心仪商品:${wantProduct ? wantProduct : '暂无'}\n`; if (wantProduct) { @@ -216,17 +217,17 @@ async function algorithm() { } else { console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称\n`); await jdfactory_getProductList(true); - message += `当前剩余最多商品:${$.canMakeList[0].name}\n`; - message += `兑换所需电量:${$.canMakeList[0].fullScore}\n`; + message += `当前剩余最多商品:${$.canMakeList[0] && $.canMakeList[0].name}\n`; + message += `兑换所需电量:${$.canMakeList[0] && $.canMakeList[0].fullScore}\n`; message += `您当前总电量:${$.batteryValue * 1}\n`; - if ($.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0].fullScore) { + if ($.canMakeList[0] && $.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0] && $.canMakeList[0].fullScore) { let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); if (new Date(nowTimes).getHours() === 12) { - $.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'}); - if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n${message}【满足】兑换${$.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0] && [0].name}所需总电量:${$.canMakeList[0] && $.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'}); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`); } } else { - console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0].name}所需的 ${$.canMakeList[0].fullScore}电量\n`) + console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0] && $.canMakeList[0].name}所需的 ${$.canMakeList[0] && $.canMakeList[0].fullScore}电量\n`) } } } @@ -254,98 +255,100 @@ async function helpFriends() { } } 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) { - //可以做此任务 + if ($.taskVos && $.taskVos.length > 0) { + for (let item of $.taskVos) { + if (item.taskType === 1) { + //关注店铺任务 + if (item.status === 1) { console.log(`准备做此任务:${item.taskName}`); - await jdfactory_collectScore(item.threeMealInfoVos[0].taskToken); - } else if (item.threeMealInfoVos[0].status === 0) { - console.log(`${item.taskName} 任务已错过时间`) + for (let task of item.followShopVo) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + 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 === 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 === 13) { - //每日打卡 - if (item.status === 1) { - console.log(`准备做此任务:${item.taskName}`); - await jdfactory_collectScore(item.simpleRecordInfoVo.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 === 14) { - //好友助力 - if (item.status === 1) { - console.log(`准备做此任务:${item.taskName}`); - // await jdfactory_collectScore(item.simpleRecordInfoVo.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 === 23) { - //从数码电器首页进入 - if (item.status === 1) { - console.log(`准备做此任务:${item.taskName}`); - await queryVkComponent(); - await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); - } else { - 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}已完成`); + } } } } @@ -353,7 +356,8 @@ async function doTask() { //领取做完任务的奖励 function jdfactory_collectScore(taskToken) { - return new Promise(resolve => { + return new Promise(async resolve => { + await $.wait(1000); $.post(taskPostUrl("jdfactory_collectScore", { taskToken }, "jdfactory_collectScore"), async (err, resp, data) => { try { if (err) { @@ -532,17 +536,20 @@ function jdfactory_getProductList(flag = false) { if (safeGet(data)) { data = JSON.parse(data); if (data.data.bizCode === 0) { + $.canMakeList = []; $.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) { + if ($.canMakeList && $.canMakeList.length > 0) { + $.canMakeList.sort(sortCouponCount); + console.log(`商品名称 可选状态 剩余量`) for (let item of $.canMakeList) { - if (item.name.indexOf(wantProduct) > -1 && item.couponCount > 0 && item.sellOut === 0) { - await jdfactory_makeProduct(item.skuId); - break + 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 + } } } } @@ -621,7 +628,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_jdzz.js b/jd_jdzz.js index f5da363..5ea61aa 100644 --- a/jd_jdzz.js +++ b/jd_jdzz.js @@ -343,7 +343,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_joy.js b/jd_joy.js index 302fc97..1a204b2 100644 --- a/jd_joy.js +++ b/jd_joy.js @@ -164,16 +164,15 @@ async function joinTwoPeopleRun() { if (petRaceResult === 'unreceive') { console.log('今日参赛的比赛已经结束,现在领取奖励'); await getWinCoin(); - let winCoin = 0, teamLimitCount = 2; + let winCoin = 0; if ($.getWinCoinRes && $.getWinCoinRes.success) { winCoin = $.getWinCoinRes.data.winCoin; - teamLimitCount = $.getWinCoinRes.data.teamLimitCount; } await receiveJoyRunAward(); console.log(`领取赛跑奖励结果:${JSON.stringify($.receiveJoyRunAwardRes)}`) if ($.receiveJoyRunAwardRes.success) { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n太棒了,${teamLimitCount}人赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`); - if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index}${$.nickName}\n${teamLimitCount}人赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`) + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n太棒了,${$.name}赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`); + if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index}${$.nickName}\n太棒了,${$.name}赛跑取得获胜\n恭喜您已获得${winCoin}积分奖励`) } } if (petRaceResult === 'participate') { @@ -476,16 +475,16 @@ function followShop(shopId) { } function enterRoom() { return new Promise(resolve => { - const url = `${weAppUrl}/enterRoom?reqSource=weapp`; + const url = `${weAppUrl}/enterRoom/h5?reqSource=weapp&invitePin=&openId=`; const host = `draw.jdfcloud.com`; const reqSource = 'weapp'; - $.get(taskUrl(url, host, reqSource), (err, resp, data) => { + $.post({...taskUrl(url, host, reqSource),body:'{}'}, (err, resp, data) => { try { if (err) { console.log('\n京东宠汪汪: API查询请求失败 ‼️‼️') } else { // console.log('JSON.parse(data)', JSON.parse(data)) - + $.roomData = JSON.parse(data); console.log(`现有狗粮: ${$.roomData.data.petFood}\n`) diff --git a/jd_joy_reward.js b/jd_joy_reward.js index 6878e76..76ed0fe 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -1,6 +1,6 @@ /* 宠汪汪积分兑换奖品脚本, 目前脚本只兑换京豆,兑换京豆成功,才会发出通知提示,其他情况不通知。 -更新时间:2020-12-23 +更新时间:2021-1-6 兑换规则:一个账号一天只能兑换一次京豆。 兑换奖品成功后才会有系统弹窗通知 每日京豆库存会在0:00、8:00、16:00更新,经测试发现中午12:00也会有补发京豆。 @@ -60,6 +60,7 @@ const JD_API_HOST = 'https://jdjoy.jd.com'; } continue } + console.log(`本地时间与京东服务器时间差(毫秒):${await get_diff_time()}`); await joyReward(); // $.msg($.name, '兑换脚本暂不能使用', `请停止使用,等待后期更新\n如果新版本兑换您有兑换机会,请抓包兑换\n再把抓包数据发送telegram用户@lxk0301`); } @@ -126,9 +127,9 @@ async function joyReward() { ctrTemp = `${jdNotify}` === 'false'; } if (ctrTemp) { - $.msg($.name, `兑换${giftValue}京豆成功`, `【京东账号${$.index}】${$.nickName}\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【${giftValue}京豆】兑换成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】 ${$.nickName}\n【兑换${giftValue}京豆】成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】 ${$.nickName}\n【${giftValue}京豆】兑换成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); } } // if ($.isNode()) { @@ -273,6 +274,35 @@ function TotalBean() { }) }) } +function getJDServerTime() { + return new Promise(resolve => { + // console.log(Date.now()) + $.get({url: "https://a.jd.com//ajax/queryServerData.html",headers:{ + "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 Edg/87.0.4280.88" + }}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} 获取京东服务器时间失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.jdTime = data['serverTime']; + // console.log(data['serverTime']); + // console.log(data['serverTime'] - Date.now()) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve($.jdTime); + } + }) + }) +} +async function get_diff_time() { + // console.log(`本机时间戳 ${Date.now()}`) + // console.log(`京东服务器时间戳 ${await getJDServerTime()}`) + return Date.now() - await getJDServerTime(); +} function jsonParse(str) { if (typeof str == "string") { try { diff --git a/jd_joy_run.js b/jd_joy_run.js index 2b18c1e..3e0e489 100644 --- a/jd_joy_run.js +++ b/jd_joy_run.js @@ -1,6 +1,6 @@ /** 宠汪汪邀请助力与赛跑助力脚本,感谢github@Zero-S1提供帮助 -更新时间:2020-12-16(宠汪汪助力更新Token的配置正则表达式已改) +更新时间:2021-1-7(宠汪汪助力更新Token的配置正则表达式已改) token时效很短,几个小时就失效了,闲麻烦的放弃就行 每天拿到token后,可一次性运行完毕即可。 @@ -41,7 +41,7 @@ const JD_BASE_API = `https://draw.jdfcloud.com//pet`; //下面给出好友邀请助力的示例填写规则 let invite_pins = ["jd_6cd93e613b0e5,被折叠的记忆33,jd_704a2e5e28a66,jd_45a6b5953b15b,zooooo58,jd_66f5cecc1efcd"]; //下面给出好友赛跑助力的示例填写规则 -let run_pins = ["被折叠的记忆33,jd_6cd93e613b0e5,jd_45a6b5953b15b,zooooo58,jd_66f5cecc1efcd,jd_sIhNpDXJehOr,jd_704a2e5e28a66"]; +let run_pins = ["被折叠的记忆33,jd_6cd93e613b0e5,jd_45a6b5953b15b,jd_66f5cecc1efcd,jd_sIhNpDXJehOr,jd_704a2e5e28a66,zooooo58"]; // $.LKYLToken = '76fe7794c475c18711e3b47185f114b5' || $.getdata('jdJoyRunToken'); // $.LKYLToken = $.getdata('jdJoyRunToken'); 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"]; @@ -245,37 +245,41 @@ async function invite(invite_pins) { for (let item of invite_pins.map(item => item.trim())) { console.log(`\n账号${$.index} [${UserName}] 开始给好友 [${item}] 进行邀请助力`) const data = await enterRoom(item); - if (!data.success && data.errorCode === 'B0001') { - console.log('京东Cookie失效'); - $.msg($.name, `【提示】京东cookie已失效`, `京东账号${$.index} ${UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); - $.jdLogin = false; - break - } else { - const { helpStatus } = data.data; - console.log(`helpStatus ${helpStatus}`) - if (helpStatus=== 'help_full') { - console.log(`您的邀请助力机会已耗尽\n`) - break; - } else if (helpStatus=== 'cannot_help') { - console.log(`已给该好友 ${item} 助力过或者此friendPin是你自己\n`) - continue; - } else if (helpStatus=== 'invite_full') { - console.log(`助力失败,该好友 ${item} 已经满3人给他助力了,无需您再次助力\n`) - continue; - } else if (helpStatus=== 'can_help') { - console.log(`开始给好友 ${item} 助力\n`) - const LKYL_DATA = await helpInviteFriend(item); - if (LKYL_DATA.errorCode === 'L0001' && !LKYL_DATA.success) { - console.log('来客有礼宠汪汪token失效'); - $.setdata('', 'jdJoyRunToken'); - $.msg($.name, '【提示】来客有礼token失效,请重新获取', "微信搜索'来客有礼'小程序\n点击底部的'发现'Tab\n即可获取Token") - $.LKYLLogin = false; + if (data) { + if (data.success) { + const { helpStatus } = data.data; + console.log(`helpStatus ${helpStatus}`) + if (helpStatus=== 'help_full') { + console.log(`您的邀请助力机会已耗尽\n`) + break; + } else if (helpStatus=== 'cannot_help') { + console.log(`已给该好友 ${item} 助力过或者此friendPin是你自己\n`) + continue; + } else if (helpStatus=== 'invite_full') { + console.log(`助力失败,该好友 ${item} 已经满3人给他助力了,无需您再次助力\n`) + continue; + } else if (helpStatus=== 'can_help') { + console.log(`开始给好友 ${item} 助力\n`) + const LKYL_DATA = await helpInviteFriend(item); + if (LKYL_DATA.errorCode === 'L0001' && !LKYL_DATA.success) { + console.log('来客有礼宠汪汪token失效'); + $.setdata('', 'jdJoyRunToken'); + $.msg($.name, '【提示】来客有礼token失效,请重新获取', "微信搜索'来客有礼'小程序\n点击底部的'发现'Tab\n即可获取Token") + $.LKYLLogin = false; + break + } else { + $.LKYLLogin = true; + } + } + $.jdLogin = true; + } else { + if (data.errorCode === 'B0001') { + console.log('京东Cookie失效'); + $.msg($.name, `【提示】京东cookie已失效`, `京东账号${$.index} ${UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + $.jdLogin = false; break - } else { - $.LKYLLogin = true; } } - $.jdLogin = true; } } // if ($.inviteReward > 0) { @@ -286,18 +290,20 @@ function enterRoom(invitePin) { return new Promise(resolve => { headers.Cookie = cookie; headers.LKYLToken = $.LKYLToken; + headers['Content-Type'] = "application/json"; const options = { - url: `${JD_BASE_API}/enterRoom?reqSource=weapp&invitePin=${encodeURI(invitePin)}`, + url: `${JD_BASE_API}/enterRoom/h5?reqSource=weapp&invitePin=${encodeURI(invitePin)}&inviteSource=task_invite&shareSource=weapp&inviteTimeStamp=${Date.now()}`, + body: '{}', headers } - $.get(options, (err, resp, data) => { + $.post(options, (err, resp, data) => { try { if (err) { - $.log('API请求失败') - $.logErr(JSON.stringify(err)); + $.log(`${$.name} API请求失败`) + $.log(JSON.stringify(err)) } else { - data = JSON.parse(data); // console.log('进入房间', data) + data = JSON.parse(data); } } catch (e) { $.logErr(e, resp) diff --git a/jd_pet.js b/jd_pet.js index 1446989..3586c92 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-30 +更新时间:2021-01-06 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -90,7 +90,7 @@ async function jdPet() { } if (!$.petInfo.goodsInfo) { $.msg($.name, '', `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`, { "open-url": "openapp.jdmoble://" }); - await notify.sendNotify(`${$.name} - ${$.index} - ${$.nickName}`, `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`); + if ($.isNode()) await notify.sendNotify(`${$.name} - ${$.index} - ${$.nickName}`, `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`); return } goodsUrl = $.petInfo.goodsInfo && $.petInfo.goodsInfo.goodsUrl; @@ -231,8 +231,10 @@ async function masterHelpInit() { if(!res.result.addedBonusFlag) { console.log("开始领取额外奖励"); let getHelpAddedBonusResult = await request('getHelpAddedBonus'); + if (getHelpAddedBonusResult.resultCode === '0') { + message += `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n`; + } console.log(`领取30g额外奖励结果:【${getHelpAddedBonusResult.message}】`); - message += `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n`; } else { console.log("已经领取过5好友助力额外奖励"); message += `【额外奖励】已领取\n`; @@ -261,6 +263,8 @@ async function masterHelpInit() { * 运行脚本时你自己的shareCode会在控制台输出, 可以将其分享给他人 */ async function slaveHelp() { + $.log(`\n因1.6日好友助力功能下线。故暂时屏蔽\n`) + return let helpPeoples = ''; for (let code of newShareCodes) { console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${code}`); @@ -281,7 +285,7 @@ async function slaveHelp() { console.log(`助力其他情况:${JSON.stringify(response)}`); } } else { - console.log(`助理好友结果: ${response.message}`); + console.log(`助力好友结果: ${response.message}`); } } if (helpPeoples && helpPeoples.length > 0) { @@ -442,7 +446,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取个${randomCount}码放到您固定的互助码后面`) + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } @@ -467,7 +471,9 @@ function shareCodesFormat() { const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); newShareCodes = shareCodes[tempIndex].split('@'); } - const readShareCodeRes = await readShareCode(); + //因好友助力功能下线。故暂时屏蔽 + // const readShareCodeRes = await readShareCode(); + const readShareCodeRes = null; if (readShareCodeRes && readShareCodeRes.code === 200) { newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; } diff --git a/jd_plantBean.js b/jd_plantBean.js index 9497a07..c573903 100644 --- a/jd_plantBean.js +++ b/jd_plantBean.js @@ -1,6 +1,6 @@ /* 种豆得豆 脚本更新地址:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_plantBean.js -更新时间:2020-11-04 +更新时间:2020-12-31 已支持IOS京东双账号,云端N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js 注:会自动关注任务中的店铺跟商品,介意者勿使用。 @@ -161,14 +161,27 @@ async function stealFriendWater() { return } if ($.stealFriendList.data && $.stealFriendList.data.friendInfoList && $.stealFriendList.data.friendInfoList.length > 0) { + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); for (let item of $.stealFriendList.data.friendInfoList) { - if (item.nutrCount >= 3) { - // console.log(`可以偷的好友的信息::${JSON.stringify(item)}`); - console.log(`可以偷的好友的信息paradiseUuid::${JSON.stringify(item.paradiseUuid)}`); - await collectUserNutr(item.paradiseUuid); - console.log(`偷取好友营养液情况:${JSON.stringify($.stealFriendRes)}`) - if ($.stealFriendRes.code === '0') { - console.log(`偷取好友营养液成功`) + if (new Date(nowTimes).getHours() === 20) { + if (item.nutrCount >= 2) { + // console.log(`可以偷的好友的信息::${JSON.stringify(item)}`); + console.log(`可以偷的好友的信息paradiseUuid::${JSON.stringify(item.paradiseUuid)}`); + await collectUserNutr(item.paradiseUuid); + console.log(`偷取好友营养液情况:${JSON.stringify($.stealFriendRes)}`) + if ($.stealFriendRes.code === '0') { + console.log(`偷取好友营养液成功`) + } + } + } else { + if (item.nutrCount >= 3) { + // console.log(`可以偷的好友的信息::${JSON.stringify(item)}`); + console.log(`可以偷的好友的信息paradiseUuid::${JSON.stringify(item.paradiseUuid)}`); + await collectUserNutr(item.paradiseUuid); + console.log(`偷取好友营养液情况:${JSON.stringify($.stealFriendRes)}`) + if ($.stealFriendRes.code === '0') { + console.log(`偷取好友营养液成功`) + } } } } @@ -508,7 +521,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取个${randomCount}码放到您固定的互助码后面`) + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_small_home.js b/jd_small_home.js index 096519e..46a21a0 100644 --- a/jd_small_home.js +++ b/jd_small_home.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-11-12 11:42:12 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-12-23 14:27:20 + * @Last Modified time: 2021-1-4 14:27:20 */ /* 东东小窝 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js @@ -274,25 +274,27 @@ function queryFurnituresCenterList() { if (safeGet(data)) { data = JSON.parse(data); if (data.head.code === 200) { - let { buy, list } = data.body; - $.canBuyList = []; - list.map((item, index) => { - if (buy.some((buyItem) => buyItem === item.id)) return - $.canBuyList.push(item); - }) - $.canBuyList.sort(sortByjdBeanNum); - if ($.canBuyList[0].needWoB <= $.woB) { - await furnituresCenterPurchase($.canBuyList[0].id, $.canBuyList[0].jdBeanNum); - } else { - console.log(`\n兑换${$.canBuyList[0].jdBeanNum}京豆失败:当前wo币${$.woB}不够兑换所需的${$.canBuyList[0].needWoB}WO币`) - message += `【装饰领京豆】兑换${$.canBuyList[0].jdBeanNum}京豆失败,原因:WO币不够\n`; + if (data.body) { + let { buy, list } = data.body; + $.canBuyList = []; + list.map((item, index) => { + if (buy.some((buyItem) => buyItem === item.id)) return + $.canBuyList.push(item); + }) + $.canBuyList.sort(sortByjdBeanNum); + if ($.canBuyList[0].needWoB <= $.woB) { + await furnituresCenterPurchase($.canBuyList[0].id, $.canBuyList[0].jdBeanNum); + } else { + console.log(`\n兑换${$.canBuyList[0].jdBeanNum}京豆失败:当前wo币${$.woB}不够兑换所需的${$.canBuyList[0].needWoB}WO币`) + message += `【装饰领京豆】兑换${$.canBuyList[0].jdBeanNum}京豆失败,原因:WO币不够\n`; + } + // for (let canBuyItem of $.canBuyList) { + // if (canBuyItem.needWoB <= $.woB) { + // await furnituresCenterPurchase(canBuyItem.id, canBuyItem.jdBeanNum); + // break + // } + // } } - // for (let canBuyItem of $.canBuyList) { - // if (canBuyItem.needWoB <= $.woB) { - // await furnituresCenterPurchase(canBuyItem.id, canBuyItem.jdBeanNum); - // break - // } - // } } } } diff --git a/jd_speed.js b/jd_speed.js index f9da4a9..905cecc 100644 --- a/jd_speed.js +++ b/jd_speed.js @@ -1,12 +1,11 @@ /* 京东天天加速链接:https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_speed.js -更新时间:2020-11-03 +更新时间:2020-12-25 支持京东双账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js 每天4京豆,再小的苍蝇也是肉 从 https://github.com/Zero-S1/JD_tools/blob/master/JD_speed.py 改写来的 建议3小时运行一次,打卡时间间隔是6小时 -注:如果使用Node.js, 需自行安装'crypto-js,got,http-server,tough-cookie'模块. 例: npm install crypto-js http-server tough-cookie got --save */ // quantumultx // [task_local] @@ -67,6 +66,7 @@ const JD_API_HOST = 'https://api.m.jd.com/' message = ''; subTitle = ''; await jDSpeedUp(); + await getMemBerList(); await showMsg(); } } @@ -85,7 +85,7 @@ function showMsg() { $.log(`\n${message}\n`); } } -function jDSpeedUp(sourceId, doubleKey) { +function jDSpeedUp(sourceId) { return new Promise((resolve) => { let body = {"source": "game"}; if (sourceId) { @@ -109,6 +109,7 @@ function jDSpeedUp(sourceId, doubleKey) { try { if (err) { console.log('京东天天-加速: 签到接口请求失败 ‼️‼️'); + console.log(`${JSON.stringify(err)}`) } else { if (data) { let res = JSON.parse(data); @@ -184,6 +185,7 @@ function spaceEventList() { try { if (err) { console.log("\n京东天天-加速: 查询太空特殊事件请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) } else { if (data) { const cc = JSON.parse(data); @@ -244,6 +246,7 @@ function spaceEventHandleEvent(spaceEventList) { try { if (err) { console.log("\n京东天天-加速: 处理太空特殊事件请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) } else { if (data) { const cc = JSON.parse(data); @@ -291,6 +294,7 @@ function energyPropList() { try { if (err) { console.log("\n京东天天-加速: 查询道具请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) } else { if (data) { const cc = JSON.parse(data) @@ -346,6 +350,7 @@ function receiveEnergyProp(CID) { try { if (error) { console.log("\n天天加速-领取道具请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) } else { if (data) { const cc = JSON.parse(data) @@ -390,6 +395,7 @@ function energyPropUsaleList(EID) { try { if (error) { console.log("\n天天加速-查询道具ID请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) } else { if (data) { const cc = JSON.parse(data); @@ -450,6 +456,7 @@ function useEnergy(PropID) { try { if (error) { console.log("\n天天加速-使用燃料请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) } else { if (data) { const cc = JSON.parse(data); @@ -476,6 +483,84 @@ function useEnergy(PropID) { } }) } +function getMemBerList() { + return new Promise((resolve) => { + const body = { "source": "game", "status": 0}; + const spaceEventUrl = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=member_list&body=${escape(JSON.stringify(body))}&_t=${Date.now()}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/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") + } + } + $.get(spaceEventUrl, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && data.success) { + $.getRewardBeans = 0; + console.log(`\n检查是否可领虫洞京豆奖励`) + $.memBerList = data.data.filter(item => item['taskStatus'] === 2); + if ($.memBerList && $.memBerList.length > 0) { + for (let uuids of $.memBerList) { + await getReward(uuids['uuid']); + } + if ($.getRewardBeans > 0) { + $.msg(`${$.name}`, '', `京东账号${$.index} ${$.nickName}\n虫洞任务:获得${$.getRewardBeans}京豆`); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${$.nickName}\n虫洞任务:获得${$.getRewardBeans}京豆`) + } + } else { + console.log(`暂无可领取的虫洞京豆奖励`) + } + } + } + } + } catch (e) { + $.msg("天天加速-查询太空特殊事件" + e.name + "‼️", JSON.stringify(e), e.message) + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +function getReward(uuid) { + return new Promise((resolve) => { + const body = { "source": "game", uuid}; + const options = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=member_getReward&body=${escape(JSON.stringify(body))}&_t=${Date.now()}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/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") + } + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && data.success) { + $.getRewardBeans += data.data.beans; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} function TotalBean() { return new Promise(async resolve => { const options = { @@ -527,5 +612,16 @@ function jsonParse(str) { } } } +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)} \ No newline at end of file diff --git a/jd_superMarket.js b/jd_superMarket.js index abbf54a..75438e0 100644 --- a/jd_superMarket.js +++ b/jd_superMarket.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-08-16 18:54:16 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-11-24 08:22:37 + * @Last Modified time: 2021-1-17 18:22:37 */ /* 东东超市(活动入口:京东APP-》首页-》京东超市-》底部东东超市) @@ -153,11 +153,11 @@ async function doDailyTask() { const res = await smtgObtainShopTaskPrize(item.taskId); console.log(`\n领取做完任务的奖励${JSON.stringify(res)}\n`) } + //做任务 if ((item.type === 1 || item.type === 11) && item.taskStatus === 0) { // 分享任务 const res = await smtgDoShopTask(item.taskId); console.log(`${item.subTitle}结果${JSON.stringify(res)}`) - } if (item.type === 2) { //逛会场 @@ -177,6 +177,15 @@ async function doDailyTask() { console.log(`${item.subTitle}结果${JSON.stringify(res)}`); } } + if (item.type === 9) { + //开卡领蓝币任务 + if (item.taskStatus === 0) { + console.log('开始开卡领蓝币任务') + const itemId = item.content[item.type].itemId; + const res = await smtgDoShopTask(item.taskId, itemId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`); + } + } if (item.type === 10) { //关注店铺 if (item.taskStatus === 0) { @@ -253,7 +262,7 @@ function receiveBlueCoin(timeout = 0) { //每日签到 function smtgSign() { return new Promise((resolve) => { - $.get(taskUrl('smtg_sign'), async (err, resp, data) => { + $.get(taskUrl('smtg_sign', {"shareId":"QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ","channel":"4"}), async (err, resp, data) => { try { // console.log('ddd----ddd', data) if (err) { @@ -751,7 +760,8 @@ function updatePkActivityIdCDN(url = 'https://raw.fastgit.org/lxk0301/updateTeam function smtgDoShopTask(taskId, itemId) { return new Promise((resolve) => { const body = { - "taskId": taskId + "taskId": taskId, + "channel": "18" } if (itemId) { body.itemId = itemId; diff --git a/jd_syj.js b/jd_syj.js index cd6dabf..ea75fc2 100644 --- a/jd_syj.js +++ b/jd_syj.js @@ -2,7 +2,7 @@ * @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 + * @Last Modified time: 2021-1-1 16:58:02 */ /* 十元街脚本,一周签到下来可获得30京豆,一天任意时刻运行一次即可 @@ -93,7 +93,7 @@ function showMsg() { let signFlag = 0; function userSignIn() { return new Promise(resolve => { - const body = {"activityId":"8d6845fe2e77425c82d5078d314d33c5","inviterId":"VMIQlLQqjQyjZokQmv5bIDgq011L0Ov8","channel":"MiniProgram"}; + const body = {"activityId":"ccd8067defcd4787871b7f0c96fcbf5c","inviterId":"","channel":"MiniProgram"}; $.get(taskUrl('userSignIn', body), async (err, resp, data) => { try { if (err) { @@ -122,6 +122,10 @@ function userSignIn() { signFlag ++; await userSignIn(); } + } else if (data.code === 66) { + //此处有时会遇到 服务器繁忙 导致签到失败,故重复三次签到 + $.log(`${$.name}签到失败:${data.msg}`); + message += `【签到】失败,${data.msg}`; } else { console.log(`异常:${JSON.stringify(data)}`) } diff --git a/jd_unbind.js b/jd_unbind.js index 0e618a0..65e5377 100644 --- a/jd_unbind.js +++ b/jd_unbind.js @@ -36,9 +36,9 @@ if ($.isNode()) { cookiesArr.reverse(); cookiesArr = cookiesArr.filter(item => item !== "" && item !== null && item !== undefined); } -const jdNotify = $.getdata('jdUnsubscribeNotify');//是否关闭通知,false打开通知推送,true关闭通知推送 -let cardPageSize = $.getdata('jdUnsubscribePageSize') || 200;// 运行一次取消多少个会员卡。数字0表示不注销任何会员卡 -let stopCards = $.getdata('jdUnsubscribeStopCards') || ['京东PLUS会员'];//遇到此会员卡不再进行注销 +const jdNotify = $.getdata('jdUnbindCardNotify');//是否关闭通知,false打开通知推送,true关闭通知推送 +let cardPageSize = 200;// 运行一次取消多少个会员卡。数字0表示不注销任何会员卡 +let stopCards = `京东PLUS会员`;//遇到此会员卡跳过注销,多个使用&分开 const JD_API_HOST = 'https://api.m.jd.com/'; !(async () => { if (!cookiesArr[0]) { @@ -220,24 +220,23 @@ function TotalBean() { } function requireConfig() { return new Promise(resolve => { - if ($.isNode() && process.env.UN_BIND_CARD_NUM) { - $.UN_BIND_NUM = process.env.UN_BIND_CARD_NUM - } - if ($.isNode() && process.env.UN_BIND_STOP_CARD) { - if (process.env.UN_BIND_STOP_CARD.indexOf('&') > -1) { - $.UN_BIND_STOP_CARD = process.env.UN_BIND_STOP_CARD.split('&'); - } else if (process.env.UN_BIND_STOP_CARD.indexOf('@') > -1) { - $.UN_BIND_STOP_CARD = process.env.UN_BIND_STOP_CARD.split('@'); - } else if (process.env.UN_BIND_STOP_CARD.indexOf('\n') > -1) { - $.UN_BIND_STOP_CARD = process.env.UN_BIND_STOP_CARD.split('\n'); - } else if (process.env.UN_BIND_STOP_CARD.indexOf('\\n') > -1) { - $.UN_BIND_STOP_CARD = process.env.UN_BIND_STOP_CARD.split('\\n'); + $.UN_BIND_NUM = $.isNode() ? (process.env.UN_BIND_CARD_NUM ? process.env.UN_BIND_CARD_NUM : cardPageSize) : ($.getdata('UN_BIND_CARD_NUM') ? $.getdata('UN_BIND_CARD_NUM') : cardPageSize); + $.UN_BIND_STOP_CARD = $.isNode() ? (process.env.UN_BIND_STOP_CARD ? process.env.UN_BIND_STOP_CARD : stopCards) : ($.getdata('UN_BIND_STOP_CARD') ? $.getdata('UN_BIND_STOP_CARD') : stopCards); + if ($.UN_BIND_STOP_CARD) { + if ($.UN_BIND_STOP_CARD.indexOf('&') > -1) { + $.UN_BIND_STOP_CARD = $.UN_BIND_STOP_CARD.split('&'); + } else if ($.UN_BIND_STOP_CARD.indexOf('@') > -1) { + $.UN_BIND_STOP_CARD = $.UN_BIND_STOP_CARD.split('@'); + } else if ($.UN_BIND_STOP_CARD.indexOf('\n') > -1) { + $.UN_BIND_STOP_CARD = $.UN_BIND_STOP_CARD.split('\n'); + } else if ($.UN_BIND_STOP_CARD.indexOf('\\n') > -1) { + $.UN_BIND_STOP_CARD = $.UN_BIND_STOP_CARD.split('\\n'); } else { - $.UN_BIND_STOP_CARD = process.env.UN_BIND_STOP_CARD.split(); + $.UN_BIND_STOP_CARD = $.UN_BIND_STOP_CARD.split(); } } - cardPageSize = $.UN_BIND_NUM || cardPageSize - stopCards = $.UN_BIND_STOP_CARD || stopCards + cardPageSize = $.UN_BIND_NUM; + stopCards = $.UN_BIND_STOP_CARD; resolve() }) } diff --git a/lxk0301.boxjs.json b/lxk0301.boxjs.json index 842a61d..dc9e0e5 100644 --- a/lxk0301.boxjs.json +++ b/lxk0301.boxjs.json @@ -664,6 +664,44 @@ "https://raw.githubusercontent.com/Orz-3/task/master/jd.png" ] }, + { + "id": "jd_unbind", + "name": "注销京东会员卡", + "keys": [ + "UN_BIND_CARD_NUM", + "UN_BIND_STOP_CARD" + ], + "settings": [ + { + "id": "jdUnbindCardNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "运行脚本时不发出系统弹窗通知" + }, + { + "id": "UN_BIND_CARD_NUM", + "name": "注销京东店铺会员卡的数量", + "val": 200, + "type": "number", + "desc": "运行一次脚本注销多少个店铺会员卡(默认200个,输入0表示不注销会员卡)" + }, + { + "id": "UN_BIND_STOP_CARD", + "name": "注销京东店铺会员卡(白名单)", + "val": "", + "type": "text", + "desc": "不想注销的店铺会员卡名称" + } + ], + "author": "@lxk0301", + "repo": "https://github.com/lxk0301/jd_scripts", + "script": "https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unsubscribe.js", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind.png" + ] + }, { "id": "jd_SuperMarket", "name": "京小超", diff --git a/sendNotify.js b/sendNotify.js index 6a20589..071c618 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-08-19 16:12:40 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-12-21 13:52:54 + * @Last Modified time: 2021-1-7 17:52:54 */ const querystring = require("querystring"); const $ = new Env(); @@ -48,6 +48,12 @@ let DD_BOT_SECRET = ''; //注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_KEY) let QYWX_KEY = ''; +// =======================================企业微信应用消息通知设置区域=========================================== +//此处填你企业微信应用消息的 值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236),依次填上corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id(见https://github.com/lxk0301/jd_scripts/issues/519) 注意用,号隔开,例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +//增加一个选择推送消息类型,用图文消息直接填写素材库图片id的值,用卡片消息就填写0(就是数字零) +//注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_AM) +let QYWX_AM = ''; + // =======================================iGot聚合推送通知设置区域=========================================== //此处填您iGot的信息(推送key,例如:https://push.hellyw.com/XXXXXXXX) //注:此处设置github action用户填写到Settings-Secrets里面(Name输入IGOT_PUSH_KEY) @@ -108,6 +114,10 @@ if (process.env.QYWX_KEY) { QYWX_KEY = process.env.QYWX_KEY; } +if (process.env.QYWX_AM) { + QYWX_AM = process.env.QYWX_AM; +} + if (process.env.IGOT_PUSH_KEY) { IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY } @@ -123,16 +133,21 @@ if (process.env.PUSH_PLUS_USER) { async function sendNotify(text, desp, params = {}) { //提供7种通知 - await serverNotify(text, desp);//微信server酱 - await pushPlusNotify(text, desp);//pushplus(推送加) + await Promise.all([ + serverNotify(text, desp),//微信server酱 + pushPlusNotify(text, desp)//pushplus(推送加) + ]) //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; - await BarkNotify(text, desp, params);//iOS Bark APP - await tgBotNotify(text, desp);//telegram 机器人 - await ddBotNotify(text, desp);//钉钉机器人 - await qywxBotNotify(text, desp); //企业微信机器人 - await iGotNotify(text, desp, params);//iGot - await CoolPush(text, desp);//QQ酷推 + await Promise.all([ + BarkNotify(text, desp, params),//iOS Bark APP + tgBotNotify(text, desp),//telegram 机器人 + ddBotNotify(text, desp),//钉钉机器人 + qywxBotNotify(text, desp), //企业微信机器人 + qywxamNotify(text, desp), //企业微信应用消息推送 + iGotNotify(text, desp, params),//iGot + CoolPush(text, desp)//QQ酷推 + ]) } function serverNotify(text, desp, timeout = 2100) { @@ -406,6 +421,93 @@ function qywxBotNotify(text, desp) { }); } +function qywxamNotify(text, desp) { + return new Promise(resolve => { + if (QYWX_AM) { + var QYWX_AM_AY = QYWX_AM.split(','); + const options_accesstoken = { + url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, + json: { + corpid:`${QYWX_AM_AY[0]}`, + corpsecret:`${QYWX_AM_AY[1]}`, + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + $.post(options_accesstoken, (err, resp, data) => { + html=desp.replace(/\n/g,"
") + var json = JSON.parse(data); + accesstoken = json.access_token; + const options_textcard = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser:`${QYWX_AM_AY[2]}`, + agentid:`${QYWX_AM_AY[3]}`, + msgtype: 'textcard', + textcard: { + title: `${text}`, + description: `${desp}`, + url: '127.0.0.1', + btntxt: '更多' + }, + safe:'0', + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + const options_mpnews = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser:`${QYWX_AM_AY[2]}`, + agentid:`${QYWX_AM_AY[3]}`, + msgtype: 'mpnews', + mpnews: { + articles: [ + { + title: `${text}`, + thumb_media_id: `${QYWX_AM_AY[4]}`, + author : `智能助手` , + content_source_url: ``, + content : `${html}`, + digest: `${desp}` + } + ] + }, + safe:'0', + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + $.post((QYWX_AM_AY[4]==0)?options_textcard:options_mpnews, (err, resp, data) => { + try { + if (err) { + console.log('企业微信应用消息发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('企业微信应用消息发送通知消息完成。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }); + } else { + console.log('您未提供企业微信应用消息推送所需的QYWX_AM,取消企业微信应用消息推送消息通知\n'); + resolve(); + } + }); +} + function iGotNotify(text, desp, params={}){ return new Promise(resolve => { if (IGOT_PUSH_KEY) { @@ -486,14 +588,15 @@ function pushPlusNotify(text, desp) { } }) } else { - console.log('\n您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n'); + console.log('您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n'); resolve() } }) } module.exports = { - sendNotify + sendNotify, + BARK_PUSH } // prettier-ignore function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),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}getScript(t){return new Promise(s=>{$.get({url:t},(t,e,i)=>s(i))})}runScript(t,s){return new Promise(e=>{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=s&&s.timeout?s.timeout:o;const[h,a]=i.split("@"),r={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":h,Accept:"*/*"}};$.post(r,(t,s,i)=>e(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),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;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),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),o=JSON.stringify(this.data);e?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(s,o):this.fs.writeFileSync(t,o)}}lodash_get(t,s,e){const i=s.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return e;return o}lodash_set(t,s,e){return Object(t)!==t?t:(Array.isArray(s)||(s=s.toString().match(/[^.[\]]+/g)||[]),s.slice(0,-1).reduce((t,e,i)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(s[i+1])>>0==+s[i+1]?[]:{},t)[s[s.length-1]]=e,t)}getdata(t){let s=this.getval(t);if(/^@/.test(t)){const[,e,i]=/^@(.*?)\.(.*?)$/.exec(t),o=e?this.getval(e):"";if(o)try{const t=JSON.parse(o);s=t?this.lodash_get(t,i,""):s}catch(t){s=""}}return s}setdata(t,s){let e=!1;if(/^@/.test(s)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(s),h=this.getval(i),a=i?"null"===h?null:h||"{}":"{}";try{const s=JSON.parse(a);this.lodash_set(s,o,t),e=this.setval(JSON.stringify(s),i)}catch(s){const h={};this.lodash_set(h,o,t),e=this.setval(JSON.stringify(h),i)}}else e=$.setval(t,s);return e}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,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||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,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t))}}time(t){let s={"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 e in s)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[e]:("00"+s[e]).substr((""+s[e]).length)));return t}msg(s=t,e="",i="",o){const h=t=>!t||!this.isLoon()&&this.isSurge()?t:"string"==typeof t?this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0:"object"==typeof t&&(t["open-url"]||t["media-url"])?this.isLoon()?t["open-url"]:this.isQuanX()?t:void 0:void 0;$.isMute||(this.isSurge()||this.isLoon()?$notification.post(s,e,i,h(o)):this.isQuanX()&&$notify(s,e,i,h(o))),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)} diff --git a/serverless.yml b/serverless.yml index 3a81ce0..0ec42ca 100644 --- a/serverless.yml +++ b/serverless.yml @@ -19,15 +19,15 @@ inputs: - 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 + argument: jd_bean_sign + - timer: #京小超兑换奖品 #摇京豆 #京东汽车 #京东汽车兑换 + parameters: + name: jd_blueCoin_jd_club_lottery_car_car_exchange + cronExpression: "0 0 0 * * * *" + enable: true + argument: jd_blueCoin&jd_club_lottery&jd_car&jd_car_exchange - timer: # 东东农场# 东东萌宠 parameters: name: jd_fruit_jd_pet @@ -46,12 +46,12 @@ inputs: cronExpression: "0 0 0-16/8,20 * * * *" enable: true argument: jd_joy_reward&jd_joy_steal&jd_necklace&jd_live - - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 #秒杀红包雨 #健康抽奖机 + - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 #健康抽奖机 parameters: - name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home_ms_redrain_health + name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home_health cronExpression: "0 10 0 * * * *" enable: true - argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home&jd_ms_redrain&jd_health + argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home&jd_health - timer: # 京东天天加速# 天天提鹅 parameters: name: jd_speed_jd_daily_egg @@ -64,18 +64,18 @@ inputs: cronExpression: "0 15 * * * * *" enable: true argument: jd_superMarket - - timer: #京豆变动通知 #疯狂的joy #京东排行榜 #领京豆额外奖励 #京东汽车 #京东健康APP + - timer: #京豆变动通知 #疯狂的joy #京东排行榜 #领京豆额外奖励 parameters: - name: bean_change_crazy_joy_rankingList_bean_home_car_jdh + name: bean_change_crazy_joy_rankingList_bean_home cronExpression: "0 30 7 * * * *" enable: true - argument: jd_bean_change&jd_crazy_joy&jd_rankingList&jd_bean_home&jd_car&jd_jdh - - timer: #金融养猪 #十元街 #京东快递 #发现-看一看 #京东赚赚 #金融打卡领年终奖 + argument: jd_bean_change&jd_crazy_joy&jd_rankingList&jd_bean_home&jd_car + - timer: #金融养猪 #十元街 #京东快递 #京东赚赚 parameters: - name: pigPet_syj_kd_watch_jdzz_jr_sign + name: pigPet_syj_kd_jdzz cronExpression: "0 3 1 * * * *" enable: true - argument: jd_pigPet&jd_syj&jd_kd&jd_watch&jd_jdzz&jr_sign + argument: jd_pigPet&jd_syj&jd_kd&jd_jdzz environment: # 环境变量 variables: # 环境变量对象 AAA: BBB # 不要删除,用来格式化对齐追加的变量的