Skip to content

Commit baaad50

Browse files
committed
1 parent 1e6da17 commit baaad50

5 files changed

Lines changed: 1240 additions & 6 deletions

File tree

‎.github/workflows/jd_baiTiao.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
name: 京东白条
3+
4+
on:
5+
workflow_dispatch:
6+
#schedule:
7+
# - cron: '15 */4 * * *'
8+
watch:
9+
types: started
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
if: github.event.repository.owner.id == github.event.sender.id
14+
env:
15+
JD_COOKIE: ${{ secrets.JD_COOKIE }}
16+
steps:
17+
- name: Checkout
18+
run: |
19+
git clone https://github.com/Sunert/Scripts.git ~/Scripts
20+
- name: Use Node.js 12.x
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 12.x
24+
- name: npm install
25+
run: |
26+
cd ~/Scripts
27+
npm install
28+
- name: '运行 【京东白条】'
29+
if: env.JD_COOKIE
30+
run: |
31+
cd ~/Scripts
32+
node Task/jd_baiTiao.js
33+
env:
34+
PUSH_KEY: ${{ secrets.PUSH_KEY }}
35+
BARK_PUSH: ${{ secrets.BARK_PUSH }}
36+
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
37+
TG_USER_ID: ${{ secrets.TG_USER_ID }}
38+
BARK_SOUND: ${{ secrets.BARK_SOUND }}
39+
DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }}
40+
DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }}

‎.github/workflows/jd_bigWinner.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
name: 京东大赢家
3+
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '3 */2 * * *'
8+
watch:
9+
types: started
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
if: github.event.repository.owner.id == github.event.sender.id
14+
env:
15+
JD_COOKIE: ${{ secrets.JD_COOKIE }}
16+
steps:
17+
- name: Checkout
18+
run: |
19+
git clone https://github.com/Sunert/Scripts.git ~/Scripts
20+
- name: Use Node.js 12.x
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: 12.x
24+
- name: npm install
25+
run: |
26+
cd ~/Scripts
27+
npm install
28+
- name: '运行 【京东大赢家】'
29+
if: env.JD_COOKIE
30+
run: |
31+
cd ~/Scripts
32+
node Task/jd_bigWinner.js
33+
env:
34+
PUSH_KEY: ${{ secrets.PUSH_KEY }}
35+
BARK_PUSH: ${{ secrets.BARK_PUSH }}
36+
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
37+
TG_USER_ID: ${{ secrets.TG_USER_ID }}
38+
BARK_SOUND: ${{ secrets.BARK_SOUND }}
39+
DD_BOT_TOKEN: ${{ secrets.DD_BOT_TOKEN }}
40+
DD_BOT_SECRET: ${{ secrets.DD_BOT_SECRET }}

‎Task/jd_baiTiao.js‎

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
/*
2+
京东金融领白条券
3+
更新时间:2020-10-26 16:02
4+
[task_local]
5+
# 京东金融领白条券 9点执行(非天天领券要9点开始领)
6+
0 9 * * * https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_baiTiao.js, tag=京东白条, img-url=https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/image/baitiao.png, enabled=true
7+
*/
8+
const $ = new Env('天天领白条券');
9+
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
10+
//直接用NobyDa的jd cookie
11+
let cookiesArr = [], cookie = '';
12+
if ($.isNode()) {
13+
Object.keys(jdCookieNode).forEach((item) => {
14+
cookiesArr.push(jdCookieNode[item])
15+
})
16+
} else {
17+
cookiesArr.push($.getdata('CookieJD'));
18+
cookiesArr.push($.getdata('CookieJD2'));
19+
}
20+
const JR_API_HOST = 'https://jrmkt.jd.com/activity/newPageTake/takePrize';
21+
let prize =
22+
//每日领随机白条券
23+
[
24+
{name : `prizeDaily`, desc : `天天领`, id : `Q72m9P5k3K94223q5k5O1w228U2S8B040D2B9qt`},
25+
//周一领
26+
{name : `prizeMonday`, desc : `周一领`, id : `Q1295372232228280029Aw`},
27+
//周二领
28+
{name : `prizeTuesday`, desc : `周二领`, id : `Q9293947555491r1b3U870x0D2V95X`},
29+
//周三领
30+
{name : `prizeWednesday`, desc : `周三领`, id : `Q8299679592g5N1Y1r3j8X0004269Ll`},
31+
//周四领
32+
{name : `prizeThursday`, desc : `周四领`, id : `X9D2l0f0P8S31154947512923QU`},
33+
//每周五领55-5券
34+
{name : `prizeFriday`, desc : `周五领`, id : `Q529284818011r8O2Y8L07082T9kE`},
35+
//周六领
36+
{name : `prizeSaturday`, desc : `周六领`, id : `i9200831161952186922QB`},
37+
//周六领2
38+
{name : `prizeSaturday2`, desc : `周六领`, id : `Q4295706b5Q9t2D6F181k3x8Q0v0W2e9JK`}
39+
]
40+
41+
!(async () => {
42+
if (!cookiesArr[0]) {
43+
$.msg($.name, '提示:请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"});
44+
return;
45+
}
46+
47+
for (let i = 0; i < prize.length; i++) {
48+
prize[i].body =`activityId=${prize[i].id}&eid=${randomWord(false,90).toUpperCase()}&fp=${randomWord(false,32).toLowerCase()}`
49+
}
50+
51+
for (let i = 0; i < cookiesArr.length; i++) {
52+
cookie = cookiesArr[i];
53+
if (cookie) {
54+
$.prize = {addMsg : ``};
55+
let date = new Date();
56+
await takePrize(prize[0]);
57+
if ($.prize["prizeDaily"].respCode === "00001" ) {
58+
$.msg($.name, '提示:请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"});
59+
continue;
60+
}
61+
if (date.getDay() !== 0) {
62+
await takePrize(prize[date.getDay()],820);//延迟执行,防止提示活动火爆
63+
if (date.getDay() === 6) await takePrize(prize[7],820);//第二个周六券
64+
}
65+
if (date.getDay() === 0) {
66+
$.prize.addMsg = `提 醒:请于今天使用周日专享白条券\n`
67+
}
68+
await queryMissionWantedDetail();
69+
await msgShow();
70+
}
71+
}
72+
})()
73+
.catch((e) => {
74+
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
75+
})
76+
.finally(() => {
77+
$.done();
78+
})
79+
80+
81+
function takePrize(prize,timeout = 0) {
82+
return new Promise((resolve) => {
83+
setTimeout( ()=>{
84+
let url = {
85+
url: JR_API_HOST,
86+
body : prize.body,
87+
headers: {
88+
'Cookie' : cookie,
89+
'X-Requested-With' : `XMLHttpRequest`,
90+
'Accept' : `application/json, text/javascript, */*; q=0.01`,
91+
'Origin' : `https://jrmkt.jd.com`,
92+
'Accept-Encoding' : `gzip, deflate, br`,
93+
'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`,
94+
'Host' : `jrmkt.jd.com`,
95+
'Connection' : `keep-alive`,
96+
'Referer' : `https://jrmkt.jd.com/ptp/wl/vouchers.html?activityId=${prize.id}`,
97+
'Accept-Language' : `zh-cn`
98+
}
99+
}
100+
$.post(url, (err, resp, data) => {
101+
try {
102+
data = JSON.parse(data);
103+
$.prize[prize.name] = data;
104+
$.prize[prize.name].desc = prize.desc;
105+
} catch (e) {
106+
$.logErr(e, resp);
107+
} finally {
108+
resolve()
109+
}
110+
})
111+
},timeout)
112+
})
113+
}
114+
115+
function queryMissionWantedDetail(timeout = 0) {
116+
return new Promise((resolve) => {
117+
setTimeout( ()=>{
118+
let url = {
119+
url: `https://ms.jr.jd.com/gw/generic/mission/h5/m/queryMissionWantedDetail?reqData=%7B%22playId%22:%2281%22,%22channelCode%22:%22MISSIONCENTER%22,%22timeStamp%22:%2${$.time(`yyyy-MM-ddTHH:mm:ss.SZ`)}%22%7D`,
120+
headers: {
121+
'Cookie' : cookie,
122+
'Origin' : `https://m.jr.jd.com`,
123+
'Connection' : `keep-alive`,
124+
'Accept' : `application/json`,
125+
'Referer' : `https://m.jr.jd.com/member/task/RewardDetail/?playId=81&platformCode=MISSIONCENTER&channel=baitiao&jrcontainer=h5&jrcloseweb=false`,
126+
'Host' : `ms.jr.jd.com`,
127+
'Accept-Encoding' : `gzip, deflate, br`,
128+
'Accept-Language' : `zh-cn`
129+
}
130+
}
131+
$.post(url, async (err, resp, data) => {
132+
try {
133+
data = JSON.parse(data);
134+
switch (data.resultData.data.mission.status ) {
135+
case -1 :
136+
$.prize.addMsg += `周任务:${data.resultData.data.mission.name}`;
137+
await receivePlay(data.resultData.data.mission.missionId);
138+
break;
139+
case 0 : // 2已完成 -1未领取 0已领取
140+
$.prize.addMsg += `周任务:完成进度${data.resultData.data.mission.scheduleNowValue || 0}/${data.resultData.data.mission.scheduleTargetValue},剩余数量:${data.resultData.data.residueAwardNum || `未知`}\n`
141+
break;
142+
case 1 : //
143+
$.prize.addMsg += `周任务:完成进度${data.resultData.data.mission.scheduleNowValue || 0}/${data.resultData.data.mission.scheduleTargetValue},剩余数量:${data.resultData.data.residueAwardNum || `未知`}\n`
144+
break;
145+
}
146+
} catch (e) {
147+
$.logErr(e, resp);
148+
} finally {
149+
resolve()
150+
}
151+
})
152+
},timeout)
153+
})
154+
}
155+
156+
function receivePlay(missionId,timeout = 0) {
157+
return new Promise((resolve) => {
158+
setTimeout( ()=>{
159+
let url = {
160+
url: `https://ms.jr.jd.com/gw/generic/mission/h5/m/receivePlay?reqData=%7B%22playId%22:%2281%22,%22channelCode%22:%22MISSIONCENTER%22,%22playType%22:1,%22missionId%22:${missionId},%22timeStamp%22:%22${$.time(`yyyy-MM-ddTHH:mm:ss.SZ`)}%22%7D`,
161+
headers: {
162+
'Cookie' : cookie,
163+
'Origin' : `https://m.jr.jd.com`,
164+
'Connection' : `keep-alive`,
165+
'Accept' : `application/json`,
166+
'Referer' : `https://m.jr.jd.com/member/task/RewardDetail/?playId=81&platformCode=MISSIONCENTER&channel=baitiao&jrcontainer=h5&jrcloseweb=false`,
167+
'Host' : `ms.jr.jd.com`,
168+
'Accept-Encoding' : `gzip, deflate, br`,
169+
'Accept-Language' : `zh-cn`
170+
}
171+
}
172+
$.post(url, (err, resp, data) => {
173+
try {
174+
data = JSON.parse(data);
175+
$.prize.addMsg += `-${data.resultData.msg.replace(`该任务`,``)}\n`;
176+
} catch (e) {
177+
$.logErr(e, resp);
178+
} finally {
179+
resolve()
180+
}
181+
})
182+
},timeout)
183+
})
184+
}
185+
186+
187+
function randomWord(randomFlag, min, max){
188+
let str = "",
189+
range = min,
190+
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
191+
// 随机产生
192+
if(randomFlag){
193+
range = Math.round(Math.random() * (max-min)) + min;
194+
}
195+
for(let i=0; i<range; i++){
196+
pos = Math.round(Math.random() * (arr.length-1));
197+
str += arr[pos];
198+
}
199+
return str;
200+
}
201+
202+
function msgShow() {
203+
let url ={"open-url" : "jdmobile://share?jumpType=7&jumpUrl=https%3A%2F%2Fm.jr.jd.com%2Fmember%2Fmc%2F%23%2Fhome"}
204+
$.message = "";
205+
for (let i in $.prize) {
206+
if (typeof ($.prize[i]) !== "object" ) continue;
207+
if ($.message === "") $.message = `用户名:${$.prize[i].nickName}\n`;
208+
if ($.prize[i].respCode === "00000") {
209+
$.message += `${$.prize[i].desc}:${$.prize[i].prizeModels[0].prizeName + $.prize[i].prizeModels[0].prizeAward}\n`;
210+
}
211+
else {
212+
$.message += `${$.prize[i].desc}:${typeof($.prize[i].failDesc) == "undefined" ? $.prize[i].respDesc : $.prize[i].failDesc}\n`;
213+
}
214+
}
215+
$.message += $.prize.addMsg ? $.prize.addMsg : "";
216+
$.msg($.name, '', `${$.message.substr(0,$.message.length - 1)}`, url);
217+
}
218+
219+
220+
function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),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}getScript(t){return new Promise(s=>{$.get({url:t},(t,e,i)=>s(i))})}runScript(t,s){return new Promise(e=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=s&&s.timeout?s.timeout:o;const[h,a]=i.split("@"),r={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":h,Accept:"*/*"}};$.post(r,(t,s,i)=>e(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),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;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),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),o=JSON.stringify(this.data);e?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(s,o):this.fs.writeFileSync(t,o)}}lodash_get(t,s,e){const i=s.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return e;return o}lodash_set(t,s,e){return Object(t)!==t?t:(Array.isArray(s)||(s=s.toString().match(/[^.[\]]+/g)||[]),s.slice(0,-1).reduce((t,e,i)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(s[i+1])>>0==+s[i+1]?[]:{},t)[s[s.length-1]]=e,t)}getdata(t){let s=this.getval(t);if(/^@/.test(t)){const[,e,i]=/^@(.*?)\.(.*?)$/.exec(t),o=e?this.getval(e):"";if(o)try{const t=JSON.parse(o);s=t?this.lodash_get(t,i,""):s}catch(t){s=""}}return s}setdata(t,s){let e=!1;if(/^@/.test(s)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(s),h=this.getval(i),a=i?"null"===h?null:h||"{}":"{}";try{const s=JSON.parse(a);this.lodash_set(s,o,t),e=this.setval(JSON.stringify(s),i)}catch(s){const h={};this.lodash_set(h,o,t),e=this.setval(JSON.stringify(h),i)}}else e=$.setval(t,s);return e}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,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||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,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t))}}time(t){let s={"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 e in s)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[e]:("00"+s[e]).substr((""+s[e]).length)));return t}msg(s=t,e="",i="",o){const h=t=>!t||!this.isLoon()&&this.isSurge()?t:"string"==typeof t?this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0:"object"==typeof t&&(t["open-url"]||t["media-url"])?this.isLoon()?t["open-url"]:this.isQuanX()?t:void 0:void 0;this.isSurge()||this.isLoon()?$notification.post(s,e,i,h(o)):this.isQuanX()&&$notify(s,e,i,h(o)),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)}

0 commit comments

Comments
 (0)