diff --git a/script/boxjs.json b/script/boxjs.json index fe71ef19d..95662f189 100644 --- a/script/boxjs.json +++ b/script/boxjs.json @@ -6,18 +6,38 @@ "repo": "https://github.com/blackmatrix7/ios_rule_script", "apps": [ { - "id": "blackmatrix7.10010", - "name": "联通每日签到与抽奖", - "keys": ["unicom_user_cookie", "unicom_mobile", "unicom_encrypt_mobile", "city_code"], + "id": "blackmatrix7.bark", + "name": "Bark推送", + "keys": [ + "bark_url" + ], + "settings": [ + { + "id": "bark_url", + "name": "Bark推送URL", + "val": "", + "type": "input", + "placeholder": "https://api.day.app/xxxxxxxxxxxxxxxxxx/", + "autoGrow": true, + "desc": "填写Bark推送的链接,脚本通知将通过Bark推送" + } + ], "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/10010", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/10010.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/10010.png"], - "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/10010/unicom_signin.js" + "repo": "https://git.codecolor.cool/matrix/script/bilibili", + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/icon/matrix/dark/bark.jpg", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/icon/matrix/color/bark.jpg" + ] }, { "id": "blackmatrix7.bilibili", "name": "哔哩哔哩去广告", - "keys": ["bilibili_story_aid", "bilibili_feed_black", "bilibili_disable_index_story", "bilibili_enable_mall"], + "keys": [ + "bilibili_story_aid", + "bilibili_feed_black", + "bilibili_disable_index_story", + "bilibili_enable_mall" + ], "settings": [ { "id": "bilibili_feed_black", @@ -46,42 +66,41 @@ ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/bilibili", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/bilibili.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/bilibili.png"] - }, - { - "id": "blackmatrix7.didachuxing", - "name": "嘀嗒出行", - "keys": ["dida_cid", "dida_cookie", "dida_useragent", "dida_access_token"], - "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didachuxing", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/didachuxing/didachuxing.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/didachuxing/didachuxing.png"], - "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/didachuxing/didachuxing_plus.js" - }, - { - "id": "blackmatrix7.didichuxing", - "name": "滴滴出行", - "keys": ["didi_token", "didi_city_id", "didi_lottery_id", "didi_my_source_id", "didi_group_id", "didi_finance_channel_id", "didi_finance_activity_id"], - "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/didichuxing", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/didi.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/didi.png"], - "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/didichuxing/didi_checkin.js" + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/bilibili.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/bilibili.png" + ] }, { "id": "blackmatrix7.dingdong", "name": "叮咚买菜", - "keys": ["dingdongmaicai_checkin_cookie", "dingdongmaicai_checkin_body"], + "keys": [ + "dingdongmaicai_checkin_cookie", + "dingdongmaicai_checkin_body" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/dingdong", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong_checkin.js" }, { "id": "blackmatrix7.eleme", "name": "饿了么", - "keys": ["eleme_app_cookie", "eleme_app_longitude", "eleme_app_latitude"], + "keys": [ + "eleme_app_cookie", + "eleme_app_longitude", + "eleme_app_latitude", + "eleme_task_keywords" + ], "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/eleme", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/elem.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/elem.png"], + "repo": "https://git.codecolor.cool/matrix/script/eleme", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/elem.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/elem.png" + ], "scripts": [ { "name": "领取吃货豆", @@ -91,51 +110,155 @@ "name": "领取会员任务", "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js" } + ], + "settings": [ + { + "id": "eleme_app_cookie", + "name": "Cookie", + "val": "", + "type": "input", + "placeholder": "", + "autoGrow": true, + "desc": "填写获取的饿了么Cookie" + }, + { + "id": "eleme_app_longitude", + "name": "经度", + "val": "", + "type": "input", + "placeholder": "", + "autoGrow": true, + "desc": "填写抓包获取的饿了么经度" + }, + { + "id": "eleme_app_latitude", + "name": "纬度", + "val": "", + "type": "input", + "placeholder": "", + "autoGrow": true, + "desc": "填写抓包获取的饿了么纬度" + }, + { + "id": "eleme_task_keywords", + "name": "任务关键字", + "val": "美食外卖;", + "type": "input", + "placeholder": "多个关键词以;分隔,越靠前的关键词优先级越高", + "autoGrow": true, + "desc": "只领取含有关键字的任务" + }, + { + "id": "magicjs_loglevel", + "name": "日志等级", + "val": "INFO", + "type": "radios", + "items": [ + { + "key": "INFO", + "label": "INFO" + }, + { + "key": "WARNING", + "label": "WARNING" + }, + { + "key": "ERROR", + "label": "ERROR" + }, + { + "key": "CRITICAL", + "label": "CRITICAL" + }, + { + "key": "DEBUG", + "label": "DEBUG" + } + ], + "desc": "出现异常时请选择DEBUG提交日志" + } ] }, { "id": "blackmatrix7.famijia", "name": "Fa米家", - "keys": ["famijia_checkin_cookie", "famijia_device_id", "famijia_black_box"], + "keys": [ + "famijia_checkin_cookie", + "famijia_device_id", + "famijia_black_box" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/famijia", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/famijia/famijia_checkin.js" }, { "id": "blackmatrix7.luka", "name": "Luka阅读养成", - "keys": ["luka_checkin_cookie", "luka_signin_auth"], + "keys": [ + "luka_checkin_cookie", + "luka_signin_auth" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/luka", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/luka/luka.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/luka/luka.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/luka/luka.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/luka/luka.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/luka/luka_signin.js" }, { "id": "blackmatrix7.manmanbuy", "name": "慢慢买", - "keys": ["manmanbuy_checkin_cookie", "manmanbuy_login_body", "manmanbuy_username", "manmanbuy_deviceid"], + "keys": [ + "manmanbuy_checkin_cookie", + "manmanbuy_login_body", + "manmanbuy_username", + "manmanbuy_deviceid" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/manmanbuy", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/manmanbuy/manmanmai.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/manmanbuy/manmanmai.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/manmanbuy/manmanmai.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/manmanbuy/manmanmai.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/manmanbuy/manmanbuy_checkin.js" }, { "id": "blackmatrix7.meituan", "name": "美团买菜", - "keys": ["meituan_mall_cookie", "meituan_mall_t", "meituan_mall_querystring", "meituan_mall_uuid", "meituan_mall_userid", "meituan_mall_body"], + "keys": [ + "meituan_mall_cookie", + "meituan_mall_t", + "meituan_mall_querystring", + "meituan_mall_uuid", + "meituan_mall_userid", + "meituan_mall_body" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/meituan", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai_checkin.js" }, { "id": "blackmatrix7.smzdm", "name": "什么值得买", - "keys": ["smzdm_cookie", "smzdm_session"], + "keys": [ + "smzdm_cookie", + "smzdm_session" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/smzdm", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/smzdm.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/smzdm.png"], + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/smzdm.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/smzdm.png" + ], "scripts": [ { "name": "每日自动任务", @@ -150,28 +273,31 @@ { "id": "blackmatrix7.tieba", "name": "百度贴吧", - "keys": ["tieba_checkin_cookie"], + "keys": [ + "tieba_checkin_cookie" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/tieba", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/tieba.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/tieba.png"], + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/tieba.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/tieba.png" + ], "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/tieba/tieba_checkin.js" }, - { - "id": "blackmatrix7.wanda", - "name": "万达电影", - "keys": ["wanda_checkin_cookie", "wanda_activitycode"], - "author": "@blackmatrix7", - "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/wanda", - "icons": ["https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/wanda.png", "https://raw.githubusercontent.com/Orz-3/mini/master/Color/wanda.png"], - "script": "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/wanda/wanda_checkin.js" - }, { "id": "blackmatrix7.zhihu", "name": "知乎助手", - "keys": ["zhihu_blocked_users", "zhihu_current_userinfo", "zhihu_keyword_block"], + "keys": [ + "zhihu_blocked_users", + "zhihu_current_userinfo", + "zhihu_keyword_block" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/zhihu", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/zhihu/zhihu.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/zhihu/zhihu.png"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/zhihu/zhihu.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/zhihu/zhihu.png" + ], "descs_html": [ "

具体功能说明查看README.md

", "

✨为Plus版本专属功能,❓为已过时或即将淘汰功能

", @@ -309,7 +435,12 @@ { "id": "blackmatrix7.synology", "name": "Synology", - "keys": ["syno_https_url", "syno_account", "syno_passwd", "syno_sid"], + "keys": [ + "syno_https_url", + "syno_account", + "syno_passwd", + "syno_sid" + ], "settings": [ { "id": "syno_https_url", @@ -379,7 +510,10 @@ ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/synology", - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology_dark.jpg", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology.jpg"], + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology_dark.jpg", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/synology/icon/synology.jpg" + ], "scripts": [ { "name": "登录Synology", @@ -390,7 +524,13 @@ { "id": "blackmatrix7.applestore", "name": "AppleStore", - "keys": ["goods_model", "applestore_region", "applestore_bark_url", "applestore_stock", "onlinestore_stock"], + "keys": [ + "goods_model", + "applestore_region", + "applestore_bark_url", + "applestore_stock", + "onlinestore_stock" + ], "author": "@blackmatrix7", "repo": "https://github.com/blackmatrix7/ios_rule_script/tree/master/script/applestore", "settings": [ @@ -483,7 +623,10 @@ "desc": "出现异常时请选择DEBUG提交日志" } ], - "icons": ["https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore_dark.png", "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore.png"] + "icons": [ + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore_dark.png", + "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/applestore/icon/applestore.png" + ] } ] -} +} \ No newline at end of file diff --git a/script/eleme/README.md b/script/eleme/README.md index 7f05f43d5..633420a33 100644 --- a/script/eleme/README.md +++ b/script/eleme/README.md @@ -6,26 +6,15 @@ 自动领取吃货豆,非会员可能能用,我没有非会员账号,无法验证,有兴趣可以自己试试。 -## 最近更新 - -1. 拆分领取吃货豆和领取会员任务的脚本 -2. 支持最新多选一任务 -3. 适配饿了么最新的吃货豆活动 -4. 增加自动领取吃货豆功能 - ## 特别说明 -目前已将领取吃货豆和领取会员任务的脚本拆分,请按需部署脚本。 +### 获取数据 -如果使用现成的Surge模块或Loon插件,则会在0点10分领取吃货豆,在早上10点领取任务列表中第一个可以领取的任务。 - -### 领取吃货豆 - -脚本自动领取APP中未领取的吃货豆。 +需要同时获取到Cookie与坐标,脚本才能正常执行,获取方法见后。 ### 多选一任务 -对于最新更新的多选一任务,脚本会依次尝试领取所有任务。但因为多选一的关系,通常只会有第一个任务能成功领取。 +脚本会依次尝试领取所有任务。但因为多选一的关系,通常只会有第一个任务能成功领取。 ## 配置说明 @@ -33,15 +22,16 @@ 使用模块 +```ini https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.sgmodule +``` ### Loon -使用远程脚本配置 +使用插件 ```ini -[Remote Script] -https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.lnscript, tag=饿了么_领取吃货豆及任务, enabled=true +https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.lnplugin ``` ### Quantumult X @@ -53,67 +43,75 @@ https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/ele https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.qxrewrite, tag=饿了么_获取Cookie, enabled=true [task_local] -10 00 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js, tag=饿了么_领取吃货豆, enabled=true -00 10 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js, tag=饿了么_领取会员任务, enabled=true +05 10 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js, tag=饿了么_领取吃货豆, enabled=true +05 10 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js, tag=饿了么_领取会员任务, enabled=true ``` -## 获取Cookie +## 获取数据 -饿了么APP - 我的 - 超级吃货卡 +### 获取Cookie -## 统一推送 +打开饿了么APP即可。 -MagicJS利用Bark,实现了跨设备的统一推送能力,将多个iOS设备的脚本执行结果,统一推送到一个设备上。 +### 获取坐标 -执行效果图,以饿了么为例: +打开饿了么APP - 我的 - 赚吃货豆。 + +由于获取坐标的请求不是每次都触发的,如果没有正确获取到坐标,建议移除饿了么APP后台,间隔10分钟后,再尝试上述操作。 + +或者通过其他途径获取自身坐标,通过BoxJS填入。 + +## Bark推送 + +通过BoxJS,配置Bark推送链接,可以将脚本通知,通过Bark推送到其他设备上。 + +以饿了么为例: ![](https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/images/bark.jpg) -### 开启统一推送 +在BoxJS中填写Bark推送链接即可。 -你需要安装Bark这个APP,打开后可以得到类似这样的链接: + -```http -https://api.day.app/VXTWvaQ18N29bsQAg7DgkT +## 青龙面板 + +MagicJS所有的变量,都存储在脚本同级目录下的`magic.json`文件中,不支持通过环境变量读取变量。 + +在青龙面板中,在左侧菜单选择脚本管理,新建 `magic.json` 文件(文件名不可修改)。 + +写入如下json: + +```json +{ + "eleme_app_cookie": "xxxxxxxxxxxxxxxxx", + "eleme_app_longitude": "111.1111111111", + "eleme_app_latitude": "111.1111111111", + "eleme_task_keywords": "美食外卖", + "bark_url": "https://api.day.app/xxxxxxxxxxxxxxxxxx/" +} ``` -在Surge、Loon、QuantumultX中执行以下代码,将链接写入(如何执行代码请自己动手解决)。 +变量说明 -**Surge、Loon** +| 变量名 | 说明 | +| ------------------- | ---------------------------------------------- | +| eleme_app_cookie | 饿了么Cookie | +| eleme_app_longitude | 饿了么经度 | +| eleme_app_latitude | 饿了么纬度 | +| eleme_task_keywords | 饿了么任务关键词,含有此关键词的任务才会被领取 | +| bark_url | Bark推送地址 | -```javascript -# 开启所有脚本统一推送 -$persistentStore.write("https://api.day.app/VXTWvaQ18N29bsQAg7DgkT", "magicjs_unified_push_url"); +如果你正在使用多个由MagicJS支持的脚本,可以将变量写在同一个`magic.json`文件中,例如: + +```json +{ + "smzdm_cookie": "xxxxxxxxxxxxxxxxxxxxx", + "smzdm_session": "xxxxxxxxxxxxxxxxxxxxx", + "eleme_app_cookie": "xxxxxxxxxxxxxxxxx", + "eleme_app_longitude": "111.1111111111", + "eleme_app_latitude": "111.1111111111", + "eleme_task_keywords": "美食外卖", + "bark_url": "https://api.day.app/xxxxxxxxxxxxxxxxxx/" +} ``` -**Quantumult X** - -```javascript -# 开启所有脚本统一推送 -$prefs.setValueForKey("https://api.day.app/VXTWvaQ18N29bsQAg7DgkT", "magicjs_unified_push_url"); -``` - -### 关闭统一推送 - -**Surge、Loon** - -```javascript -# 关闭所有脚本统一推送 -$persistentStore.write("", "magicjs_unified_push_url"); -``` - -**Quantumult X** - -```javascript -# 关闭所有脚本统一推送 -$prefs.setValueForKey("", "magicjs_unified_push_url"); -``` - -### 其他 - -1. 统一推送能力仅对支持的脚本有效。 -2. 开启统一推送后,所有支持统一推送的脚本,都会把通知推送到目标设备上。 -3. 限于Bark的功能,统一推送中的多媒体和链接不可用。 -4. 统一推送需要使用Bark的服务器,推送成功与否,与Bark服务器的可用性有关。 -5. 统一推送不会关闭APP的本地推送,即两个iOS设备都会有推送。 -6. 如有隐私考虑,可以参考Bark的服务端文档,自建服务端。 \ No newline at end of file diff --git a/script/eleme/eleme_daily.js b/script/eleme/eleme_daily.js index bd9f8eae6..f0d0c78da 100644 --- a/script/eleme/eleme_daily.js +++ b/script/eleme/eleme_daily.js @@ -1,41 +1,60 @@ const scriptName = '饿了么'; -const getCookieRegex = /^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply\?.*longitude=([^&]*).*latitude=([^&]*)/; +const getCoordinateRegex1 = /^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-home-tasklist-new\/home\?.*longitude=([^&]*).*latitude=([^&]*)/; +const getCoordinateRegex2 = /^https?:\/\/tb\.ele\.me\/wow\/alsc\/mod\/.*longitude=([^&]*).*latitude=([^&]*)/; +const getCoordinateRegex3 = /^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply\?.*longitude=([^&]*).*latitude=([^&]*)/; +const getCookies = /^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-foodie-card\/home/; const elemeCookieKey = 'eleme_app_cookie'; const elemeLongitudeKey = 'eleme_app_longitude'; const elemeLatitudeKey = 'eleme_app_latitude'; let magicJS = MagicJS(scriptName, "INFO"); -magicJS.unifiedPushUrl = magicJS.read('eleme_app_unified_push_url') || magicJS.read('magicjs_unified_push_url'); +magicJS.unifiedPushUrl = magicJS.read("bark_url"); -function GetCookie(){ - try{ - let cookie = magicJS.request.headers.Cookie; - let arr = magicJS.request.url.match(getCookieRegex); - let longitude = arr[1]; - let latitude = arr[2]; - let hisCookie = magicJS.read(elemeCookieKey); +function GetCoordinate() { + try { + let arr = []; + const hisLongitude = magicJS.read(elemeLongitudeKey); + const hisLatitude = magicJS.read(elemeLatitudeKey); + arr = magicJS.request.url.match(getCoordinateRegex1); + if (arr && arr.length < 2) { + arr = magicJS.request.url.match(getCoordinateRegex2); + } + if (arr && arr.length < 2) { + arr = magicJS.request.url.match(getCoordinateRegex3); + } + const longitude = arr[1]; + const latitude = arr[2]; magicJS.write(elemeLongitudeKey, longitude); magicJS.write(elemeLatitudeKey, latitude); - let compareCookie2 = !!cookie? /cookie2=([a-zA-Z0-9]*)/.exec(cookie)[1]: null; - let compareHisCookie2 = !!hisCookie? /cookie2=([a-zA-Z0-9]*)/.exec(hisCookie)[1]: null; - if (!!!hisCookie || compareCookie2 !== compareHisCookie2){ - magicJS.write(elemeCookieKey, cookie); - magicJS.logInfo(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`); - magicJS.notify('Cookie写入成功!!'); - } - else{ - magicJS.logInfo('Cookie没有变化,无需更新'); + if (longitude !== hisLongitude || latitude !== hisLatitude){ + magicJS.notify(`更新坐标成功!`) } } - catch(err){ - magicJS.notify('获取Cookie出现异常,请查阅日志。'); - magicJS.logError(`获取Cookie出现执行异常,异常信息:${err}`); + catch (err) { + magicJS.notify('获取坐标出现异常,请查阅日志。'); + magicJS.logError(`获取坐标出现执行异常,异常信息:${err}`); + } +} + + +function GetCookies(){ + let cookie = magicJS.request.headers.Cookie; + let hisCookie = magicJS.read(elemeCookieKey); + let compareCookie2 = !!cookie ? /cookie2=([a-zA-Z0-9]*)/.exec(cookie)[1] : null; + let compareHisCookie2 = !!hisCookie ? /cookie2=([a-zA-Z0-9]*)/.exec(hisCookie)[1] : null; + if (!!!hisCookie || compareCookie2 !== compareHisCookie2) { + magicJS.write(elemeCookieKey, cookie); + magicJS.logInfo(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`); + magicJS.notify('Cookie写入成功!!'); + } + else { + magicJS.logInfo('Cookie没有变化,无需更新'); } } // 获取待领取的吃货豆列表 -function GetPeaList(cookie, longitude, latitude){ - return new Promise((resolve, reject)=>{ +function GetPeaList(cookie, longitude, latitude) { + return new Promise((resolve, reject) => { let options = { url: `https://h5.ele.me/restapi/biz.svip_core/v1/foodie/homepage?longitude=${longitude}&latitude=${latitude}`, headers: { @@ -52,29 +71,29 @@ function GetPeaList(cookie, longitude, latitude){ "x-shard": `loc=${longitude},${latitude}` } } - magicJS.get(options, (err, resp, data)=>{ - if (err){ + magicJS.get(options, (err, resp, data) => { + if (err) { magicJS.logError(`获取待领取的吃货豆失败,请求异常:${err}`); reject('获取待领取的吃货豆失败,请求异常,请查阅日志!'); } - else{ - try{ + else { + try { magicJS.logDebug(`获取待领取吃货豆列表响应结果:${data}`); - let obj = typeof data === 'string'? JSON.parse(data) : data; - if (obj.success === true){ + let obj = typeof data === 'string' ? JSON.parse(data) : data; + if (obj.success === true) { let peaList = []; obj.foodiePeaBlock.peaList.forEach(element => { - peaList.push({'id': element.id, 'count': element.count, 'description': element.description}); + peaList.push({ 'id': element.id, 'count': element.count, 'description': element.description }); }); magicJS.logInfo(`获取待领取的吃货豆成功:${JSON.stringify(peaList)}`); resolve(peaList); } - else{ + else { magicJS.logError(`获取待领取的吃货豆失败,响应异常:${data}`); reject('获取待领取的吃货豆失败,响应异常,请查阅日志!'); } } - catch(err){ + catch (err) { magicJS.logError(`获取待领取的吃货豆失败,执行异常:${err},接口响应:${data}`); reject('获取待领取的吃货豆失败,执行异常,请查阅日志!'); } @@ -84,8 +103,8 @@ function GetPeaList(cookie, longitude, latitude){ } // 领取吃货豆 -function DrawPea(cookie, peaId, longitude, latitude){ - return new Promise((resolve, reject)=>{ +function DrawPea(cookie, peaId, longitude, latitude) { + return new Promise((resolve, reject) => { let options = { url: `https://h5.ele.me/restapi/biz.svip_bonus/v1/users/supervip/pea/draw?peaId=${peaId}`, headers: { @@ -108,25 +127,25 @@ function DrawPea(cookie, peaId, longitude, latitude){ "latitude": latitude }) } - magicJS.post(options, (err, resp, data)=>{ - if (err){ + magicJS.post(options, (err, resp, data) => { + if (err) { magicJS.logError(`领取吃货豆失败,请求异常:${err}`); reject('领取吃货豆失败,请求异常,请查阅日志!'); } - else{ - try{ + else { + try { magicJS.logDebug(`领取吃货豆响应结果:${data}`); - let obj = typeof data === 'string'? JSON.parse(data) : data; - if (obj.success === true){ + let obj = typeof data === 'string' ? JSON.parse(data) : data; + if (obj.success === true) { magicJS.logInfo(`领取吃货豆成功:${data}`); resolve(true); } - else{ + else { magicJS.logError(`领取吃货豆失败,响应异常:${data}`); reject('领取吃货豆失败,响应异常,请查阅日志!'); } } - catch(err){ + catch (err) { magicJS.logError(`领取吃货豆失败,执行异常:${err},接口响应:${data}`); reject('领取吃货豆失败,执行异常,请查阅日志!'); } @@ -135,41 +154,48 @@ function DrawPea(cookie, peaId, longitude, latitude){ }) } -;(async()=>{ - if (magicJS.isRequest){ - if (getCookieRegex.test(magicJS.request.url) && magicJS.request.method == "GET"){ - GetCookie(); +; (async () => { + if (magicJS.isRequest) { + if (( + getCoordinateRegex1.test(magicJS.request.url) || + getCoordinateRegex2.test(magicJS.request.url) || + getCoordinateRegex3.test(magicJS.request.url) + ) && magicJS.request.method == "GET") { + GetCoordinate(); + } + else if (getCookies.test(magicJS.request.url)){ + GetCookies(); } } - else{ + else { let subTitle = ""; let content = ""; let cookie = magicJS.read(elemeCookieKey); let longitude = magicJS.read(elemeLongitudeKey); let latitude = magicJS.read(elemeLatitudeKey); - if (!!!cookie){ + if (!!!cookie) { magicJS.logWarning('没有读取到Cookie,请先从App中获取一次Cookie!'); content = '❓没有读取到有效Cookie,请先从App中获取Cookie!!'; } - else{ + else { // 获取待领取的吃货豆 let [getPeaListErr, peaList] = await magicJS.attempt(GetPeaList(cookie, longitude, latitude), []); content = '吃货豆领取结果:'; - if (getPeaListErr){ + if (getPeaListErr) { content += '\n获取待领取的吃货豆异常,请查阅日志'; } - else if (peaList.length == 0){ + else if (peaList.length == 0) { content += '\n没有发现待领取的吃货豆'; } - else{ + else { let peaCount = 0; let drawPeaContent = ''; - for (let j=0;j{let t={};if(this.isSurge||this.isQuanX||this.isLoon){if(typeof e==="string"){if(this.isLoon)t={openUrl:e};else if(this.isQuanX)t={"open-url":e};else if(this.isSurge)t={url:e}}else if(typeof e==="object"){let s={Surge:{openUrl:"url","open-url":"url"},Loon:{url:"openUrl","open-url":"openUrl","media-url":"mediaUrl"},QuantumultX:{url:"open-url",openUrl:"open-url",mediaUrl:"media-url"}};let i=Object.keys(e);for(let o=0;o{})}if(this.isSurge||this.isLoon){$notification.post(e,t,s,i)}else if(this.isQuanX){$notify(e,t,s,i)}else if(this.isJSBox){let i={title:e,body:!!t?`${t}\n${s}`:s};$push.schedule(i)}}log(e,t="INFO"){if(!(this.logLevels[this._logLevel]{if(typeof i.body==="undefined")return"";return`${encodeURIComponent(e)}=${encodeURIComponent(i.body[e])}`}).join("&");if(i.url.indexOf("?")<0)i.url+="?";if(i.url.lastIndexOf("&")+1!=i.url.length&&i.url.lastIndexOf("?")+1!=i.url.length)i.url+="&";i.url+=e;delete i.body}if(this.isQuanX){if(i.hasOwnProperty("body")&&typeof i["body"]!=="string")i["body"]=JSON.stringify(i["body"]);i["method"]=t}else if(this.isNode){delete i.headers["Accept-Encoding"];if(typeof i.body==="object"){if(t==="GET"){i.qs=i.body;delete i.body}else if(t==="POST"){i["json"]=true;i.body=i.body}}}else if(this.isJSBox){i["header"]=i["headers"];delete i["headers"]}return i}get(e,t){let s=this.adapterHttpOptions(e,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.get(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>t(e.error,null,null))}else if(this.isNode){return this.node.request.get(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.get(s)}}post(e,t){let s=this.adapterHttpOptions(e,"POST");this.logDebug(`HTTP POST: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.post(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>{t(e.error,null,null)})}else if(this.isNode){return this.node.request.post(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.post(s)}}done(e={}){if(typeof $done!=="undefined"){$done(e)}}isToday(e){if(e==null){return false}else{let t=new Date;if(typeof e=="string"){e=new Date(e)}if(t.getFullYear()==e.getFullYear()&&t.getMonth()==e.getMonth()&&t.getDay()==e.getDay()){return true}else{return false}}}isNumber(e){return parseFloat(e).toString()==="NaN"?false:true}attempt(e,t=null){return e.then(e=>{return[null,e]}).catch(e=>{this.logError(e);return[e,t]})}retry(e,t=5,s=0,i=null){return(...o)=>{return new Promise((r,n)=>{function a(...o){Promise.resolve().then(()=>e.apply(this,o)).then(e=>{if(typeof i==="function"){Promise.resolve().then(()=>i(e)).then(()=>{r(e)}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}else{r(e)}}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}a.apply(this,o)})}}formatTime(e,t="yyyy-MM-dd hh:mm:ss"){var s={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t))t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length));for(let e in s)if(new RegExp("("+e+")").test(t))t=t.replace(RegExp.$1,RegExp.$1.length==1?s[e]:("00"+s[e]).substr((""+s[e]).length));return t}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(e){return new Promise(t=>setTimeout(t,e))}}(e)} +function MagicJS(e = "MagicJS", t = "INFO") { const s = { accept: "Accept", "accept-ch": "Accept-CH", "accept-charset": "Accept-Charset", "accept-features": "Accept-Features", "accept-encoding": "Accept-Encoding", "accept-language": "Accept-Language", "accept-ranges": "Accept-Ranges", "access-control-allow-credentials": "Access-Control-Allow-Credentials", "access-control-allow-origin": "Access-Control-Allow-Origin", "access-control-allow-methods": "Access-Control-Allow-Methods", "access-control-allow-headers": "Access-Control-Allow-Headers", "access-control-max-age": "Access-Control-Max-Age", "access-control-expose-headers": "Access-Control-Expose-Headers", "access-control-request-method": "Access-Control-Request-Method", "access-control-request-headers": "Access-Control-Request-Headers", age: "Age", allow: "Allow", alternates: "Alternates", authorization: "Authorization", "cache-control": "Cache-Control", connection: "Connection", "content-encoding": "Content-Encoding", "content-language": "Content-Language", "content-length": "Content-Length", "content-location": "Content-Location", "content-md5": "Content-MD5", "content-range": "Content-Range", "content-security-policy": "Content-Security-Policy", "content-type": "Content-Type", cookie: "Cookie", dnt: "DNT", date: "Date", etag: "ETag", expect: "Expect", expires: "Expires", from: "From", host: "Host", "if-match": "If-Match", "if-modified-since": "If-Modified-Since", "if-none-match": "If-None-Match", "if-range": "If-Range", "if-unmodified-since": "If-Unmodified-Since", "last-event-id": "Last-Event-ID", "last-modified": "Last-Modified", link: "Link", location: "Location", "max-forwards": "Max-Forwards", negotiate: "Negotiate", origin: "Origin", pragma: "Pragma", "proxy-authenticate": "Proxy-Authenticate", "proxy-authorization": "Proxy-Authorization", range: "Range", referer: "Referer", "retry-after": "Retry-After", "sec-websocket-extensions": "Sec-Websocket-Extensions", "sec-websocket-key": "Sec-Websocket-Key", "sec-websocket-origin": "Sec-Websocket-Origin", "sec-websocket-protocol": "Sec-Websocket-Protocol", "sec-websocket-version": "Sec-Websocket-Version", server: "Server", "set-cookie": "Set-Cookie", "set-cookie2": "Set-Cookie2", "strict-transport-security": "Strict-Transport-Security", tcn: "TCN", te: "TE", trailer: "Trailer", "transfer-encoding": "Transfer-Encoding", upgrade: "Upgrade", "user-agent": "User-Agent", "variant-vary": "Variant-Vary", vary: "Vary", via: "Via", warning: "Warning", "www-authenticate": "WWW-Authenticate", "x-content-duration": "X-Content-Duration", "x-content-security-policy": "X-Content-Security-Policy", "x-dnsprefetch-control": "X-DNSPrefetch-Control", "x-frame-options": "X-Frame-Options", "x-requested-with": "X-Requested-With", "x-surge-skip-scripting": "X-Surge-Skip-Scripting" }; return new class { constructor() { this.version = "2.2.3.3"; this.scriptName = e; this.logLevels = { DEBUG: 5, INFO: 4, NOTIFY: 3, WARNING: 2, ERROR: 1, CRITICAL: 0, NONE: -1 }; this.isLoon = typeof $loon !== "undefined"; this.isQuanX = typeof $task !== "undefined"; this.isJSBox = typeof $drive !== "undefined"; this.isNode = typeof module !== "undefined" && !this.isJSBox; this.isSurge = typeof $httpClient !== "undefined" && !this.isLoon; this.platform = this.getPlatform(); this.node = { request: undefined, fs: undefined, data: {} }; this.iOSUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1"; this.pcUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59"; this.logLevel = t; this._unifiedPushUrl = ""; if (this.isNode) { this.node.fs = require("fs"); this.node.request = require("request"); try { this.node.fs.accessSync("./magic.json", this.node.fs.constants.R_OK | this.node.fs.constants.W_OK) } catch (e) { this.node.fs.writeFileSync("./magic.json", "{}", { encoding: "utf8" }) } this.node.data = require("./magic.json") } else if (this.isJSBox) { if (!$file.exists("drive://MagicJS")) { $file.mkdir("drive://MagicJS") } if (!$file.exists("drive://MagicJS/magic.json")) { $file.write({ data: $data({ string: "{}" }), path: "drive://MagicJS/magic.json" }) } } } set unifiedPushUrl(e) { this._unifiedPushUrl = !!e ? e.replace(/\/+$/g, "") : "" } set logLevel(e) { this._logLevel = typeof e === "string" ? e.toUpperCase() : "DEBUG" } get logLevel() { return this._logLevel } get isRequest() { return typeof $request !== "undefined" && typeof $response === "undefined" } get isResponse() { return typeof $response !== "undefined" } get request() { return typeof $request !== "undefined" ? $request : undefined } get response() { if (typeof $response !== "undefined") { if ($response.hasOwnProperty("status")) $response["statusCode"] = $response["status"]; if ($response.hasOwnProperty("statusCode")) $response["status"] = $response["statusCode"]; return $response } else { return undefined } } getPlatform() { if (this.isSurge) return "Surge"; else if (this.isQuanX) return "QuantumultX"; else if (this.isLoon) return "Loon"; else if (this.isJSBox) return "JSBox"; else if (this.isNode) return "Node.js"; else return "unknown" } read(e, t = "") { let s = ""; if (this.isSurge || this.isLoon) { s = $persistentStore.read(e) } else if (this.isQuanX) { s = $prefs.valueForKey(e) } else if (this.isNode) { s = this.node.data } else if (this.isJSBox) { s = $file.read("drive://MagicJS/magic.json").string } try { if (this.isNode) s = s[e]; if (this.isJSBox) s = JSON.parse(s)[e]; if (!!t) { if (typeof s === "string") s = JSON.parse(s); s = !!s && typeof s === "object" ? s[t] : null } } catch (i) { this.logError(i); s = !!t ? {} : null; this.del(e) } if (typeof s === "undefined") s = null; try { if (!!s && typeof s === "string") s = JSON.parse(s) } catch (e) { } this.logDebug(`READ DATA [${e}]${!!t ? `[${t}]` : ""}(${typeof s})\n${JSON.stringify(s)}`); return s } write(e, t, s = "") { let i = !!s ? {} : ""; if (!!s && (this.isSurge || this.isLoon)) { i = $persistentStore.read(e) } else if (!!s && this.isQuanX) { i = $prefs.valueForKey(e) } else if (this.isNode) { i = this.node.data } else if (this.isJSBox) { i = JSON.parse($file.read("drive://MagicJS/magic.json").string) } if (!!s) { try { if (typeof i === "string") i = JSON.parse(i); i = typeof i === "object" && !!i ? i : {} } catch (t) { this.logError(t); this.del(e); i = {} } if (this.isJSBox || this.isNode) { if (!i.hasOwnProperty(e) || typeof i[e] !== "object" || i[e] === null) { i[e] = {} } if (!i[e].hasOwnProperty(s)) { i[e][s] = null } if (typeof t === "undefined") { delete i[e][s] } else { i[e][s] = t } } else { if (typeof t === "undefined") { delete i[s] } else { i[s] = t } } } else { if (this.isNode || this.isJSBox) { if (typeof t === "undefined") { delete i[e] } else { i[e] = t } } else { if (typeof t === "undefined") { i = null } else { i = t } } } if (typeof i === "object") i = JSON.stringify(i); if (this.isSurge || this.isLoon) { $persistentStore.write(i, e) } else if (this.isQuanX) { $prefs.setValueForKey(i, e) } else if (this.isNode) { this.node.fs.writeFileSync("./magic.json", i) } else if (this.isJSBox) { $file.write({ data: $data({ string: i }), path: "drive://MagicJS/magic.json" }) } this.logDebug(`WRITE DATA [${e}]${!!s ? `[${s}]` : ""}(${typeof t})\n${JSON.stringify(t)}`) } del(e, t = "") { this.logDebug(`DELETE KEY [${e}]${!!t ? `[${t}]` : ""}`); this.write(e, null, t) } notify(e = this.scriptName, t = "", s = "", i = "") { let o = e => { let t = {}; if (this.isSurge || this.isQuanX || this.isLoon) { if (typeof e === "string") { if (this.isLoon) t = { openUrl: e }; else if (this.isQuanX) t = { "open-url": e }; else if (this.isSurge) t = { url: e } } else if (typeof e === "object") { let s = { Surge: { openUrl: "url", "open-url": "url" }, Loon: { url: "openUrl", "open-url": "openUrl", "media-url": "mediaUrl" }, QuantumultX: { url: "open-url", openUrl: "open-url", mediaUrl: "media-url" } }; let i = Object.keys(e); for (let o = 0; o < i.length; o++) { if (!!s[this.platform][i[o]]) { t[s[this.platform][i[o]]] = e[i[o]] } else { t[i[o]] = e[i[o]] } } } } return t }; i = o(i); this.logNotify(`title:${e}\nsubTitle:${t}\nbody:${s}\noptions:${typeof i === "object" ? JSON.stringify(i) : i}`); if (arguments.length == 1) { e = this.scriptName; t = "", s = arguments[0] } if (!!this._unifiedPushUrl) { let i = encodeURI(`${e}/${t}${!!t ? "\n" : ""}${s}`); this.get(`${this._unifiedPushUrl}/${i}`, () => { }) } if (this.isSurge || this.isLoon) { $notification.post(e, t, s, i) } else if (this.isQuanX) { $notify(e, t, s, i) } else if (this.isJSBox) { let i = { title: e, body: !!t ? `${t}\n${s}` : s }; $push.schedule(i) } } log(e, t = "INFO") { if (!(this.logLevels[this._logLevel] < this.logLevels[t.toUpperCase()])) console.log(`[${t}] [${this.scriptName}]\n${e}\n`) } logDebug(e) { this.log(e, "DEBUG") } logInfo(e) { this.log(e, "INFO") } logNotify(e) { this.log(e, "NOTIFY") } logWarning(e) { this.log(e, "WARNING") } logError(e) { this.log(e, "ERROR") } adapterHttpOptions(e, t) { let i = typeof e === "object" ? Object.assign({}, e) : { url: e, headers: {} }; if (i.hasOwnProperty("header") && !i.hasOwnProperty("headers")) { i["headers"] = i["header"]; delete i["header"] } if (typeof i.headers === "object" && !!s) { for (let e in i.headers) { if (s[e]) { i.headers[s[e]] = i.headers[e]; delete i.headers[e] } } } if (!!!i.headers || typeof i.headers !== "object" || !!!i.headers["User-Agent"]) { if (!!!i.headers || typeof i.headers !== "object") i.headers = {}; if (this.isNode) i.headers["User-Agent"] = this.pcUserAgent; else i.headers["User-Agent"] = this.iOSUserAgent } let o = false; if (typeof i["opts"] === "object" && (i["opts"]["hints"] === true || i["opts"]["Skip-Scripting"] === true) || typeof i["headers"] === "object" && i["headers"]["X-Surge-Skip-Scripting"] === true) { o = true } if (!o) { if (this.isSurge) i.headers["X-Surge-Skip-Scripting"] = false; else if (this.isLoon) i.headers["X-Requested-With"] = "XMLHttpRequest"; else if (this.isQuanX) { if (typeof i["opts"] !== "object") i.opts = {}; i.opts["hints"] = false } } if (!this.isSurge || o) delete i.headers["X-Surge-Skip-Scripting"]; if (!this.isQuanX && i.hasOwnProperty("opts")) delete i["opts"]; if (this.isQuanX && i.hasOwnProperty("opts")) delete i["opts"]["Skip-Scripting"]; if (t === "GET" && !this.isNode && !!i.body) { let e = Object.keys(i.body).map(e => { if (typeof i.body === "undefined") return ""; return `${encodeURIComponent(e)}=${encodeURIComponent(i.body[e])}` }).join("&"); if (i.url.indexOf("?") < 0) i.url += "?"; if (i.url.lastIndexOf("&") + 1 != i.url.length && i.url.lastIndexOf("?") + 1 != i.url.length) i.url += "&"; i.url += e; delete i.body } if (this.isQuanX) { if (i.hasOwnProperty("body") && typeof i["body"] !== "string") i["body"] = JSON.stringify(i["body"]); i["method"] = t } else if (this.isNode) { delete i.headers["Accept-Encoding"]; if (typeof i.body === "object") { if (t === "GET") { i.qs = i.body; delete i.body } else if (t === "POST") { i["json"] = true; i.body = i.body } } } else if (this.isJSBox) { i["header"] = i["headers"]; delete i["headers"] } return i } get(e, t) { let s = this.adapterHttpOptions(e, "GET"); this.logDebug(`HTTP GET: ${JSON.stringify(s)}`); if (this.isSurge || this.isLoon) { $httpClient.get(s, t) } else if (this.isQuanX) { $task.fetch(s).then(e => { e["status"] = e.statusCode; t(null, e, e.body) }, e => t(e.error, null, null)) } else if (this.isNode) { return this.node.request.get(s, t) } else if (this.isJSBox) { s["handler"] = (e => { let s = e.error ? JSON.stringify(e.error) : undefined; let i = typeof e.data === "object" ? JSON.stringify(e.data) : e.data; t(s, e.response, i) }); $http.get(s) } } post(e, t) { let s = this.adapterHttpOptions(e, "POST"); this.logDebug(`HTTP POST: ${JSON.stringify(s)}`); if (this.isSurge || this.isLoon) { $httpClient.post(s, t) } else if (this.isQuanX) { $task.fetch(s).then(e => { e["status"] = e.statusCode; t(null, e, e.body) }, e => { t(e.error, null, null) }) } else if (this.isNode) { return this.node.request.post(s, t) } else if (this.isJSBox) { s["handler"] = (e => { let s = e.error ? JSON.stringify(e.error) : undefined; let i = typeof e.data === "object" ? JSON.stringify(e.data) : e.data; t(s, e.response, i) }); $http.post(s) } } done(e = {}) { if (typeof $done !== "undefined") { $done(e) } } isToday(e) { if (e == null) { return false } else { let t = new Date; if (typeof e == "string") { e = new Date(e) } if (t.getFullYear() == e.getFullYear() && t.getMonth() == e.getMonth() && t.getDay() == e.getDay()) { return true } else { return false } } } isNumber(e) { return parseFloat(e).toString() === "NaN" ? false : true } attempt(e, t = null) { return e.then(e => { return [null, e] }).catch(e => { this.logError(e); return [e, t] }) } retry(e, t = 5, s = 0, i = null) { return (...o) => { return new Promise((r, n) => { function a(...o) { Promise.resolve().then(() => e.apply(this, o)).then(e => { if (typeof i === "function") { Promise.resolve().then(() => i(e)).then(() => { r(e) }).catch(e => { this.logError(e); if (t >= 1 && s > 0) { setTimeout(() => a.apply(this, o), s) } else if (t >= 1) { a.apply(this, o) } else { n(e) } t-- }) } else { r(e) } }).catch(e => { this.logError(e); if (t >= 1 && s > 0) { setTimeout(() => a.apply(this, o), s) } else if (t >= 1) { a.apply(this, o) } else { n(e) } t-- }) } a.apply(this, o) }) } } formatTime(e, t = "yyyy-MM-dd hh:mm:ss") { var s = { "M+": e.getMonth() + 1, "d+": e.getDate(), "h+": e.getHours(), "m+": e.getMinutes(), "s+": e.getSeconds(), "q+": Math.floor((e.getMonth() + 3) / 3), S: e.getMilliseconds() }; if (/(y+)/.test(t)) t = t.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length)); for (let e in s) if (new RegExp("(" + e + ")").test(t)) t = t.replace(RegExp.$1, RegExp.$1.length == 1 ? s[e] : ("00" + s[e]).substr(("" + s[e]).length)); return t } now() { return this.formatTime(new Date, "yyyy-MM-dd hh:mm:ss") } today() { return this.formatTime(new Date, "yyyy-MM-dd") } sleep(e) { return new Promise(t => setTimeout(t, e)) } }(e) } diff --git a/script/eleme/eleme_daily.lnplugin b/script/eleme/eleme_daily.lnplugin new file mode 100644 index 000000000..02094ca76 --- /dev/null +++ b/script/eleme/eleme_daily.lnplugin @@ -0,0 +1,17 @@ +#!name= 饿了么 +#!desc= 饿了么每日自动领取任务及吃货豆 +#!openUrl=https://github.com/blackmatrix7/ios_rule_script/tree/master/script/eleme +#!author= blackmatrix7 +#!homepage= https://github.com/blackmatrix7/ios_rule_script +#!icon= https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/elem.png + +[Script] +http-request ^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-foodie-card\/home requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,tag=饿了么_获取Cookie +http-request ^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-home-tasklist-new\/home requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,tag=饿了么_获取坐标1 +http-request ^https?:\/\/tb\.ele\.me\/wow\/alsc\/mod requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,tag=饿了么_获取坐标2 +http-request ^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,tag=饿了么_获取坐标3 +cron "10 09 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,timeout=60,tag=饿了么_领取吃货豆 +cron "15 09 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js,timeout=60,tag=饿了么_领取会员任务 + +[MITM] +hostname = air.tb.ele.me,tb.ele.me,h5.ele.me \ No newline at end of file diff --git a/script/eleme/eleme_daily.lnscript b/script/eleme/eleme_daily.lnscript deleted file mode 100644 index fbeb89756..000000000 --- a/script/eleme/eleme_daily.lnscript +++ /dev/null @@ -1,7 +0,0 @@ -# 饿了么每日自动领取任务及吃货豆 - -http-request ^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply requires-body=1,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,tag=饿了么_获取cookie -cron "10 00 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js,timeout=60,tag=饿了么_领取吃货豆 -cron "00 10 * * *" script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js,timeout=60,tag=饿了么_领取会员任务 - -hostname = h5.ele.me \ No newline at end of file diff --git a/script/eleme/eleme_daily.qxrewrite b/script/eleme/eleme_daily.qxrewrite index a061e6fe0..ea747cc16 100644 --- a/script/eleme/eleme_daily.qxrewrite +++ b/script/eleme/eleme_daily.qxrewrite @@ -1,5 +1,8 @@ # 饿了么每日自动领取任务及吃货豆 +^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-foodie-card\/home url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-home-tasklist-new\/home url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +^https?:\/\/tb\.ele\.me\/wow\/alsc\/mod url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js ^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js -hostname = h5.ele.me \ No newline at end of file +hostname = air.tb.ele.me,tb.ele.me,h5.ele.me \ No newline at end of file diff --git a/script/eleme/eleme_daily.sgmodule b/script/eleme/eleme_daily.sgmodule index 89b70454b..733df797e 100644 --- a/script/eleme/eleme_daily.sgmodule +++ b/script/eleme/eleme_daily.sgmodule @@ -3,9 +3,12 @@ #!system=ios [Script] -饿了么_领取吃货豆 = type=cron,cronexp=10 00 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js -饿了么_领取任务 = type=cron,cronexp=00 10 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js -饿了么_获取cookie = type=http-request,pattern=^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +饿了么_领取吃货豆 = type=cron,cronexp=10 09 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +饿了么_领取任务 = type=cron,cronexp=15 09 * * *,timeout=60,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_mission.js +饿了么_获取坐标1 = type=http-request,pattern=^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-home-tasklist-new\/home,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +饿了么_获取坐标2 = type=http-request,pattern=^https?:\/\/tb\.ele\.me\/wow\/alsc\/mod,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +饿了么_获取坐标3 = type=http-request,pattern=^https?:\/\/h5\.ele\.me\/restapi\/biz\.svip_scene\/svip\/engine\/queryTrafficSupply,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js +饿了么_Cookies = type=http-request,pattern=^https?:\/\/air\.tb\.ele\.me\/app\/conch-page\/svip-foodie-card\/home,script-path=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/eleme/eleme_daily.js [MITM] -hostname = %APPEND% h5.ele.me \ No newline at end of file +hostname = %APPEND% air.tb.ele.me,tb.ele.me,h5.ele.me \ No newline at end of file diff --git a/script/eleme/eleme_mission.js b/script/eleme/eleme_mission.js index 77bdd96ec..b18db7b35 100644 --- a/script/eleme/eleme_mission.js +++ b/script/eleme/eleme_mission.js @@ -2,16 +2,18 @@ const scriptName = "饿了么"; const elemeCookieKey = "eleme_app_cookie"; const elemeLongitudeKey = "eleme_app_longitude"; const elemeLatitudeKey = "eleme_app_latitude"; -// 以下条件是AND的关系 -const taskKeywords = ["美食外卖"]; // 任务JSON中含有此关键字的任务才会领取 -const requiredOrderAmount = 4; // 需要完成订单数量小于等于此数的任务才会领取 +const elemeTaskKey = "eleme_task_keywords"; let magicJS = MagicJS(scriptName, "INFO"); -magicJS.unifiedPushUrl = magicJS.read("eleme_app_unified_push_url") || magicJS.read("magicjs_unified_push_url"); +magicJS.barkUrl = magicJS.read("bark_url"); // 获取超级会员任务列表 function GetSuperVipMissions(cookie, longitude, latitude) { return new Promise((resolve, reject) => { + // 获取配置的任务关键词 + const taskKeywords = magicJS.read(elemeTaskKey).split(';'); + magicJS.logInfo(`只获取含有以下关键词的任务:${magicJS.read(elemeTaskKey)}`); + let options = { url: `https://h5.ele.me/restapi/svip_biz/v1/supervip/query_mission_list?longitude=${longitude}&latitude=${latitude}`, headers: { @@ -42,7 +44,7 @@ function GetSuperVipMissions(cookie, longitude, latitude) { let missionInfo = JSON.stringify(element); let flag = false; for (keyword of taskKeywords) { - if (missionInfo.indexOf(keyword) >= 0 && element.required_order_amount <= requiredOrderAmount) { + if (missionInfo.indexOf(keyword) >= 0) { flag = true; break; } @@ -154,4 +156,4 @@ function AcceptMission(cookie, longitude, latitude, mission_id) { })(); // prettier-ignore -function MagicJS(e="MagicJS",t="INFO"){const s={accept:"Accept","accept-ch":"Accept-CH","accept-charset":"Accept-Charset","accept-features":"Accept-Features","accept-encoding":"Accept-Encoding","accept-language":"Accept-Language","accept-ranges":"Accept-Ranges","access-control-allow-credentials":"Access-Control-Allow-Credentials","access-control-allow-origin":"Access-Control-Allow-Origin","access-control-allow-methods":"Access-Control-Allow-Methods","access-control-allow-headers":"Access-Control-Allow-Headers","access-control-max-age":"Access-Control-Max-Age","access-control-expose-headers":"Access-Control-Expose-Headers","access-control-request-method":"Access-Control-Request-Method","access-control-request-headers":"Access-Control-Request-Headers",age:"Age",allow:"Allow",alternates:"Alternates",authorization:"Authorization","cache-control":"Cache-Control",connection:"Connection","content-encoding":"Content-Encoding","content-language":"Content-Language","content-length":"Content-Length","content-location":"Content-Location","content-md5":"Content-MD5","content-range":"Content-Range","content-security-policy":"Content-Security-Policy","content-type":"Content-Type",cookie:"Cookie",dnt:"DNT",date:"Date",etag:"ETag",expect:"Expect",expires:"Expires",from:"From",host:"Host","if-match":"If-Match","if-modified-since":"If-Modified-Since","if-none-match":"If-None-Match","if-range":"If-Range","if-unmodified-since":"If-Unmodified-Since","last-event-id":"Last-Event-ID","last-modified":"Last-Modified",link:"Link",location:"Location","max-forwards":"Max-Forwards",negotiate:"Negotiate",origin:"Origin",pragma:"Pragma","proxy-authenticate":"Proxy-Authenticate","proxy-authorization":"Proxy-Authorization",range:"Range",referer:"Referer","retry-after":"Retry-After","sec-websocket-extensions":"Sec-Websocket-Extensions","sec-websocket-key":"Sec-Websocket-Key","sec-websocket-origin":"Sec-Websocket-Origin","sec-websocket-protocol":"Sec-Websocket-Protocol","sec-websocket-version":"Sec-Websocket-Version",server:"Server","set-cookie":"Set-Cookie","set-cookie2":"Set-Cookie2","strict-transport-security":"Strict-Transport-Security",tcn:"TCN",te:"TE",trailer:"Trailer","transfer-encoding":"Transfer-Encoding",upgrade:"Upgrade","user-agent":"User-Agent","variant-vary":"Variant-Vary",vary:"Vary",via:"Via",warning:"Warning","www-authenticate":"WWW-Authenticate","x-content-duration":"X-Content-Duration","x-content-security-policy":"X-Content-Security-Policy","x-dnsprefetch-control":"X-DNSPrefetch-Control","x-frame-options":"X-Frame-Options","x-requested-with":"X-Requested-With","x-surge-skip-scripting":"X-Surge-Skip-Scripting"};return new class{constructor(){this.version="2.2.3.3";this.scriptName=e;this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};this.isLoon=typeof $loon!=="undefined";this.isQuanX=typeof $task!=="undefined";this.isJSBox=typeof $drive!=="undefined";this.isNode=typeof module!=="undefined"&&!this.isJSBox;this.isSurge=typeof $httpClient!=="undefined"&&!this.isLoon;this.platform=this.getPlatform();this.node={request:undefined,fs:undefined,data:{}};this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1";this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59";this.logLevel=t;this._unifiedPushUrl="";if(this.isNode){this.node.fs=require("fs");this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(e){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else if(this.isJSBox){if(!$file.exists("drive://MagicJS")){$file.mkdir("drive://MagicJS")}if(!$file.exists("drive://MagicJS/magic.json")){$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"})}}}set unifiedPushUrl(e){this._unifiedPushUrl=!!e?e.replace(/\/+$/g,""):""}set logLevel(e){this._logLevel=typeof e==="string"?e.toUpperCase():"DEBUG"}get logLevel(){return this._logLevel}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}getPlatform(){if(this.isSurge)return"Surge";else if(this.isQuanX)return"QuantumultX";else if(this.isLoon)return"Loon";else if(this.isJSBox)return"JSBox";else if(this.isNode)return"Node.js";else return"unknown"}read(e,t=""){let s="";if(this.isSurge||this.isLoon){s=$persistentStore.read(e)}else if(this.isQuanX){s=$prefs.valueForKey(e)}else if(this.isNode){s=this.node.data}else if(this.isJSBox){s=$file.read("drive://MagicJS/magic.json").string}try{if(this.isNode)s=s[e];if(this.isJSBox)s=JSON.parse(s)[e];if(!!t){if(typeof s==="string")s=JSON.parse(s);s=!!s&&typeof s==="object"?s[t]:null}}catch(i){this.logError(i);s=!!t?{}:null;this.del(e)}if(typeof s==="undefined")s=null;try{if(!!s&&typeof s==="string")s=JSON.parse(s)}catch(e){}this.logDebug(`READ DATA [${e}]${!!t?`[${t}]`:""}(${typeof s})\n${JSON.stringify(s)}`);return s}write(e,t,s=""){let i=!!s?{}:"";if(!!s&&(this.isSurge||this.isLoon)){i=$persistentStore.read(e)}else if(!!s&&this.isQuanX){i=$prefs.valueForKey(e)}else if(this.isNode){i=this.node.data}else if(this.isJSBox){i=JSON.parse($file.read("drive://MagicJS/magic.json").string)}if(!!s){try{if(typeof i==="string")i=JSON.parse(i);i=typeof i==="object"&&!!i?i:{}}catch(t){this.logError(t);this.del(e);i={}}if(this.isJSBox||this.isNode){if(!i.hasOwnProperty(e)||typeof i[e]!=="object"||i[e]===null){i[e]={}}if(!i[e].hasOwnProperty(s)){i[e][s]=null}if(typeof t==="undefined"){delete i[e][s]}else{i[e][s]=t}}else{if(typeof t==="undefined"){delete i[s]}else{i[s]=t}}}else{if(this.isNode||this.isJSBox){if(typeof t==="undefined"){delete i[e]}else{i[e]=t}}else{if(typeof t==="undefined"){i=null}else{i=t}}}if(typeof i==="object")i=JSON.stringify(i);if(this.isSurge||this.isLoon){$persistentStore.write(i,e)}else if(this.isQuanX){$prefs.setValueForKey(i,e)}else if(this.isNode){this.node.fs.writeFileSync("./magic.json",i)}else if(this.isJSBox){$file.write({data:$data({string:i}),path:"drive://MagicJS/magic.json"})}this.logDebug(`WRITE DATA [${e}]${!!s?`[${s}]`:""}(${typeof t})\n${JSON.stringify(t)}`)}del(e,t=""){this.logDebug(`DELETE KEY [${e}]${!!t?`[${t}]`:""}`);this.write(e,null,t)}notify(e=this.scriptName,t="",s="",i=""){let o=e=>{let t={};if(this.isSurge||this.isQuanX||this.isLoon){if(typeof e==="string"){if(this.isLoon)t={openUrl:e};else if(this.isQuanX)t={"open-url":e};else if(this.isSurge)t={url:e}}else if(typeof e==="object"){let s={Surge:{openUrl:"url","open-url":"url"},Loon:{url:"openUrl","open-url":"openUrl","media-url":"mediaUrl"},QuantumultX:{url:"open-url",openUrl:"open-url",mediaUrl:"media-url"}};let i=Object.keys(e);for(let o=0;o{})}if(this.isSurge||this.isLoon){$notification.post(e,t,s,i)}else if(this.isQuanX){$notify(e,t,s,i)}else if(this.isJSBox){let i={title:e,body:!!t?`${t}\n${s}`:s};$push.schedule(i)}}log(e,t="INFO"){if(!(this.logLevels[this._logLevel]{if(typeof i.body==="undefined")return"";return`${encodeURIComponent(e)}=${encodeURIComponent(i.body[e])}`}).join("&");if(i.url.indexOf("?")<0)i.url+="?";if(i.url.lastIndexOf("&")+1!=i.url.length&&i.url.lastIndexOf("?")+1!=i.url.length)i.url+="&";i.url+=e;delete i.body}if(this.isQuanX){if(i.hasOwnProperty("body")&&typeof i["body"]!=="string")i["body"]=JSON.stringify(i["body"]);i["method"]=t}else if(this.isNode){delete i.headers["Accept-Encoding"];if(typeof i.body==="object"){if(t==="GET"){i.qs=i.body;delete i.body}else if(t==="POST"){i["json"]=true;i.body=i.body}}}else if(this.isJSBox){i["header"]=i["headers"];delete i["headers"]}return i}get(e,t){let s=this.adapterHttpOptions(e,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.get(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>t(e.error,null,null))}else if(this.isNode){return this.node.request.get(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.get(s)}}post(e,t){let s=this.adapterHttpOptions(e,"POST");this.logDebug(`HTTP POST: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.post(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>{t(e.error,null,null)})}else if(this.isNode){return this.node.request.post(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.post(s)}}done(e={}){if(typeof $done!=="undefined"){$done(e)}}isToday(e){if(e==null){return false}else{let t=new Date;if(typeof e=="string"){e=new Date(e)}if(t.getFullYear()==e.getFullYear()&&t.getMonth()==e.getMonth()&&t.getDay()==e.getDay()){return true}else{return false}}}isNumber(e){return parseFloat(e).toString()==="NaN"?false:true}attempt(e,t=null){return e.then(e=>{return[null,e]}).catch(e=>{this.logError(e);return[e,t]})}retry(e,t=5,s=0,i=null){return(...o)=>{return new Promise((r,n)=>{function a(...o){Promise.resolve().then(()=>e.apply(this,o)).then(e=>{if(typeof i==="function"){Promise.resolve().then(()=>i(e)).then(()=>{r(e)}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}else{r(e)}}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}a.apply(this,o)})}}formatTime(e,t="yyyy-MM-dd hh:mm:ss"){var s={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t))t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length));for(let e in s)if(new RegExp("("+e+")").test(t))t=t.replace(RegExp.$1,RegExp.$1.length==1?s[e]:("00"+s[e]).substr((""+s[e]).length));return t}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(e){return new Promise(t=>setTimeout(t,e))}}(e)} +function MagicJS(e="MagicJS",t="INFO"){const s={accept:"Accept","accept-ch":"Accept-CH","accept-charset":"Accept-Charset","accept-features":"Accept-Features","accept-encoding":"Accept-Encoding","accept-language":"Accept-Language","accept-ranges":"Accept-Ranges","access-control-allow-credentials":"Access-Control-Allow-Credentials","access-control-allow-origin":"Access-Control-Allow-Origin","access-control-allow-methods":"Access-Control-Allow-Methods","access-control-allow-headers":"Access-Control-Allow-Headers","access-control-max-age":"Access-Control-Max-Age","access-control-expose-headers":"Access-Control-Expose-Headers","access-control-request-method":"Access-Control-Request-Method","access-control-request-headers":"Access-Control-Request-Headers",age:"Age",allow:"Allow",alternates:"Alternates",authorization:"Authorization","cache-control":"Cache-Control",connection:"Connection","content-encoding":"Content-Encoding","content-language":"Content-Language","content-length":"Content-Length","content-location":"Content-Location","content-md5":"Content-MD5","content-range":"Content-Range","content-security-policy":"Content-Security-Policy","content-type":"Content-Type",cookie:"Cookie",dnt:"DNT",date:"Date",etag:"ETag",expect:"Expect",expires:"Expires",from:"From",host:"Host","if-match":"If-Match","if-modified-since":"If-Modified-Since","if-none-match":"If-None-Match","if-range":"If-Range","if-unmodified-since":"If-Unmodified-Since","last-event-id":"Last-Event-ID","last-modified":"Last-Modified",link:"Link",location:"Location","max-forwards":"Max-Forwards",negotiate:"Negotiate",origin:"Origin",pragma:"Pragma","proxy-authenticate":"Proxy-Authenticate","proxy-authorization":"Proxy-Authorization",range:"Range",referer:"Referer","retry-after":"Retry-After","sec-websocket-extensions":"Sec-Websocket-Extensions","sec-websocket-key":"Sec-Websocket-Key","sec-websocket-origin":"Sec-Websocket-Origin","sec-websocket-protocol":"Sec-Websocket-Protocol","sec-websocket-version":"Sec-Websocket-Version",server:"Server","set-cookie":"Set-Cookie","set-cookie2":"Set-Cookie2","strict-transport-security":"Strict-Transport-Security",tcn:"TCN",te:"TE",trailer:"Trailer","transfer-encoding":"Transfer-Encoding",upgrade:"Upgrade","user-agent":"User-Agent","variant-vary":"Variant-Vary",vary:"Vary",via:"Via",warning:"Warning","www-authenticate":"WWW-Authenticate","x-content-duration":"X-Content-Duration","x-content-security-policy":"X-Content-Security-Policy","x-dnsprefetch-control":"X-DNSPrefetch-Control","x-frame-options":"X-Frame-Options","x-requested-with":"X-Requested-With","x-surge-skip-scripting":"X-Surge-Skip-Scripting"};return new class{constructor(){this.version="2.2.3.3";this.scriptName=e;this.logLevels={DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};this.isLoon=typeof $loon!=="undefined";this.isQuanX=typeof $task!=="undefined";this.isJSBox=typeof $drive!=="undefined";this.isNode=typeof module!=="undefined"&&!this.isJSBox;this.isSurge=typeof $httpClient!=="undefined"&&!this.isLoon;this.platform=this.getPlatform();this.node={request:undefined,fs:undefined,data:{}};this.iOSUserAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1";this.pcUserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59";this.logLevel=t;this._unifiedPushUrl="";if(this.isNode){this.node.fs=require("fs");this.node.request=require("request");try{this.node.fs.accessSync("./magic.json",this.node.fs.constants.R_OK|this.node.fs.constants.W_OK)}catch(e){this.node.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}this.node.data=require("./magic.json")}else if(this.isJSBox){if(!$file.exists("drive://MagicJS")){$file.mkdir("drive://MagicJS")}if(!$file.exists("drive://MagicJS/magic.json")){$file.write({data:$data({string:"{}"}),path:"drive://MagicJS/magic.json"})}}}set barkUrl(e){this._unifiedPushUrl=!!e?e.replace(/\/+$/g,""):""}set logLevel(e){this._logLevel=typeof e==="string"?e.toUpperCase():"DEBUG"}get logLevel(){return this._logLevel}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}getPlatform(){if(this.isSurge)return"Surge";else if(this.isQuanX)return"QuantumultX";else if(this.isLoon)return"Loon";else if(this.isJSBox)return"JSBox";else if(this.isNode)return"Node.js";else return"unknown"}read(e,t=""){let s="";if(this.isSurge||this.isLoon){s=$persistentStore.read(e)}else if(this.isQuanX){s=$prefs.valueForKey(e)}else if(this.isNode){s=this.node.data}else if(this.isJSBox){s=$file.read("drive://MagicJS/magic.json").string}try{if(this.isNode)s=s[e];if(this.isJSBox)s=JSON.parse(s)[e];if(!!t){if(typeof s==="string")s=JSON.parse(s);s=!!s&&typeof s==="object"?s[t]:null}}catch(i){this.logError(i);s=!!t?{}:null;this.del(e)}if(typeof s==="undefined")s=null;try{if(!!s&&typeof s==="string")s=JSON.parse(s)}catch(e){}this.logDebug(`READ DATA [${e}]${!!t?`[${t}]`:""}(${typeof s})\n${JSON.stringify(s)}`);return s}write(e,t,s=""){let i=!!s?{}:"";if(!!s&&(this.isSurge||this.isLoon)){i=$persistentStore.read(e)}else if(!!s&&this.isQuanX){i=$prefs.valueForKey(e)}else if(this.isNode){i=this.node.data}else if(this.isJSBox){i=JSON.parse($file.read("drive://MagicJS/magic.json").string)}if(!!s){try{if(typeof i==="string")i=JSON.parse(i);i=typeof i==="object"&&!!i?i:{}}catch(t){this.logError(t);this.del(e);i={}}if(this.isJSBox||this.isNode){if(!i.hasOwnProperty(e)||typeof i[e]!=="object"||i[e]===null){i[e]={}}if(!i[e].hasOwnProperty(s)){i[e][s]=null}if(typeof t==="undefined"){delete i[e][s]}else{i[e][s]=t}}else{if(typeof t==="undefined"){delete i[s]}else{i[s]=t}}}else{if(this.isNode||this.isJSBox){if(typeof t==="undefined"){delete i[e]}else{i[e]=t}}else{if(typeof t==="undefined"){i=null}else{i=t}}}if(typeof i==="object")i=JSON.stringify(i);if(this.isSurge||this.isLoon){$persistentStore.write(i,e)}else if(this.isQuanX){$prefs.setValueForKey(i,e)}else if(this.isNode){this.node.fs.writeFileSync("./magic.json",i)}else if(this.isJSBox){$file.write({data:$data({string:i}),path:"drive://MagicJS/magic.json"})}this.logDebug(`WRITE DATA [${e}]${!!s?`[${s}]`:""}(${typeof t})\n${JSON.stringify(t)}`)}del(e,t=""){this.logDebug(`DELETE KEY [${e}]${!!t?`[${t}]`:""}`);this.write(e,null,t)}notify(e=this.scriptName,t="",s="",i=""){let o=e=>{let t={};if(this.isSurge||this.isQuanX||this.isLoon){if(typeof e==="string"){if(this.isLoon)t={openUrl:e};else if(this.isQuanX)t={"open-url":e};else if(this.isSurge)t={url:e}}else if(typeof e==="object"){let s={Surge:{openUrl:"url","open-url":"url"},Loon:{url:"openUrl","open-url":"openUrl","media-url":"mediaUrl"},QuantumultX:{url:"open-url",openUrl:"open-url",mediaUrl:"media-url"}};let i=Object.keys(e);for(let o=0;o{})}if(this.isSurge||this.isLoon){$notification.post(e,t,s,i)}else if(this.isQuanX){$notify(e,t,s,i)}else if(this.isJSBox){let i={title:e,body:!!t?`${t}\n${s}`:s};$push.schedule(i)}}log(e,t="INFO"){if(!(this.logLevels[this._logLevel]{if(typeof i.body==="undefined")return"";return`${encodeURIComponent(e)}=${encodeURIComponent(i.body[e])}`}).join("&");if(i.url.indexOf("?")<0)i.url+="?";if(i.url.lastIndexOf("&")+1!=i.url.length&&i.url.lastIndexOf("?")+1!=i.url.length)i.url+="&";i.url+=e;delete i.body}if(this.isQuanX){if(i.hasOwnProperty("body")&&typeof i["body"]!=="string")i["body"]=JSON.stringify(i["body"]);i["method"]=t}else if(this.isNode){delete i.headers["Accept-Encoding"];if(typeof i.body==="object"){if(t==="GET"){i.qs=i.body;delete i.body}else if(t==="POST"){i["json"]=true;i.body=i.body}}}else if(this.isJSBox){i["header"]=i["headers"];delete i["headers"]}return i}get(e,t){let s=this.adapterHttpOptions(e,"GET");this.logDebug(`HTTP GET: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.get(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>t(e.error,null,null))}else if(this.isNode){return this.node.request.get(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.get(s)}}post(e,t){let s=this.adapterHttpOptions(e,"POST");this.logDebug(`HTTP POST: ${JSON.stringify(s)}`);if(this.isSurge||this.isLoon){$httpClient.post(s,t)}else if(this.isQuanX){$task.fetch(s).then(e=>{e["status"]=e.statusCode;t(null,e,e.body)},e=>{t(e.error,null,null)})}else if(this.isNode){return this.node.request.post(s,t)}else if(this.isJSBox){s["handler"]=(e=>{let s=e.error?JSON.stringify(e.error):undefined;let i=typeof e.data==="object"?JSON.stringify(e.data):e.data;t(s,e.response,i)});$http.post(s)}}done(e={}){if(typeof $done!=="undefined"){$done(e)}}isToday(e){if(e==null){return false}else{let t=new Date;if(typeof e=="string"){e=new Date(e)}if(t.getFullYear()==e.getFullYear()&&t.getMonth()==e.getMonth()&&t.getDay()==e.getDay()){return true}else{return false}}}isNumber(e){return parseFloat(e).toString()==="NaN"?false:true}attempt(e,t=null){return e.then(e=>{return[null,e]}).catch(e=>{this.logError(e);return[e,t]})}retry(e,t=5,s=0,i=null){return(...o)=>{return new Promise((r,n)=>{function a(...o){Promise.resolve().then(()=>e.apply(this,o)).then(e=>{if(typeof i==="function"){Promise.resolve().then(()=>i(e)).then(()=>{r(e)}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}else{r(e)}}).catch(e=>{this.logError(e);if(t>=1&&s>0){setTimeout(()=>a.apply(this,o),s)}else if(t>=1){a.apply(this,o)}else{n(e)}t--})}a.apply(this,o)})}}formatTime(e,t="yyyy-MM-dd hh:mm:ss"){var s={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t))t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length));for(let e in s)if(new RegExp("("+e+")").test(t))t=t.replace(RegExp.$1,RegExp.$1.length==1?s[e]:("00"+s[e]).substr((""+s[e]).length));return t}now(){return this.formatTime(new Date,"yyyy-MM-dd hh:mm:ss")}today(){return this.formatTime(new Date,"yyyy-MM-dd")}sleep(e){return new Promise(t=>setTimeout(t,e))}}(e)} diff --git a/script/eleme/images/bark_conf.jpg b/script/eleme/images/bark_conf.jpg new file mode 100644 index 000000000..319ccc11f Binary files /dev/null and b/script/eleme/images/bark_conf.jpg differ diff --git a/script/gallery.json b/script/gallery.json index e882d303f..94528aed1 100644 --- a/script/gallery.json +++ b/script/gallery.json @@ -1,9 +1,5 @@ {"name":"blackmatrix7", "task":[ - { - "config":"15 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/10010/unicom_signin.js, tag=中国联通, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/10010/10010.png, enabled=true", - "addons":"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/10010/unicom_signin.qxrewrite,tag=联通_获取Cookie" - }, { "config":"20 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong_checkin.js, tag=叮咚买菜, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong.png, enabled=true", "addons":"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/dingdong/dingdong_checkin.qxrewrite,tag=叮咚买菜_获取Cookie" @@ -40,10 +36,6 @@ "config":"20 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_mission.js, tag=每日任务, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm.png, enabled=true", "addons":"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/smzdm/smzdm_signin.qxrewrite,tag=什么值得买_获取Cookie" }, - { - "config":"20 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/wanda/wanda_checkin.js, tag=万达电影, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/wanda/wanda.png, enabled=true", - "addons":"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/wanda/wanda_checkin.qxrewrite,tag=万达_获取Cookie" - }, { "config":"30 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai_checkin.js, tag=美团买菜, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png, enabled=true", "addons":"https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai_checkin.qxrewrite,tag=美团买菜_获取Cookie" diff --git a/script/jiazhangbang/jiazhangbang_checkin.js b/script/obsolete/jiazhangbang/jiazhangbang_checkin.js similarity index 100% rename from script/jiazhangbang/jiazhangbang_checkin.js rename to script/obsolete/jiazhangbang/jiazhangbang_checkin.js diff --git a/script/jiazhangbang/jiazhangbang_checkin.sgmodule b/script/obsolete/jiazhangbang/jiazhangbang_checkin.sgmodule similarity index 100% rename from script/jiazhangbang/jiazhangbang_checkin.sgmodule rename to script/obsolete/jiazhangbang/jiazhangbang_checkin.sgmodule diff --git a/script/wanda/README.md b/script/obsolete/wanda/README.md similarity index 100% rename from script/wanda/README.md rename to script/obsolete/wanda/README.md diff --git a/script/wanda/wanda.png b/script/obsolete/wanda/wanda.png similarity index 100% rename from script/wanda/wanda.png rename to script/obsolete/wanda/wanda.png diff --git a/script/wanda/wanda_checkin.js b/script/obsolete/wanda/wanda_checkin.js similarity index 100% rename from script/wanda/wanda_checkin.js rename to script/obsolete/wanda/wanda_checkin.js diff --git a/script/wanda/wanda_checkin.lnscript b/script/obsolete/wanda/wanda_checkin.lnscript similarity index 100% rename from script/wanda/wanda_checkin.lnscript rename to script/obsolete/wanda/wanda_checkin.lnscript diff --git a/script/wanda/wanda_checkin.qxrewrite b/script/obsolete/wanda/wanda_checkin.qxrewrite similarity index 100% rename from script/wanda/wanda_checkin.qxrewrite rename to script/obsolete/wanda/wanda_checkin.qxrewrite diff --git a/script/wanda/wanda_checkin.sgmodule b/script/obsolete/wanda/wanda_checkin.sgmodule similarity index 100% rename from script/wanda/wanda_checkin.sgmodule rename to script/obsolete/wanda/wanda_checkin.sgmodule