diff --git a/jd_jxnc.js b/jd_jxnc.js index 31424165..0034ac55 100644 --- a/jd_jxnc.js +++ b/jd_jxnc.js @@ -57,10 +57,8 @@ $.allTask = []; // 任务列表 $.info = {}; // 用户信息 $.answer = 3; $.drip = 0; -$.maxHelpNum = $.isNode() ? 8 : 3; // 助力 ret 1011 错误最大计数 -$.helpNum = 0; // 当前账号 助力 ret 1011 次数 -$.maxHelpSelfNum = 3; // 助力 自身 ret 1021 cannot help self 最大次数限制(防止随机API不停返回自身 code 导致死循环) -$.helpSelfNum = 0; // 当前账号 助力 ret 1021 cannot help self 次数 +$.maxHelpNum = $.isNode() ? 8 : 4; // 随机助力最大执行次数 +$.helpNum = 0; // 当前账号 随机助力次数 let assistUserShareCode = 0; // 随机助力用户 share code !(async () => { @@ -92,7 +90,6 @@ let assistUserShareCode = 0; // 随机助力用户 share code option = {}; $.answer = 3; $.helpNum = 0; - $.helpSelfNum = 0; notifyBool = notifyLevel > 0; // 初始化是否推送 await tokenFormat(); // 处理当前账号 token await shareCodesFormat(); // 处理当前账号 助力码 @@ -137,7 +134,7 @@ function requireConfig() { tokenArr.push(jdTokenNode[item] ? JSON.parse(jdTokenNode[item]) : tokenNull) }) } else { - tokenArr.push(...[$.getdata('jxnc_token1') || tokenNull, $.getdata('jxnc_token2') || tokenNull]); + tokenArr.push(...[JSON.parse($.getdata('jxnc_token1')) || tokenNull, JSON.parse($.getdata('jxnc_token2')) || tokenNull]) } if ($.isNode()) { @@ -247,7 +244,8 @@ async function jdJXNC() { await $.wait(500); let next = await helpFriends(); if (next) { - while (true) { + while ($.helpNum < $.maxHelpNum) { + $.helpNum++; assistUserShareCode = await getAssistUser(); if (assistUserShareCode) { await $.wait(300); @@ -496,21 +494,12 @@ function helpShareCode(code) { const res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/)[1]; const {ret, retmsg = ''} = JSON.parse(res); $.log(`助力结果:ret=${ret} retmsg="${retmsg ? retmsg : 'OK'}"`); - if (ret === 0) { // 0 助力成功 + // ret=0 助力成功 + // ret=1021 cannot help self 不能助力自己 + // ret=1011 active 不同 + if (ret === 0 || ret === 1021 || ret === 1011) { // 0 助力成功 resolve(true); } - if (ret === 1021) { // 1021 cannot help self 不能助力自己 - $.helpSelfNum++; - if ($.helpSelfNum <= $.maxHelpSelfNum) { - resolve(true); - } - } - if (ret === 1011) { // 1011 active 不同 - $.helpNum++; - if ($.helpNum <= $.maxHelpNum) { - resolve(true); - } - } // ret 1016 助力上限 } catch (e) { $.logErr(e, resp); diff --git a/update_task.sh b/update_task.sh new file mode 100644 index 00000000..c5283fad --- /dev/null +++ b/update_task.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +## Author: https://github.com/EvineDeng +## Modified: 2021-01-21 +## Version: v1.0.0 + +## 路径与清单 +WorkDir=$(cd $(dirname $0); pwd) +JsList=$(cd $WorkDir; ls *.js | grep -E "j[drx]_") +JsList="$JsList backUp/xmSports.js" +FileLoon=$WorkDir/Loon/lxk0301_LoonTask.conf +FileQx=$WorkDir/QuantumultX/lxk0301_gallery.json +FileQxRe=$WorkDir/QuantumultX/lxk0301_cookies.conf +FileSurge=$WorkDir/Surge/lxk0301_Task.sgmodule.sgmodule + +## task清单顶部内容 +CommentsLoon="# Loon软件Task配置 By LXK9301\n# GitHub主页(https://github.com/LXK9301/jd_scripts)\n# TG讨论组 (https://t.me/JD_fruit_pet)\n# TG通知频道 (https://t.me/jdfruit)\n# Loon的Task脚本订阅链接: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/Loon/lxk0301_LoonTask.conf\n# 使用方法:打开APP,顶部的配置 -> 脚本 -> 订阅脚本- > 点击右上角+号 -> 添加url链接 (https://raw.githubusercontent.com/LXK9301/jd_scripts/master/Loon/lxk0301_LoonTask.conf)\n\nhostname = api.m.jd.com, draw.jdfcloud.com, jdjoy.jd.com, account.huami.com" +CommentsQx='{\n "name": "LXK9301 task gallery",\n "description": "https://github.com/LXK9301/jd_scripts",\n "task": [' +CommentsQxRe="hostname = api.m.jd.com, draw.jdfcloud.com, jdjoy.jd.com, account.huami.com" +CommentsSurge="#!name=LXK9301 iOS Tasks Module\n#!desc=iOS Tasks 模块配置\n\n# Task模块配置 By LXK9301\n# GitHub主页(https://github.com/LXK9301/jd_scripts)\n# TG讨论组 (https://t.me/JD_fruit_pet)\n# TG通知频道 (https://t.me/jdfruit)\n# Surge的Task脚本模块地址: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/Surge/lxk0301_Task.sgmodule.sgmodule\n\n[Script]\n" + +## 执行写入 +cd $WorkDir +echo -e $CommentsLoon > $FileLoon +echo -e $CommentsQx > $FileQx +echo -e $CommentsQxRe > $FileQxRe +echo -e $CommentsSurge > $FileSurge +for file in $JsList +do + TaskName=$(grep "new Env" $file | awk -F "'|\"" '{print $2}') + if [[ -n $TaskName ]]; then + echo -e "\n# $TaskName" >> $FileLoon + grep -E "cron.+script-path.+https://raw\.githubusercontent\.com.+tag" $file >> $FileLoon + grep -E "https://raw\.githubusercontent\.com.+tag.+enabled" $file | perl -pe '{s|^| \"|; s|$|\",|}' >> $FileQx + grep -E "type.+cronexp.+script-path.+https://raw\.githubusercontent\.com" $file >> $FileSurge + fi + grep -E "http-(request|response).+script-path.+https://raw\.githubusercontent\.com.+tag" $file | perl -pe "s|(.+tag=)(.+)|\n# \2\n\1\2|">> $FileLoon + grep -E "script-(request|response)-.+https://raw\.githubusercontent\.com" $file | perl -pe "s|(.+)|\n# \n\1|" >> $FileQxRe + grep -E "type=http-(request|response).+pattern.+script-path.+https://raw\.githubusercontent\.com" $file >> $FileSurge +done +echo -e " ]\n}" >> $FileQx +perl -0777 -i -pe "s|,(\n \])|\1|" $FileQx +