diff --git a/Loon/lxk0301_LoonTask.conf b/Loon/lxk0301_LoonTask.conf index 63977d1f..13ff0c41 100644 --- a/Loon/lxk0301_LoonTask.conf +++ b/Loon/lxk0301_LoonTask.conf @@ -120,6 +120,6 @@ cron "10-20/5 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd # 金融打卡领年终奖 # 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=健康抽奖机 +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/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index ac722056..f359b012 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -61,8 +61,6 @@ cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script 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=京东健康 #京东赚赚 @@ -73,5 +71,5 @@ cron "20 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scri 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 2 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.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 26022817..e2d04104 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/activity/jd_jxstory.js b/activity/jd_jxstory.js index cd46e3ed..45c79941 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/activity/jd_pubg.js b/activity/jd_pubg.js index bed15df4..cc22b60c 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/backUp/iOS_Weather_AQI_Standard.js b/backUp/iOS_Weather_AQI_Standard.js new file mode 100644 index 00000000..dfb22941 --- /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/docker/Readme.md b/docker/Readme.md index beb03302..922a84a7 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 29945110..4dbf59b8 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -5,7 +5,7 @@ ##############短期活动############## # 健康抽奖机(2020.12.31活动过期) -10 0 1-31 12 * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 +10 0 * * * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 ##############长期活动############## # 签到 0 0,18 * * * cd /scripts && node jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 diff --git a/docker/default_task.sh b/docker/default_task.sh index caf4f6d1..26da7f0f 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/jdCookie.js b/jdCookie.js index 4eb2bb76..f24b3983 100644 --- a/jdCookie.js +++ b/jdCookie.js @@ -15,18 +15,13 @@ 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]; diff --git a/jd_bean_sign.js b/jd_bean_sign.js index accf5990..fb3fee0e 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-4 从 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()) { @@ -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_crazy_joy.js b/jd_crazy_joy.js index a87e8711..f1d1f5d9 100644 --- a/jd_crazy_joy.js +++ b/jd_crazy_joy.js @@ -666,7 +666,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index 2333f2f8..713a46f9 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -34,7 +34,7 @@ const randomCount = $.isNode() ? 20 : 5; 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) => { @@ -1305,7 +1305,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面`) + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_fruit.js b/jd_fruit.js index 03185eb1..2cb8ec94 100644 --- a/jd_fruit.js +++ b/jd_fruit.js @@ -1239,7 +1239,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取个${randomCount}码放到您固定的互助码后面`) + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_health.js b/jd_health.js index ee4ffe9b..b05005d0 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 b756da1d..546b7109 100644 --- a/jd_jdfactory.js +++ b/jd_jdfactory.js @@ -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`) } } } @@ -535,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 + } } } } @@ -624,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 f5da3632..5ea61aa2 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_reward.js b/jd_joy_reward.js index 6878e769..2eaf482d 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -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`); } @@ -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_pet.js b/jd_pet.js index 9b19c20f..cde3fd7f 100644 --- a/jd_pet.js +++ b/jd_pet.js @@ -442,7 +442,7 @@ function readShareCode() { console.log(`${$.name} API请求失败,请检查网路重试`) } else { if (data) { - console.log(`随机取个${randomCount}码放到您固定的互助码后面`) + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) data = JSON.parse(data); } } diff --git a/jd_plantBean.js b/jd_plantBean.js index 8fbe3d0f..c573903e 100644 --- a/jd_plantBean.js +++ b/jd_plantBean.js @@ -521,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 096519e6..46a21a0b 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 - // } - // } } } }