|
|
@@ -5,17 +5,15 @@
|
|
|
|
|
|
[rewrite_local]
|
|
|
|
|
|
+^https?:\/\/maicai\.api\.ddxq\.mobi\/point\/home\?api_version url script-request-header https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/dingdong/dingdongHelper.js
|
|
|
^https?:\/\/maicai\.api\.ddxq\.mobi url script-request-body https://git.jojo21.top/shawenguan/Quantumult-X/raw/master/Scripts/dingdong/dingdongHelper.js
|
|
|
|
|
|
[MITM]
|
|
|
-
|
|
|
+=
|
|
|
hostname=maicai.api.ddxq.mobi
|
|
|
|
|
|
********************************/
|
|
|
-console.log("#########test############");
|
|
|
-
|
|
|
const scriptName = '叮咚买菜';
|
|
|
-const getCookieRegex = /^https?:\/\/maicai\.api\.ddxq\.mobi\/point\/home\?api_version/;
|
|
|
const dingDongCookieKey = 'dingdongmaicai_checkin_cookie';
|
|
|
const dingDongBodyKey = 'dingdongmaicai_checkin_body';
|
|
|
const dingDongSyncQinglongKey = 'dingdongmaicai_sync_qinglong';
|
|
|
@@ -27,14 +25,8 @@ let currentBody = "";
|
|
|
let userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 xzone/11.16.0 station_id/5f1ea5ed3f34a90001d0b0f3 device_id/87721fd44a221da0d8aabdee75c37f575d7b44ec';
|
|
|
|
|
|
async function Main() {
|
|
|
- if(magicJS.request){
|
|
|
- magicJS.logger.info(magicJS.request.url);
|
|
|
- }
|
|
|
- magicJS.logger.info(!!$request);
|
|
|
- magicJS.logger.info(!!$response);
|
|
|
- magicJS.logger.info(`isRequest=${magicJS.isRequest}`);
|
|
|
- if (typeof $request != "undefined") {
|
|
|
- handleRequest();
|
|
|
+ if (typeof magicJS.request != "undefined") {
|
|
|
+ checkHandleRequest();
|
|
|
} else {
|
|
|
const allSessions = magicJS.data.allSessionNames(dingDongCookieKey);
|
|
|
if (!allSessions || allSessions.length <= 0) {
|
|
|
@@ -59,40 +51,57 @@ async function Main() {
|
|
|
magicJS.done();
|
|
|
}
|
|
|
|
|
|
-function handleRequest(){
|
|
|
+async function checkHandleRequest(){
|
|
|
const request = magicJS.request;
|
|
|
+ magicJS.logger.info(request.url);
|
|
|
+ magicJS.logger.info(`请求url=${url}#${request.method}`);
|
|
|
+ if(request.method != 'OPTIONS'){
|
|
|
+ return;
|
|
|
+ }
|
|
|
const url = request.url;
|
|
|
const path = request.path;
|
|
|
- magicJS.logger.info(`请求url=${url}#${$request.method}`);
|
|
|
magicJS.logger.info(`path=${path}`);
|
|
|
- // if(getCookieRegex.test(request.url)){
|
|
|
- // const cookie = request.headers.Cookie;
|
|
|
- // const body = request.url.split('?')[1];
|
|
|
- // // 获取UserId
|
|
|
- // const userId = await magicJS.utils.retry(getUserId, 3, 500)(cookie).catch(err => {
|
|
|
- // magicJS.notification.post(err);
|
|
|
- // magicJS.done();
|
|
|
- // });
|
|
|
- // let hisCookie = magicJS.data.read(dingDongCookieKey, "", userId);
|
|
|
- // if (cookie !== hisCookie) {
|
|
|
- // magicJS.data.write(dingDongCookieKey, cookie, userId);
|
|
|
- // magicJS.data.write(dingDongBodyKey, body, userId);
|
|
|
- // magicJS.logger.info(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`);
|
|
|
- // magicJS.notification.post("🎈Cookie写入成功!!");
|
|
|
- // } else {
|
|
|
- // magicJS.logger.info("Cookie没有变化,无需更新");
|
|
|
- // }
|
|
|
- // // 同步Cookies至青龙面板
|
|
|
- // if (magicJS.data.read(dingDongSyncQinglongKey, false) === true) {
|
|
|
- // hisCookie = await magicJS.qinglong.read(dingDongCookieKey, "", userId);
|
|
|
- // if (cookie !== hisCookie) {
|
|
|
- // await magicJS.qinglong.write(dingDongCookieKey, cookie, userId);
|
|
|
- // await magicJS.qinglong.write(dingDongBodyKey, body, userId);
|
|
|
- // magicJS.logger.info(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`);
|
|
|
- // magicJS.notification.post("🎈Cookie同步到青龙面板成功!!");
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ if (path.match(/\/point\/home/)) {
|
|
|
+ handlePointHomeData();
|
|
|
+ } else if (path.match(/\/user\/info/)) {
|
|
|
+ handlePointHomeData();
|
|
|
+ } else {
|
|
|
+ switch (path) {
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handlePointHomeData(){
|
|
|
+ const request = magicJS.request;
|
|
|
+ const cookie = request.headers.Cookie;
|
|
|
+ const body = request.url.split('?')[1];
|
|
|
+ // 获取UserId
|
|
|
+ const userId = await magicJS.utils.retry(getUserId, 3, 500)(cookie).catch(err => {
|
|
|
+ magicJS.notification.post(err);
|
|
|
+ magicJS.done();
|
|
|
+ });
|
|
|
+ let hisCookie = magicJS.data.read(dingDongCookieKey, "", userId);
|
|
|
+ if (cookie !== hisCookie) {
|
|
|
+ magicJS.data.write(dingDongCookieKey, cookie, userId);
|
|
|
+ magicJS.data.write(dingDongBodyKey, body, userId);
|
|
|
+ magicJS.logger.info(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`);
|
|
|
+ magicJS.notification.post("🎈Cookie写入成功!!");
|
|
|
+ } else {
|
|
|
+ magicJS.logger.info("Cookie没有变化,无需更新");
|
|
|
+ }
|
|
|
+ // 同步Cookies至青龙面板
|
|
|
+ if (magicJS.data.read(dingDongSyncQinglongKey, false) === true) {
|
|
|
+ hisCookie = await magicJS.qinglong.read(dingDongCookieKey, "", userId);
|
|
|
+ if (cookie !== hisCookie) {
|
|
|
+ await magicJS.qinglong.write(dingDongCookieKey, cookie, userId);
|
|
|
+ await magicJS.qinglong.write(dingDongBodyKey, body, userId);
|
|
|
+ magicJS.logger.info(`旧的Cookie:${hisCookie}\n新的Cookie:${cookie}\nCookie不同,写入新的Cookie成功!`);
|
|
|
+ magicJS.notification.post("🎈Cookie同步到青龙面板成功!!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function getUserId(cookie) {
|