11/*
22京东抽奖机
3- 更新时间:2020-11-07 21:42
4- 脚本说明:五个抽奖活动,【东东抽奖机】【 新店福利】【东东福利屋】【东东生活】【闪购盲盒 】,点通知只能跳转一个,入口在京东APP玩一玩里面可以看到
3+ 更新时间:2020-12-01 17:37
4+ 脚本说明:四个抽奖活动,【 新店福利】【闪购盲盒】【疯狂砸金蛋】【东东福利屋 】,点通知只能跳转一个,入口在京东APP玩一玩里面可以看到
55脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js
66// quantumultx
77[task_local]
88#京东抽奖机
9- 11 1 * * * https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js, tag=京东抽奖机, img-url=https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/image/jd .png, enabled=true
9+ 11 1 * * * https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js, tag=京东抽奖机, img-url=https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/image/jdlottery .png, enabled=true
1010// Loon
1111[Script]
1212cron "11 1 * * *" script-path=https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_lotteryMachine.js,tag=京东抽奖机
@@ -19,9 +19,10 @@ const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
1919const STRSPLIT = "|" ;
2020const needSum = false ; //是否需要显示汇总
2121const printDetail = false ; //是否显示出参详情
22- const appIdArr = [ '1EFRQxQ' , '1EFRQxA' , '1EFRQxw' , '1EFRQyw' , '1EFRRxA' ]
23- const shareCodeArr = [ 'P04z54XCjVXmYaW5m9cZ2f433tIlGBj3JnLHD0' , 'P04z54XCjVXmIaW5m9cZ2f433tIlGWEga-IO2o' , 'P04z54XCjVXm4aW5m9cZ2f433tIlINrBDzgMdY' , 'P04z54XCjVXl4aW5m9cZ2f433tIlHQIDDSzFzg' , 'P04z54XCjVWmIaW5m9cZ2f433tIlJz4FjX2kfk' ]
24- //const funPrefixArr = ['interact_template','interact_template','wfh']
22+ const appIdArr = [ '1EFRQxA' , '1EFRRxA' , '1EFRQwA' , '1EFRQyg' ]
23+ const shareCodeArr = [ 'P04z54XCjVXmIaW5m9cZ2f433tIlGWEga-IO2o' , 'P04z54XCjVWmIaW5m9cZ2f433tIlJz4FjX2kfk' , 'P04z54XCjVXnIaW5m9cZ2f433tIlLKXiUijZw4' , 'P04z54XCjVXloaW5m9cZ2f433tIlH_LzLLVOp8' ]
24+ const funPrefixArr = [ '' , '' , '' , 'wfh' , 'splitHongbao' ]
25+ let merge = { }
2526//IOS等用户直接用NobyDa的jd cookie
2627let cookiesArr = [ ] , cookie = '' ;
2728if ( $ . isNode ( ) ) {
@@ -54,10 +55,9 @@ const JD_API_HOST = `https://api.m.jd.com/client.action`;
5455 for ( let j in appIdArr ) {
5556 appId = appIdArr [ j ]
5657 shareCode = shareCodeArr [ j ]
57- // funPrefix = funPrefixArr[j]
58+ funPrefix = funPrefixArr [ j ] || 'interact_template'
5859 if ( parseInt ( j ) ) console . log ( `\n开始第${ parseInt ( j ) + 1 } 个抽奖活动` )
5960 await interact_template_getHomeData ( ) ;
60- await interact_template_getLotteryResult ( ) ;
6161 }
6262 await msgShow ( ) ;
6363 }
@@ -112,12 +112,18 @@ function interact_template_getHomeData(timeout = 0) {
112112 'Accept-Encoding' : `gzip, deflate, br` ,
113113 'Accept-Language' : `zh-cn`
114114 } ,
115- body : `functionId=${ appId === '1EFRQxw' ? 'wfh' : 'interact_template' } _getHomeData&body={"appId":"${ appId } ","taskToken":""}&client=wh5&clientVersion=1.0.0`
115+ body : `functionId=${ funPrefix } _getHomeData&body={"appId":"${ appId } ","taskToken":""}&client=wh5&clientVersion=1.0.0`
116116 }
117117 $ . post ( url , async ( err , resp , data ) => {
118118 try {
119119 if ( printDetail ) console . log ( data ) ;
120120 data = JSON . parse ( data ) ;
121+ if ( data . data . bizCode !== 0 ) {
122+ console . log ( data . data . bizMsg ) ;
123+ merge . jdBeans . fail ++ ;
124+ merge . jdBeans . notify = `${ data . data . bizMsg } ` ;
125+ return
126+ }
121127 scorePerLottery = data . data . result . userInfo . scorePerLottery || data . data . result . userInfo . lotteryMinusScore
122128 //console.log(scorePerLottery)
123129 for ( let i = 0 ; i < data . data . result . taskVos . length ; i ++ ) {
@@ -130,7 +136,6 @@ function interact_template_getHomeData(timeout = 0) {
130136 continue
131137 }
132138 if ( data . data . result . taskVos [ i ] . taskType === 14 ) { //'data.data.result.taskVos[i].assistTaskDetailVo.taskToken'
133- console . log ( '您的助力码:' + data . data . result . taskVos [ i ] . assistTaskDetailVo . taskToken )
134139 await harmony_collectScore ( shareCode , data . data . result . taskVos [ i ] . taskId ) ;
135140 continue
136141 }
@@ -140,15 +145,27 @@ function interact_template_getHomeData(timeout = 0) {
140145 if ( list [ j ] . status === 1 ) {
141146 //console.log(list[j].simpleRecordInfoVo||list[j].assistTaskDetailVo)
142147 console . log ( "\n" + ( list [ j ] . title || list [ j ] . shopName || list [ j ] . skuName ) )
143- await harmony_collectScore ( list [ j ] . taskToken , data . data . result . taskVos [ i ] . taskId ) ;
148+ //console.log(list[j].itemId)
149+ if ( list [ j ] . itemId ) {
150+ await harmony_collectScore ( list [ j ] . taskToken , data . data . result . taskVos [ i ] . taskId , list [ j ] . itemId , 1 ) ;
151+ await harmony_collectScore ( list [ j ] . taskToken , data . data . result . taskVos [ i ] . taskId , list [ j ] . itemId , 0 , 6000 ) ;
152+ if ( k === data . data . result . taskVos [ i ] . maxTimes - 1 ) await interact_template_getLotteryResult ( data . data . result . taskVos [ i ] . taskId ) ;
153+ } else {
154+ await harmony_collectScore ( list [ j ] . taskToken , data . data . result . taskVos [ i ] . taskId )
155+ }
144156 list [ j ] . status = 2 ;
145157 break ;
146158 } else {
147159 continue ;
148160 }
149161 }
150162 }
163+ if ( data . data . result . taskVos [ i ] . status === 3 ) {
164+ console . log ( '开始抽奖' )
165+ await interact_template_getLotteryResult ( data . data . result . taskVos [ i ] . taskId ) ;
166+ }
151167 }
168+ if ( scorePerLottery ) await interact_template_getLotteryResult ( ) ;
152169 } catch ( e ) {
153170 $ . logErr ( e , resp ) ;
154171 } finally {
@@ -160,7 +177,7 @@ function interact_template_getHomeData(timeout = 0) {
160177}
161178
162179
163- function harmony_collectScore ( taskToken , taskId , timeout = 0 ) {
180+ function harmony_collectScore ( taskToken , taskId , itemId = "" , actionType = 0 , timeout = 0 ) {
164181 return new Promise ( ( resolve ) => {
165182 setTimeout ( ( ) => {
166183 let url = {
@@ -175,9 +192,9 @@ function harmony_collectScore(taskToken,taskId,timeout = 0) {
175192 'Accept-Encoding' : `gzip, deflate, br` ,
176193 'Accept-Language' : `zh-cn`
177194 } ,
178- body : `functionId=${ appId === '1EFRQxw ' ? 'wfh' : 'harmony' } _collectScore&body={"appId":"${ appId } ","taskToken":"${ taskToken } ","taskId":${ taskId } ," actionType":0 }&client=wh5&clientVersion=1.0.0`
195+ body : `functionId=${ funPrefix === 'wfh ' ? funPrefix : 'harmony' } _collectScore&body={"appId":"${ appId } ","taskToken":"${ taskToken } ","taskId":${ taskId } ${ itemId ? ',"itemId":"' + itemId + '"' : '' } ," actionType":${ actionType } &client=wh5&clientVersion=1.0.0`
179196 }
180- //console.log(url)
197+ //console.log(url.body )
181198 $ . post ( url , async ( err , resp , data ) => {
182199 try {
183200 if ( printDetail ) console . log ( data ) ;
@@ -193,7 +210,7 @@ function harmony_collectScore(taskToken,taskId,timeout = 0) {
193210 } )
194211}
195212//
196- function interact_template_getLotteryResult ( timeout = 0 ) {
213+ function interact_template_getLotteryResult ( taskId , timeout = 0 ) {
197214 return new Promise ( ( resolve ) => {
198215 setTimeout ( ( ) => {
199216 let url = {
@@ -208,20 +225,27 @@ function interact_template_getLotteryResult(timeout = 0) {
208225 'Accept-Encoding' : `gzip, deflate, br` ,
209226 'Accept-Language' : `zh-cn`
210227 } ,
211- body : `functionId=${ appId === '1EFRQxw' ? 'wfh' : 'interact_template' } _getLotteryResult&body={"appId":"${ appId } "}&client=wh5&clientVersion=1.0.0`
228+ body : `functionId=${ funPrefix } _getLotteryResult&body={"appId":"${ appId } "${ taskId ? ',"taskId":"' + taskId + '"' : '' } }&client=wh5&clientVersion=1.0.0`
212229 }
230+ //console.log(url.body)
213231 $ . post ( url , async ( err , resp , data ) => {
214232 try {
215233 if ( printDetail ) console . log ( data ) ;
216234 if ( ! timeout ) console . log ( '\n开始抽奖' )
217235 data = JSON . parse ( data ) ;
218236 if ( data . data . bizCode === 0 ) {
219- merge . jdBeans . success ++ ;
220- if ( data . data . result . userAwardsCacheDto . jBeanAwardVo && data . data . result . userAwardsCacheDto . jBeanAwardVo . prizeName . match ( / 京 豆 / ) ) {
237+ if ( data . data . result . userAwardsCacheDto . jBeanAwardVo ) {
238+ merge . jdBeans . success ++ ;
221239 console . log ( '京豆:' + data . data . result . userAwardsCacheDto . jBeanAwardVo . quantity )
222240 merge . jdBeans . prizeCount += parseInt ( data . data . result . userAwardsCacheDto . jBeanAwardVo . quantity )
223241 }
224- if ( parseInt ( data . data . result . userScore ) >= scorePerLottery ) {
242+ if ( data . data . result . userAwardsCacheDto . redPacketVO ) {
243+ merge . redPacket . show = true ;
244+ merge . redPacket . success ++ ;
245+ console . log ( '红包:' + data . data . result . userAwardsCacheDto . redPacketVO . value )
246+ merge . redPacket . prizeCount += parseFloat ( data . data . result . userAwardsCacheDto . redPacketVO . value )
247+ }
248+ if ( parseInt ( data . data . result . userScore ) >= scorePerLottery && scorePerLottery ) {
225249 await interact_template_getLotteryResult ( 1000 )
226250 }
227251 } else {
@@ -230,7 +254,6 @@ function interact_template_getLotteryResult(timeout = 0) {
230254 if ( data . data . bizCode === 111 ) data . data . bizMsg = "无机会"
231255 merge . jdBeans . notify = `${ data . data . bizMsg } ` ;
232256 }
233-
234257 } catch ( e ) {
235258 $ . logErr ( e , resp ) ;
236259 } finally {
@@ -242,12 +265,13 @@ function interact_template_getLotteryResult(timeout = 0) {
242265}
243266
244267//初始化
268+
245269function initial ( ) {
246- merge = {
247- nickname : "" ,
248- enabled : true ,
249- //blueCoin : {prizeDesc : "收取|蓝币|个 ",number : true}, //定义 动作|奖励名称|奖励单位 是否是数字
250- jdBeans : { prizeDesc : "抽得|京豆|个" , number : true , fixed : 0 }
270+ merge = {
271+ nickname : "" ,
272+ enabled : true ,
273+ redPacket : { prizeDesc : "抽得|红包|元 " , number : true , fixed : 2 } , //定义 动作|奖励名称|奖励单位 是否是数字
274+ jdBeans : { prizeDesc : "抽得|京豆|个" , number : true , fixed : 0 }
251275 }
252276 for ( let i in merge ) {
253277 merge [ i ] . success = 0 ;
@@ -256,21 +280,20 @@ function initial() {
256280 merge [ i ] . notify = "" ;
257281 merge [ i ] . show = true ;
258282 }
259- // merge.jdBeans .show =Boolean(coinToBeans) ;
283+ merge . redPacket . show = false ;
260284}
261285//通知
262286function msgShow ( ) {
263- let message = "" ;
264- let url = { "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/2WBcKYkn8viyxv7MoKKgfzmu7Dss /index.html%22%20%7D` }
287+ let message = "" ; //https://h5.m.jd.com/babelDiy/Zeus/YgnrqBaEmVHWppzCgW8zjZj3VjV/index.html
288+ let url = { "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/YgnrqBaEmVHWppzCgW8zjZj3VjV /index.html%22%20%7D` }
265289 let title = `京东账号:${ merge . nickname } ` ;
266290 for ( let i in merge ) {
267291 if ( typeof ( merge [ i ] ) !== "object" || ! merge [ i ] . show ) continue ;
268292 if ( merge [ i ] . notify . split ( "" ) . reverse ( ) [ 0 ] === "\n" ) merge [ i ] . notify = merge [ i ] . notify . substr ( 0 , merge [ i ] . notify . length - 1 ) ;
269293 message += `${ merge [ i ] . prizeDesc . split ( STRSPLIT ) [ 0 ] } ${ merge [ i ] . prizeDesc . split ( STRSPLIT ) [ 1 ] } :` + ( merge [ i ] . success ? `${ merge [ i ] . prizeCount . toFixed ( merge [ i ] . fixed ) } ${ merge [ i ] . prizeDesc . split ( STRSPLIT ) [ 2 ] } \n` : `失败:${ merge [ i ] . notify } \n` )
270294 }
271295//合计
272- if ( needSum )
273- {
296+ if ( needSum ) {
274297 $ . sum = { } ;
275298 for ( let i in merge ) {
276299 if ( typeof ( merge [ i ] ) !== "object" || ! merge [ i ] . show ) continue ;
0 commit comments