From fcaadd0124c6d8fa1b2f2927d8c3f89b7ff4b562 Mon Sep 17 00:00:00 2001 From: wisz2021 Date: Fri, 21 May 2021 18:05:40 +0800 Subject: [PATCH] update --- jd_lotteryMachine.js | 27 ++++++++++++++++++++++----- jd_syj.js | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/jd_lotteryMachine.js b/jd_lotteryMachine.js index 23572b0c..6b514e0d 100644 --- a/jd_lotteryMachine.js +++ b/jd_lotteryMachine.js @@ -5,7 +5,7 @@ github: https://github.com/yangtingxiao 活动入口:京东APP中各种抽奖活动的汇总 修改自用 By lxk0301 -更新时间:2021-05-21 16:10 +更新时间:2021-05-21 18:10 */ const $ = new Env('京东抽奖机&内部互助'); const notify = $.isNode() ? require('./sendNotify') : ''; @@ -217,10 +217,27 @@ function harmony_collectScore(timeout = 0) { function updateShareCodes(url = 'https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js') { return new Promise(resolve => { - $.get({url, timeout: 10000}, async (err, resp, data) => { + const options = { + url: `${url}?${Date.now()}`, "timeout": 10000, 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" + } + }; + if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { + const tunnel = require("tunnel"); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: process.env.TG_PROXY_HOST, + port: process.env.TG_PROXY_PORT * 1 + } + }) + } + Object.assign(options, { agent }) + } + $.get(options, async (err, resp, data) => { try { if (err) { - console.log(`${JSON.stringify(err)}`) + console.log(`请求访问 【raw.githubusercontent.com】 的jd_lotteryMachine.js文件失败:${JSON.stringify(err)}\n\n下面使用 【cdn.jsdelivr.net】请求访问jd_lotteryMachine.js文件`) } else { $.body = data; } @@ -232,9 +249,9 @@ function updateShareCodes(url = 'https://raw.githubusercontent.com/yangtingxiao/ }) }) } -function updateShareCodesCDN(url = 'https://raw.fastgit.org/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js') { +function updateShareCodesCDN(url = 'https://cdn.jsdelivr.net/gh/yangtingxiao/QuantumultX@master/scripts/jd/jd_lotteryMachine.js') { return new Promise(async resolve => { - $.get({url, timeout: 10000}, async (err, resp, data) => { + $.get({url: `${url}?${Date.now()}`, timeout: 10000}, async (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) diff --git a/jd_syj.js b/jd_syj.js index ceb5c461..93322040 100644 --- a/jd_syj.js +++ b/jd_syj.js @@ -699,7 +699,7 @@ function openTuan() { function getAuthorShareCode(url) { return new Promise(resolve => { const options = { - url: `${url}?${new Date()}`, "timeout": 10000, headers: { + url: `${url}?${Date.now()}`, "timeout": 10000, 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" } };