mirror of
https://github.com/qitoqito/psyduck.git
synced 2026-01-11 12:10:42 +08:00
PsyDuck
This commit is contained in:
commit
d81ba30cc6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
||||
93
README.md
Executable file
93
README.md
Executable file
@ -0,0 +1,93 @@
|
||||
# Bug龙订阅
|
||||
```
|
||||
链接: https://github.com/qitoqito/psyduck.git
|
||||
定时类型: crontab
|
||||
定时规则: 自定(23 23 * * *)
|
||||
白名单: psyduck
|
||||
执行后: task qitoqito_psyduck/qlCreate.js now
|
||||
```
|
||||
|
||||
# Bug龙初始化
|
||||
|
||||
```
|
||||
1. 打开config文件夹,将demo.ini重命名为config.ini,按需修改config.ini字段
|
||||
2. QINGLONG_ClientId QINGLONG_ClientSecret 两个字段必须填写
|
||||
3. 进入bug龙终端安装依赖,执行以下命令: cd /ql/data/scripts/qitoqito_psyduck/ && npm install
|
||||
4. 重新执行task qitoqito_psyduck/qlCreate.js now
|
||||
```
|
||||
# INI配置文件
|
||||
以JD为例:
|
||||
在指定文件夹(默认config)创建jd.ini文件
|
||||
|
||||
具体格式:
|
||||
其中filename为需要字段的脚本名
|
||||
|
||||
[filename]
|
||||
field=test
|
||||
|
||||
|
||||
# J东SIGN
|
||||
如果环境变量中,已经部署过 JD_SIGN_API, JD_SIGN_KRAPI 可以跳过以下步骤
|
||||
|
||||
```
|
||||
docker run -dit \
|
||||
-p 17840:17840 \
|
||||
-e TZ=Asia/Shanghai \
|
||||
--name Sign \
|
||||
--hostname Sign \
|
||||
--restart unless-stopped \
|
||||
seansuny/signapi:latest
|
||||
|
||||
config.ini添加 jdSign=http://ip:17840/sign
|
||||
```
|
||||
|
||||
|
||||
# 通知字段
|
||||
|
||||
# telegram
|
||||
TELEGRAM_TOKEN=
|
||||
TELEGRAM_ID=
|
||||
TELEGRAM_URL=自定义TG代理链接
|
||||
TELEGRAM_PROXY=代理服务器 (http|https|sock)://ip:port, 使用sock需要安装 socks-proxy-agent 模块
|
||||
|
||||
# bark
|
||||
BARK_TOKEN=
|
||||
BARK_URL=自定义url
|
||||
BARK_SOUND=自定义铃声
|
||||
|
||||
# 钉钉
|
||||
DINGTALK_TOKEN=
|
||||
DINGTALK_SECRET=密钥
|
||||
|
||||
# igot
|
||||
IGOT_TOKEN=
|
||||
|
||||
# server酱
|
||||
FTQQ_TOKEN=
|
||||
|
||||
# pushplus
|
||||
PUSHPLUS_TOKEN=
|
||||
PUSHPLUS_TOPIC=群组
|
||||
|
||||
# 企业微信
|
||||
WEIXIN_TOKEN=
|
||||
|
||||
# 企业微信AM
|
||||
WXAM_TOKEN=
|
||||
|
||||
|
||||
|
||||
# 框架结构
|
||||
util: 调用函数目录
|
||||
parse: 解析脚本目录
|
||||
temp: 缓存文件目录
|
||||
static: 静态文件目录
|
||||
cookie: 数据文件目录
|
||||
config: 配置文件目录
|
||||
log: 日志文件目录
|
||||
template.js: 项目主体文件
|
||||
main.js: 项目入口文件
|
||||
qlCreate: 青龙面板生成入口以及添加定时
|
||||
|
||||
# 使用方法
|
||||
node main.js filename [-help n -custom x -limit x]
|
||||
38
config/demo.ini
Normal file
38
config/demo.ini
Normal file
@ -0,0 +1,38 @@
|
||||
[env]
|
||||
;iniPath= # ini文件获取路径,默认config/
|
||||
;jdSign= # 京东sign接口url
|
||||
;validCookie=true|false # 缓存过期cookie,开启后,脚本识别到账户过期,将缓存存储,后续脚本运行将跳过过期账户
|
||||
;panel=qinglong|js|ini # 面板类型设置,账户cookie操作使用,使用cookie/{type}.js设置js,使用cookie/{type}.ini设置ini
|
||||
;QINGLONG_ClientId= # 青龙ClientId
|
||||
;QINGLONG_ClientSecret= # 青龙ClientSecret
|
||||
|
||||
[global]
|
||||
;test=xxxx # 脚本全局变量
|
||||
|
||||
[proxy]
|
||||
;proxyGroup= # 静态代理池,适用长期有效ip,需要自行创建proxy.ini
|
||||
;proxyUrl= # 代理ip请求地址
|
||||
;pool=n|-1 # 代理池缓存数量,n为正整数时候,框架向proxyUrl获取n个ip存储在代理池,运行账号依次取出ip,数量小于n时,自动补充ip. n为-1时,取一个ip,运行账户共用此ip
|
||||
;seconds= # 代理ip每隔几秒换新一个
|
||||
;proxy= # 代理ip
|
||||
|
||||
[cache]
|
||||
;type=redis|json # 缓存类型,Redis缓存或json缓存
|
||||
;host= # Redis地址
|
||||
;port= # Redis端口
|
||||
;password= # Redis密码,如无设置请留空
|
||||
;db=2 # Redis数据库
|
||||
|
||||
|
||||
[message]
|
||||
;TELEGRAM_TOKEN= # TELEGRAM bot token
|
||||
;TELEGRAM_ID= # TELEGRAM user id
|
||||
;BARK_URL= # Bark url 默认https:#api.day.app
|
||||
;BARK_TOKEN= # Bark token
|
||||
;DINGTALK_TOKEN= # 钉钉 token
|
||||
;DINGTALK_SECRET= # 钉钉 secret
|
||||
;PUSHPLUS_TOKEN= # PushPlus token
|
||||
;PUSHPLUS_TOPIC= # PushPlus 分组id
|
||||
;FTQQ_TOKEN= # Server酱 token
|
||||
;WEIXIN_TOKEN= # 企业微信 token
|
||||
;WXAM_TOKEN= # 微信AM token
|
||||
85
config/profile.js
Normal file
85
config/profile.js
Normal file
@ -0,0 +1,85 @@
|
||||
export default {
|
||||
env: {
|
||||
index: true,
|
||||
salt: 'psyDuck'
|
||||
},
|
||||
global: {},
|
||||
psyDuck: {
|
||||
config: {
|
||||
jd: {
|
||||
userName: "pt_pin\\s*=\\s*([^;]+)",
|
||||
configuration: {
|
||||
'https://api.m.jd.com': {
|
||||
agent: {
|
||||
rejectUnauthorized: false,
|
||||
ciphers: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256",
|
||||
secureProtocol: "TLSv1_2_method",
|
||||
},
|
||||
referer: "https://prodev.m.jd.com/",
|
||||
shell: true,
|
||||
},
|
||||
'isvjcloud.com': {
|
||||
cookieJar: true,
|
||||
shell: true,
|
||||
},
|
||||
'kai.jd.com': {
|
||||
shell: true
|
||||
},
|
||||
'ms.jr.jd.com': {
|
||||
shell: true
|
||||
},
|
||||
'u.jd.com': {
|
||||
shell: true
|
||||
}
|
||||
},
|
||||
referer: "https://prodev.m.jd.com/",
|
||||
timer: {
|
||||
params: {
|
||||
'url':
|
||||
'https://api.m.jd.com/client.action?functionId=jdDiscoveryRedPoint&body=%7B%7D&uuid=487f7b22f68312d2c1bbc93b1&client=apple&clientVersion=10.0.10&st=1677768101596&sv=120&sign=fbaf17e9b2a79543cd3e296665517fb5',
|
||||
},
|
||||
wait: 120,
|
||||
haskey: 'time'
|
||||
},
|
||||
prepare: [
|
||||
{
|
||||
'eval': 'algo.bill'
|
||||
},
|
||||
{
|
||||
'eval': 'algo.isv',
|
||||
'haskey': 'public',
|
||||
'equal': 'isv'
|
||||
},
|
||||
{
|
||||
'eval': '_userData',
|
||||
'haskey': 'userData'
|
||||
},
|
||||
{
|
||||
'eval': '_shareData',
|
||||
'haskey': 'shareData'
|
||||
}
|
||||
],
|
||||
appids: [
|
||||
'redrain-2021',
|
||||
'wh5',
|
||||
'SecKill2020',
|
||||
'content_ecology',
|
||||
'u',
|
||||
'u_hongbao',
|
||||
'babelh5',
|
||||
'publicUseApi',
|
||||
'newtry'
|
||||
]
|
||||
}
|
||||
},
|
||||
map: {
|
||||
'js': 'jd'
|
||||
}
|
||||
},
|
||||
enc: {
|
||||
token: '7530233633333336393633323337333239742830363633333537303333373336353a28727b303c2633363333373333333338393332276a222932333336333337353630333739353363726162313833333333353633323930363333626f63753333353333333334363034363633336823632233333933333333383333323136333360326f2a353934333633363421333633363333703c752133353138333633327630303333333370326e67333236373333363d',
|
||||
jdApi: '263333368a19469e722333274f680ff0666222274feee1a87673333701129040',
|
||||
jdShare: ''
|
||||
}
|
||||
}
|
||||
|
||||
64
main.js
Normal file
64
main.js
Normal file
@ -0,0 +1,64 @@
|
||||
// import {Template} from "./template.js"
|
||||
// console.log(process )
|
||||
// let dirname = process.mainModule.path
|
||||
import fs from 'fs'
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import ini from 'ini'
|
||||
|
||||
let filename;
|
||||
let params = {}
|
||||
let length = process.argv.length
|
||||
if (length>2) {
|
||||
filename = process.argv[2].split('.')[0]
|
||||
params.filename = filename
|
||||
if (length>3) {
|
||||
for (let i = 3; i<length; i++) {
|
||||
let key = process.argv[i].match(/^-\w+$/)
|
||||
if (key) {
|
||||
params[key[0].substr(1)] = process.argv[i + 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
!(async () => {
|
||||
const dirpath = fileURLToPath(import.meta.url);
|
||||
const abspath = path.dirname(dirpath)
|
||||
let length = process.argv.length
|
||||
if (filename) {
|
||||
let type = filename.match(/(^[A-Za-z0-9]+)\_/)[1]
|
||||
try {
|
||||
let psyDuck = await import( `./parse/${type}/${filename}.js`)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
} catch (e) {
|
||||
// console.log(e)
|
||||
let iniText = fs.readFileSync(`config/config.ini`, 'UTF-8')
|
||||
let config = ini.parse(iniText)
|
||||
let iniPath = `config/${type}.ini`
|
||||
if (config.env && config.env.iniPath) {
|
||||
iniPath = `${config.env.iniPath}/${type}.ini`
|
||||
}
|
||||
let scText = fs.readFileSync(iniPath, 'UTF-8')
|
||||
let script = ini.parse(scText)
|
||||
let map = ''
|
||||
for (let i in script) {
|
||||
if (i == filename && script[i].map) {
|
||||
map = script[i].map
|
||||
}
|
||||
}
|
||||
if (map) {
|
||||
params.mapping = map
|
||||
let psyDuck = await import( `./parse/${type}/${map}.js`)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
}
|
||||
else {
|
||||
console.log("没有可执行的脚本")
|
||||
}
|
||||
}
|
||||
}
|
||||
})().catch((e) => {
|
||||
console.log(e)
|
||||
}).finally(() => {
|
||||
});
|
||||
39
package.json
Normal file
39
package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"cheerio": "^1.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"gm": "^1.25.0",
|
||||
"happy-dom": "^17.0.0",
|
||||
"https": "^1.0.0",
|
||||
"ini": "^5.0.0",
|
||||
"jsdom": "^26.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-jsencrypt": "^1.0.0",
|
||||
"node-schedule": "^2.1.1",
|
||||
"os": "^0.1.2",
|
||||
"qs": "^6.14.0",
|
||||
"readline-sync": "^1.4.10",
|
||||
"redis": "^4.7.0",
|
||||
"socks-proxy-agent": "^6.1.1",
|
||||
"ttl-file-cache": "^1.0.5",
|
||||
"vm": "^0.1.0"
|
||||
},
|
||||
"type": "module",
|
||||
"name": "psyduck",
|
||||
"version": "1.0.0",
|
||||
"main": "main.js",
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"start": "node main.js",
|
||||
"test": "node create.js"
|
||||
},
|
||||
"config": {
|
||||
"NODE_OPTIONS": "--no-deprecation"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
||||
211
parse/jd/jd_task_baoxian.js
Normal file
211
parse/jd/jd_task_baoxian.js
Normal file
@ -0,0 +1,211 @@
|
||||
import {Template} from '../../template.js'
|
||||
import jsdom from "jsdom";
|
||||
import {Window} from 'happy-dom' ;
|
||||
import fs from 'fs'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东保险天天领权益',
|
||||
crontab: 3
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
let ua = this.userAgents().jd
|
||||
let resourceLoader = new jsdom.ResourceLoader({
|
||||
userAgent: ua,
|
||||
"referer": "https://iu.jr.jd.com/",
|
||||
});
|
||||
let virtualConsole = new jsdom.VirtualConsole();
|
||||
this.jsConfig = {
|
||||
"url": "https://iu.jr.jd.com/",
|
||||
"referer": "https://iu.jr.jd.com/",
|
||||
"userAgent": ua,
|
||||
runScripts: "dangerously",
|
||||
resources: resourceLoader,
|
||||
includeNodeLocations: true,
|
||||
storageQuota: 10000000,
|
||||
pretendToBeVisual: true,
|
||||
virtualConsole,
|
||||
};
|
||||
let JSDOM = jsdom.JSDOM
|
||||
let a = new JSDOM(`<body><script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/aar2.min.js"></script> <script src="https://m.jr.jd.com/common/jssdk/jrbridge/2.0.0/jrbridge.js"></script> <script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/cryptico.min.js"></script> </body>`, this.jsConfig)
|
||||
await this.wait(1000)
|
||||
if (a.window.AAR2) {
|
||||
a.window.AAR2.init();
|
||||
this.crypto = {
|
||||
aar: new a.window.AAR2(),
|
||||
cry: a.window.cryptico
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.log("jsdom没有获取到aar2")
|
||||
this.jump = 1
|
||||
}
|
||||
// let jsFiles = [
|
||||
// 'aar2.min.js',
|
||||
// 'cryptico.min.js',
|
||||
// 'jrbridge.js',
|
||||
// ];
|
||||
// const window = new Window();
|
||||
// const document = window.document;
|
||||
// for (let i of jsFiles) {
|
||||
// const jsCode = fs.readFileSync(`${this.abspath}/static/${i}`, 'utf-8');
|
||||
// const scriptElement = document.createElement('script');
|
||||
// scriptElement.textContent = jsCode;
|
||||
// document.body.appendChild(scriptElement);
|
||||
// }
|
||||
// document.body.innerHTML = '<body><script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/aar2.min.js"></script> <script src="https://m.jr.jd.com/common/jssdk/jrbridge/2.0.0/jrbridge.js"></script> <script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/cryptico.min.js"></script> </body>';
|
||||
// window.AAR2.init();
|
||||
// this.crypto = {
|
||||
// aar: new window.AAR2(),
|
||||
// cry: window.cryptico
|
||||
// }
|
||||
// console.log(this.crypto.aar.nonce())
|
||||
// console.log(this.crypto.aar.sign(234,this.crypto.aar.nonce()))
|
||||
// this.jump=234
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let a = new jsdom.JSDOM(`<body><script src="//gia.jd.com/m.html"></script> <script src="//gias.jd.com/js/m.js"></body>`, this.jsConfig)
|
||||
await this.wait(2000)
|
||||
let riskJd = a.window.getJdEid();
|
||||
let bean = 0
|
||||
const aar = this.crypto.aar
|
||||
var nonce = aar.nonce()
|
||||
let getAAR = function() {
|
||||
var s = "qypd" + (new Date).getTime();
|
||||
return {
|
||||
nonce,
|
||||
signData: s,
|
||||
signature: aar.sign(s, nonce)
|
||||
}
|
||||
}
|
||||
let rsa = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/getRSAPublicKey`,
|
||||
'form': `reqData=%7B%22channel%22%3A%22sy%22%2C%22channelLv%22%3A%22sy%22%7D`,
|
||||
user
|
||||
})
|
||||
let resBusiData = this.loads(rsa.resultData.publicKey)
|
||||
this.crypto.cry.setPublicKeyString(resBusiData)
|
||||
let bodyEnc = await this.crypto.cry.encryptData(this.dumps({
|
||||
"marketId": "bxqypd",
|
||||
"pageUrl": "https://iu.jr.jd.com/insurance/channel/interest?showTab=1",
|
||||
"qdPageId": "3MB9G",
|
||||
eid: riskJd.eid,
|
||||
fp: riskJd.fp,
|
||||
token: riskJd.token,
|
||||
profitChannelCode: "qypd",
|
||||
rush: getAAR()
|
||||
}))
|
||||
let jdr = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/bxpd/newh5/m/jingDouInterestChannel`,
|
||||
json: {
|
||||
reqData: {
|
||||
"channelEncrypt": 1,
|
||||
"bodyEncrypt": bodyEnc.cipher
|
||||
}
|
||||
},
|
||||
user
|
||||
}
|
||||
)
|
||||
let res = (await this.crypto.cry.decryptData(jdr.resultData))
|
||||
if (res.status) {
|
||||
let plaintext = this.loads(res.plaintext)
|
||||
p.log("签到中...")
|
||||
let signData = {
|
||||
"relationId": "ej94ec6d",
|
||||
"relationType": 3,
|
||||
"ruleAliasCode": "signUpAndTake",
|
||||
"contextParams": {
|
||||
"request": {
|
||||
"riskMap": {
|
||||
"pageUrl": "https://iu.jr.jd.com/insurance/channel/interest?showTab=1",
|
||||
"qdPageId": "M2Wq",
|
||||
"mdClickId": `M2Wq|*ej94ec6d****${this.md5(p.user)}`
|
||||
},
|
||||
"deviceInfo": riskJd
|
||||
}
|
||||
}
|
||||
}
|
||||
let signature = aar.sign(this.dumps(signData), nonce)
|
||||
let sign = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/jractivity/h5/m/rule/execute`,
|
||||
'json': {
|
||||
reqData: {
|
||||
"preview": 0,
|
||||
"antiRushFlag": "1",
|
||||
"domain": "iu.jr.jd.com",
|
||||
"uri": "/insurance/channel/interest?showTab=1",
|
||||
"nonce": nonce,
|
||||
"signature": signature,
|
||||
"signData": this.dumps(signData)
|
||||
}
|
||||
},
|
||||
algo: {
|
||||
valid: {
|
||||
'resultData.data.code': ['0006']
|
||||
}
|
||||
},
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'resultData.data.data.signAwardInfoList')) {
|
||||
p.info.work = true
|
||||
for (let i of sign.resultData.data.data.signAwardInfoList) {
|
||||
p.log(`获得${i.awardName}:${i.awardNum}`)
|
||||
bean += i.awardNum
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(sign, 'resultData.data.msg') || sign)
|
||||
if (this.haskey(sign, 'resultData.data.code', '0002')) {
|
||||
p.log("风控账户")
|
||||
return
|
||||
}
|
||||
else if (this.haskey(sign, 'resultData.data.code', '0006')) {
|
||||
p.log("未登录")
|
||||
return
|
||||
}
|
||||
else if (this.haskey(sign, 'resultData.data.code', '0009')) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
// p.log(plaintext)
|
||||
// for (let i of this.haskey(plaintext, 'task.taskList')) {
|
||||
// if (i.taskStatus) {
|
||||
// p.log("任务已完成:", i.taskName)
|
||||
// }
|
||||
// else {
|
||||
// p.log("正在运行:", i.taskName)
|
||||
// let juid = this.match(/juid=(\w+)/, i.taskLink)
|
||||
// if (juid) {
|
||||
// let juidSign = aar.sign(juid, nonce)
|
||||
// let jump = await this.curl({
|
||||
// 'url': `https://ms.jr.jd.com/gw2/generic/mission/h5/m/getJumpInfo?juid=${juid}&signature=${juidSign}&nonce=${nonce}`,
|
||||
// user
|
||||
// }
|
||||
// )
|
||||
// if (this.haskey(jump, 'resultData.code') == '0000') {
|
||||
// p.log(`获得京豆:${i.awardNum}`)
|
||||
// bean += i.awardNum
|
||||
// }
|
||||
// else {
|
||||
// p.log('失败了:', jump)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else {
|
||||
p.log("没有获取到游戏数据...")
|
||||
}
|
||||
if (bean>0) {
|
||||
p.msg(`获得京豆: ${bean}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
42
parse/jd/jd_task_carPromotion.js
Normal file
42
parse/jd/jd_task_carPromotion.js
Normal file
@ -0,0 +1,42 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东车管家签到',
|
||||
crontab: 4
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/carPromotion_doSign?functionId=carPromotion_doSign&body={"obtainOrUseScore":1,"encryptAssignmentId":"3zex5T6aHbQRCTfGuv1jruLCgnUX","itemId":"1"}&appid=M-CAR`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'd2328',
|
||||
expire: {
|
||||
"errCode": 203
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'data.bean')) {
|
||||
p.info.work = true
|
||||
p.msg("签到奖励: 1豆")
|
||||
}
|
||||
else if (this.haskey(sign, 'data.subCode', '103')) {
|
||||
p.info.work = true
|
||||
p.log('任务已完成')
|
||||
}
|
||||
else {
|
||||
p.log(sign)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
parse/jd/jd_task_chatReward.js
Normal file
53
parse/jd/jd_task_chatReward.js
Normal file
@ -0,0 +1,53 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东社群红包',
|
||||
prompt: {
|
||||
activityId: "活动id1|id2"
|
||||
},
|
||||
sync: 1,
|
||||
verify: true,
|
||||
crontab: 3
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
await this.field('activityId')
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=chatReward_doReward&appid=wechat_activity&client=h5&body={"activityId":"${p.context.activityId}"}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let reward = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=chatReward_mainPage&appid=wechat_activity&client=h5&body={"activityId":"${p.context.activityId}"}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: "323f1",
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(reward, 'data.rewardInfo.rewardValue')) {
|
||||
if (reward.data.rewardInfo.rewardType == 1) {
|
||||
// p.msg(p.context.activityId)
|
||||
p.msg(`红包: ${reward.data.rewardInfo.rewardValue}元`)
|
||||
}
|
||||
else {
|
||||
p.log(`优惠券: ${reward.data.rewardInfo.rewardValue}元`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log("什么也没有")
|
||||
}
|
||||
if (this.haskey(reward, 'data')) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
137
parse/jd/jd_task_checkCookie.js
Normal file
137
parse/jd/jd_task_checkCookie.js
Normal file
@ -0,0 +1,137 @@
|
||||
import {Template} from '../../template.js'
|
||||
import {Panel} from "../../util/panel.js";
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东Cookie过期检测',
|
||||
userData: true,
|
||||
validCookie: true,
|
||||
interval: 2000,
|
||||
crontab: 24
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let s = await this.curl({
|
||||
'url': `https://plogin.m.jd.com/cgi-bin/ml/islogin`,
|
||||
user,
|
||||
algo: {
|
||||
shell: 1,
|
||||
// valid: {
|
||||
// haskey: 'islogin', code: ['0']
|
||||
// }
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(s, 'islogin', '0')) {
|
||||
let userData = this.userData[user] || {}
|
||||
if (userData.wskey) {
|
||||
let genToken = await this.curl({
|
||||
url: 'https://api.m.jd.com/client.action',
|
||||
form: 'functionId=genToken&body=%7B%22to%22%3A%22https%3A%2F%2Fbean.m.jd.com%2FbeanDetail%2Findex.action%22%2C%22action%22%3A%22to%22%7D&uuid=487f7b22f68312d2c1bbc93b1a&client=apple&clientVersion=10.10.0',
|
||||
cookie: `wskey=${userData.wskey};pin=${encodeURIComponent(user)};`,
|
||||
algo: {app: true},
|
||||
response: 'all',
|
||||
headers: {
|
||||
'j-e-c': encodeURIComponent(this.dumps({
|
||||
"hdid": "JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=",
|
||||
"ts": new Date().getTime(),
|
||||
"ridx": -1,
|
||||
"cipher": {"pin": this.eip(user, 'b64encode')},
|
||||
"ciphertype": 5,
|
||||
"version": "1.2.0",
|
||||
"appname": "com.jingdong.app.mall"
|
||||
})),
|
||||
'j-e-h': encodeURIComponent(this.dumps({
|
||||
"hdid": "JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=",
|
||||
"ts": new Date().getTime(),
|
||||
"ridx": -1,
|
||||
"cipher": {"User-Agent": this.eip("Mozilla/5.0 (iPad; CPU OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1", 'b64encode')},
|
||||
"ciphertype": 5,
|
||||
"version": "1.2.0",
|
||||
"appname": "com.jingdong.app.mall"
|
||||
})),
|
||||
'user-agent': 'JD4iPhone/169635%20(iPhone;%20iOS;%20Scale/3.00);jdmall;iphone;version/13.8.1;build/169635;network/wifi;screen/1170x2532;os/15.1.1',
|
||||
'x-rp-client': 'ios_4.0.0',
|
||||
'x-referer-page': 'com.jingdong.app.mall.WebActivity',
|
||||
'x-referer-package': 'com.jingdong.app.mall',
|
||||
'charset': 'UTF-8',
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(genToken, 'content.tokenKey') && genToken.content.tokenKey.slice(0, 2) == 'AA') {
|
||||
let y = await this.curl({
|
||||
'url': `https://un.m.jd.com/cgi-bin/app/appjmp`,
|
||||
form: `tokenKey=${genToken.content.tokenKey}&&lbs={"cityId":"","districtId":"","provinceId":"","districtName":"","lng":"0.000000","provinceName":"","lat":"0.000000","cityName":""}&to=${encodeURIComponent("https://bean.m.jd.com/beanDetail/index.action")}`,
|
||||
response: "all",
|
||||
maxRedirects: 0,
|
||||
scheme: 'http',
|
||||
}
|
||||
)
|
||||
if (y.cookie && y.cookie.includes('app_open')) {
|
||||
this.dict[user] = y.cookie
|
||||
p.log('openKey生成成功');
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.err("openKey获取失败")
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.err("tokenKey获取失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.haskey(s, 'islogin', '1')) {
|
||||
p.log("账户还未过期")
|
||||
this.valid(user, true)
|
||||
}
|
||||
else {
|
||||
p.err("没有获取到数据")
|
||||
}
|
||||
}
|
||||
|
||||
async done() {
|
||||
try {
|
||||
if (Object.keys(this.dict).length) {
|
||||
let panel = new Panel(this.dict)
|
||||
await panel.send()
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
eip(str, type = "") {
|
||||
const charMap = {
|
||||
'A': 'K', 'B': 'L', 'C': 'M', 'D': 'N', 'E': 'O',
|
||||
'F': 'P', 'G': 'Q', 'H': 'R', 'I': 'S', 'J': 'T',
|
||||
'K': 'A', 'L': 'B', 'M': 'C', 'N': 'D', 'O': 'E',
|
||||
'P': 'F', 'Q': 'G', 'R': 'H', 'S': 'I', 'T': 'J',
|
||||
'e': 'o', 'f': 'p', 'g': 'q', 'h': 'r', 'i': 's',
|
||||
'j': 't', 'k': 'u', 'l': 'v', 'm': 'w', 'n': 'x',
|
||||
'o': 'e', 'p': 'f', 'q': 'g', 'r': 'h', 's': 'i',
|
||||
't': 'j', 'u': 'k', 'v': 'l', 'w': 'm', 'x': 'n'
|
||||
};
|
||||
if (type === 'b64encode') {
|
||||
const data = typeof str === "object" ? this.dumps(str) : str;
|
||||
return Buffer.from(data)
|
||||
.toString('base64')
|
||||
.split("")
|
||||
.map(char => charMap[char] || char)
|
||||
.join("");
|
||||
}
|
||||
const decrypted = str.split("")
|
||||
.map(char => charMap[char] || char)
|
||||
.join("");
|
||||
return this.jsonParse(Buffer.from(decrypted, 'base64').toString());
|
||||
}
|
||||
}
|
||||
|
||||
81
parse/jd/jd_task_deliverySign.js
Normal file
81
parse/jd/jd_task_deliverySign.js
Normal file
@ -0,0 +1,81 @@
|
||||
import {Template } from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东天天领豆",
|
||||
crontab: 3,
|
||||
model: 'user',
|
||||
sync: 1,
|
||||
prompt: {
|
||||
activityId: '活动id1|id2'
|
||||
},
|
||||
verify: 1
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
await this.field('activityId')
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user
|
||||
let home = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=deliverySign_home&appid=signed_wh5_ihub&body={"activityId":"${p.context.activityId}"}&client=apple&clientVersion=13.2.8&d_model=&osVersion=15.1.1`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e88fd'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(home, 'data.bizCode', -102)) {
|
||||
p.info.jump = true
|
||||
}
|
||||
if (this.haskey(home, 'data.result.bubbleList')) {
|
||||
for (let i of home.data.result.bubbleList) {
|
||||
if (i.status == 1) {
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=deliverySign_sign&appid=signed_wh5_ihub&body={"activityId":"${p.context.activityId}"}&client=apple&clientVersion=13.2.8&d_model=&osVersion=15.1.1`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e88fd'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'data.result.value')) {
|
||||
p.msg(`京豆: ${sign.data.result.value}`)
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(sign, 'data.bizMsg') || sign)
|
||||
}
|
||||
let reward = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=deliverySign_continue_award&appid=signed_wh5_ihub&body={"activityId":"${p.context.activityId}"}&client=apple&uuid=674ce0d97511f5ed054c3dc0af093b3b245ab68d&clientVersion=13.2.8&d_model=&osVersion=15.1.1`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e88fd'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(reward, 'data.result.value')) {
|
||||
p.msg(`京豆: ${reward.data.result.value}`)
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.haskey(i, 'status', 2)) {
|
||||
p.info.work = true
|
||||
}
|
||||
p.log("暂不可做:", i.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log("没有获取到数据...")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
85
parse/jd/jd_task_drainage.js
Normal file
85
parse/jd/jd_task_drainage.js
Normal file
@ -0,0 +1,85 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东天天来赚钱',
|
||||
headers: {
|
||||
referer: 'https://servicewechat.com/wx91d27dbf599dff74/770/page-frame.html',
|
||||
'user-agent': 'wechat',
|
||||
wqreferer: 'http://wq.jd.com/wxapp/pages/marketing/entry_task/channel',
|
||||
'X-Rp-Client': 'mini_2.1.0'
|
||||
},
|
||||
crontab: 3
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/MiniTask_ChannelPage?g_ty=ls&g_tk=1629788202`,
|
||||
'form': `loginType=11&clientType=wxapp&client=apple&clientVersion=9.23.200&build=&osVersion=iOS%2015.1.1&screen=390*844&networkType=wifi&d_brand=iPhone&d_model=iPhone%2012%20Pro%3CiPhone13%2C3%3E&lang=zh_CN&functionId=MiniTask_ChannelPage&t=1732259085779&body={"source":"task","businessSource":"bbxa"}&appid=hot_channel`,
|
||||
user,
|
||||
algo: {
|
||||
'appId': '60d61',
|
||||
store: 'buildtime=20230103;wxapp_type=1;wxapp_version=8.13.30;wxapp_scene=1112;cid=5;pinStatus=4;'
|
||||
}
|
||||
}
|
||||
)
|
||||
let channel = await this.curl({
|
||||
'url': `https://api.m.jd.com/MiniTask_ChannelPage?g_ty=ls&g_tk=1722006734`,
|
||||
'form': `loginType=11&clientType=wxapp&client=apple&clientVersion=9.23.140&build=&osVersion=iOS%2015.1.1&screen=390*844&networkType=wifi&d_brand=iPhone&d_model=iPhone%2012%20Pro%3CiPhone13%2C3%3E&lang=zh_CN&uuid=oCwKwuBoW0okKEIIDlT5FXxscxcM&functionId=MiniTask_ChannelPage&t=1731719820513&body={"source":"task","silverHairInfo":{},"expose":false,"xyhfAuth":2,"xyhfShow":false,"businessSource":"2411shiyebuchuanbo","versionFlag":"new"}&appid=hot_channel`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '60d61'
|
||||
}
|
||||
}
|
||||
)
|
||||
let query = await this.curl({
|
||||
'url': `https://api.m.jd.com/miniTask_queryMyRights?g_ty=ls&g_tk=1722006734`,
|
||||
'form': `loginType=11&clientType=wxapp&client=apple&clientVersion=9.23.140&build=&osVersion=iOS%2015.1.1&screen=390*844&networkType=wifi&d_brand=iPhone&d_model=iPhone%2012%20Pro%3CiPhone13%2C3%3E&lang=zh_CN&uuid=oCwKwuBoW0okKEIIDlT5FXxscxcM&functionId=miniTask_queryMyRights&t=1731719821597&body={}&appid=hot_channel&d_name=`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '1221c'
|
||||
}
|
||||
}
|
||||
)
|
||||
let rights = await this.curl({
|
||||
'url': `https://api.m.jd.com/miniTask_superSaveGetRights?g_ty=ls&g_tk=1722006734`,
|
||||
'form': `loginType=11&clientType=wxapp&client=apple&clientVersion=9.22.230&build=&osVersion=iOS%2015.1.1&screen=390*844&networkType=wifi&d_brand=iPhone&d_model=iPhone%2012%20Pro%3CiPhone13%2C3%3E&lang=zh_CN&functionId=miniTask_superSaveGetRights&t=1731641417506&body={"itemId":"1"}&appid=hot_channel`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '87bb2'
|
||||
},
|
||||
}
|
||||
)
|
||||
let subCode = this.haskey(rights, 'subCode')
|
||||
if (this.haskey(rights, 'data.rights')) {
|
||||
p.info.work = true
|
||||
for (let i of this.haskey(rights, 'data.rights')) {
|
||||
if (i.rewardType == 1) {
|
||||
p.msg(`红包: ${i.discount}`)
|
||||
}
|
||||
else if (i.rewardType == 3) {
|
||||
p.log(`优惠券:${i.quota}-${i.discount} (${i.category})`)
|
||||
}
|
||||
else {
|
||||
p.log(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (subCode == 3010) {
|
||||
p.info.work = true
|
||||
p.log(rights.message)
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(rights, 'message') || rights)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
118
parse/jd/jd_task_dwapp.js
Normal file
118
parse/jd/jd_task_dwapp.js
Normal file
@ -0,0 +1,118 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东充值金",
|
||||
crontab: 12
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user
|
||||
let list = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=dwapp_task_dwList`,
|
||||
'form': `appid=h5-sep&body=${this.dumps(await this.cmd5x())}&client=m&clientVersion=6.0.0`,
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(list, 'code', 201)) {
|
||||
p.err("未登录")
|
||||
return
|
||||
}
|
||||
let cash = 0
|
||||
for (let i of this.haskey(list, 'data') || []) {
|
||||
if (i.viewStatus == 3 || i.viewStatus == 1) {
|
||||
p.log("任务完成:", i.name)
|
||||
}
|
||||
else {
|
||||
p.log("正在运行:", i.name)
|
||||
let record = await this.curl({
|
||||
'url': `https://dwapp.jd.com/user/task/dwRecord`,
|
||||
'json': await this.cmd5x({
|
||||
"id": i.id,
|
||||
"taskType": i.taskType,
|
||||
"agentNum": "m",
|
||||
"followChannelStatus": "",
|
||||
taskFlowChannelId: i.taskFlowChannelId
|
||||
}),
|
||||
user
|
||||
}
|
||||
)
|
||||
// p.log(record)
|
||||
await this.wait(2000)
|
||||
let receive = await this.curl({
|
||||
'url': `https://dwapp.jd.com/user/task/dwReceive`,
|
||||
'json': await this.cmd5x({
|
||||
"id": i.id,
|
||||
}),
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(receive, 'data.giveScoreNum')) {
|
||||
p.log("获得充值金:", receive.data.giveScoreNum)
|
||||
cash += receive.data.giveScoreNum
|
||||
}
|
||||
else {
|
||||
p.log(receive)
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
}
|
||||
var sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/api`,
|
||||
form: `appid=h5-sep&body=${this.dumps(await this.cmd5x())}&client=m&clientVersion=6.0.0&functionId=DATAWALLET_USER_SIGN`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '60d0e',
|
||||
status: 200,
|
||||
},
|
||||
referer: 'https://mypoint.jd.com/'
|
||||
}
|
||||
)
|
||||
let totalNum = 0
|
||||
if (this.haskey(sign, 'data.signInfo.signNum')) {
|
||||
cash += sign.data.signInfo.signNum
|
||||
totalNum = sign.data.totalNum
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
if (sign) {
|
||||
if (sign.code == 302) {
|
||||
p.log('签到过了...')
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.log(sign)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.err("没有获取到数据...")
|
||||
}
|
||||
}
|
||||
if (cash>0) {
|
||||
if (totalNum) {
|
||||
p.msg(`现有: ${totalNum} 获得: ${cash.toFixed(2)}`)
|
||||
}
|
||||
else {
|
||||
p.msg(`获得充值金: ${cash.toFixed(2)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async cmd5x(params = {}) {
|
||||
let p = Object.assign(params, {
|
||||
t: new Date().getTime()
|
||||
})
|
||||
let str = p.id || ''
|
||||
if (p.taskType) {
|
||||
str = `${str}${p.taskType}`
|
||||
}
|
||||
p.encStr = this.md5(`${str}${p.t}e9c398ffcb2d4824b4d0a703e38yffdd`)
|
||||
return p
|
||||
}
|
||||
}
|
||||
58
parse/jd/jd_task_groupHb.js
Normal file
58
parse/jd/jd_task_groupHb.js
Normal file
@ -0,0 +1,58 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东微信群领红包',
|
||||
crontab: 3,
|
||||
headers: {
|
||||
referer: 'https://servicewechat.com/wx91d27dbf599dff74/785/page-frame.html'
|
||||
},
|
||||
sync: 1,
|
||||
interval: 1000
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let reward = await this.curl({
|
||||
'url': `https://api.m.jd.com/groupHb/reward?g_ty=ls&g_tk=1084416199`,
|
||||
'form': `loginType=11&clientType=wxapp&client=apple&clientVersion=10.13.240&build=&osVersion=iOS%2015.1.1&screen=390*844&networkType=wifi&d_brand=iPhone&appid=hot_channel&functionId=miniShake_groupHbReward&sign=&t=1738400991624&body={"gid":"${context.gid}","activityId":"${context.activityId}"}&loginWQBiz=mpmsku&channel=http-direct&partner=&forcebot=`,
|
||||
user,
|
||||
algo: {
|
||||
appId: "050fc",
|
||||
expire: {
|
||||
'subCode': 102
|
||||
}
|
||||
},
|
||||
ua: 'wechat'
|
||||
}
|
||||
)
|
||||
let subCode = this.haskey(reward, 'subCode')
|
||||
if (subCode == 1008) {
|
||||
p.info.work = true
|
||||
p.log('你已经领取过啦!')
|
||||
}
|
||||
else if (subCode == 0) {
|
||||
p.info.work = true
|
||||
p.msg(`${reward.data.rewardDesc}: ${reward.data.rewardAmount}`)
|
||||
}
|
||||
else if (subCode == 1006) {
|
||||
p.info.finish = true
|
||||
p.log("你今天的红包领取次数已经达上限啦!")
|
||||
}
|
||||
else if (subCode == 2004) {
|
||||
p.info.jump = true
|
||||
p.log("黑号无法获取红包")
|
||||
}
|
||||
else {
|
||||
p.log(reward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
89
parse/jd/jd_task_hall.js
Normal file
89
parse/jd/jd_task_hall.js
Normal file
@ -0,0 +1,89 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东特物超级殿堂',
|
||||
crontab: 3,
|
||||
verify: true,
|
||||
sync: 1,
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/?client=wh5&appid=ProductZ4Brand&functionId=superBrandSecondFloorMainPage&body={"source":"hall_1111"}`,
|
||||
algo: {
|
||||
appId: "8adfb",
|
||||
}
|
||||
})
|
||||
let activityId = this.haskey(s, 'data.result.activityBaseInfo.activityId')
|
||||
if (activityId) {
|
||||
this.shareCode({
|
||||
activityId: activityId,
|
||||
source: "hall_1111"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let source = p.context.source
|
||||
let activityId = p.context.activityId
|
||||
let tt = await this.curl({
|
||||
'url': `https://api.m.jd.com/?client=wh5&appid=ProductZ4Brand&functionId=superBrandSecondFloorMainPage&body={"source":"${source}","activityId":${activityId}}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: "8adfb",
|
||||
}
|
||||
}
|
||||
)
|
||||
if (tt.data.bizCode == '0') {
|
||||
let encryptProjectId = tt.data.result.activityBaseInfo.encryptProjectId
|
||||
let url = `https://api.m.jd.com/?client=wh5&appid=ProductZ4Brand&functionId=superBrandTaskList&body={"source":"${source}","activityId":${activityId}}`
|
||||
let l = await this.curl({
|
||||
'url': url,
|
||||
user, algo: {
|
||||
appId: "8adfb",
|
||||
valid: {
|
||||
'data.bizCode': ['1001']
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(l, 'data.result.taskList')) {
|
||||
try {
|
||||
if (i.assignmentName.includes('惊喜领豆')) {
|
||||
if (i.assignmentTimesLimit != i.completionCnt) {
|
||||
p.log("正在运行:", tt.data.result.activityBaseInfo.activityName)
|
||||
let ss = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?client=wh5&appid=ProductZ4Brand&functionId=superBrandDoTask&body={"source":"${source}","activityId":${activityId},"completionFlag":1,"encryptProjectId":"${encryptProjectId}","encryptAssignmentId":"${i.encryptAssignmentId}","assignmentType":${i.assignmentType},"actionType":0,"itemId":""}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: "8adfb",
|
||||
}
|
||||
}
|
||||
)
|
||||
if (ss.data.result.rewards && ss.data.result.rewards != 'null') {
|
||||
for (let r of ss.data.result.rewards) {
|
||||
if (r.awardName.includes('京豆')) {
|
||||
p.msg(`获得${r.beanNum}京豆`)
|
||||
}
|
||||
}
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.info.work = true
|
||||
p.log('已领取过任务', activityId)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
p.log("err", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
103
parse/jd/jd_task_healthy.js
Normal file
103
parse/jd/jd_task_healthy.js
Normal file
@ -0,0 +1,103 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东健康',
|
||||
crontab: 4,
|
||||
round: 2
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
for (let i of Array(2)) {
|
||||
let kit = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=jdh-middle&functionId=jdh_bm_getKitTask&t=1738395115758`,
|
||||
'form': `body={"channel":"jdapp","groupCode":"openkits","m_patch_appKey":"231282000001","imei":"CFFGHFCF"}`,
|
||||
cookie: this.tester()
|
||||
}
|
||||
)
|
||||
if (this.haskey(kit, 'result.encodeId')) {
|
||||
this.dict.encodeId = kit.result.encodeId
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let gift = function(a) {
|
||||
for (let i of this.haskey(a, ['result.result.prizeInfovo', 'result.result.prizeInfovos']) || {}) {
|
||||
if (i.prizeType == 2) {
|
||||
p.msg(`获得京豆: ${i.awardId}`)
|
||||
p.info.work = true
|
||||
}
|
||||
else if (i.prizeType == 14) {
|
||||
p.log("获得健康值:", i.awardId)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (context.round == 0) {
|
||||
if (this.dict.encodeId) {
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=jdh-middle&functionId=jdh_msoa_doTaskGw&t=1738387986997`,
|
||||
'form': `body={"infoId":"jdhHome_task","channel":"jdapp","appKey":"231282000001","encodeId":"${this.dict.encodeId}","imei":"CFFGHFCF","location":{"province":"16","city":"1234","district":"1234","town":"56789"}}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: "8c399"
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'result.result.bizCode', 12)) {
|
||||
p.log("已签到")
|
||||
p.info.work = true
|
||||
}
|
||||
else if (this.haskey(sign, 'result.result.bizCode', 2)) {
|
||||
p.info.work = true
|
||||
gift.bind(this)(sign)
|
||||
}
|
||||
else {
|
||||
p.log(sign)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
let taskList = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=jdh-middle&functionId=jdh_bm_queryTaskList&t=1738398013872`,
|
||||
'form': `body={"activityId":"8542","appKey":"231282000001","channel":"jdapp","imei":"CFFGHFCF","location":{"province":"16","city":"1234","district":"1234","town":"45678"}}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(taskList, 'data.result')) {
|
||||
for (let j of i.taskVoList) {
|
||||
if (j.status == 1) {
|
||||
p.log("正在运行:", i.mainTitle || i.groupName)
|
||||
let doTask = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=jdh-middle&functionId=jdh_msoa_doTaskGw&t=1738398013872`,
|
||||
'form': `body={"appKey":"${j.appKey}","channel":"jdapp","infoId":"jdhHome_task","encodeId":"${j.encodeId}","imei":"CFFGHFCF","location":{"province":"16","city":"1234","district":"1234","town":"45678"}}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
await this.wait(1000)
|
||||
let award = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=jdh-middle&functionId=jdh_msoa_sendAwardGw&t=1738398403434`,
|
||||
'form': `body={"appKey":"${j.appKey}","channel":"jdapp","infoId":"jdhHome_task","activityId":${j.activityId},"queryToken":"${j.encodeId}","taskId":${j.id},"imei":"CFFGHFCF","location":{"province":"16","city":"1234","district":"1234","town":"45678"}}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '8c399'
|
||||
}
|
||||
}
|
||||
)
|
||||
try {
|
||||
gift.bind(this)(award)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
324
parse/jd/jd_task_hudong.js
Normal file
324
parse/jd/jd_task_hudong.js
Normal file
@ -0,0 +1,324 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东互动整合',
|
||||
crontab: 4,
|
||||
sync: 1,
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
if (this[`_${context.category}`]) {
|
||||
try {
|
||||
await this[`_${context.category}`](p)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
if (p.prize.length) {
|
||||
p.prize.unshift(`linkId: ${context.linkId}`)
|
||||
p.msg(p.prize.join("\n"))
|
||||
p.prize = []
|
||||
}
|
||||
}
|
||||
|
||||
async doTask(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let apTask = await this.curl({
|
||||
'url': `https://api.m.jd.com/api`,
|
||||
'form': `functionId=apTaskList&body={"linkId":"${context.linkId}","channel":4}&t=1738479849113&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let isOk = 1
|
||||
for (let i of this.haskey(apTask, 'data')) {
|
||||
if (i.taskLimitTimes == i.taskDoTimes) {
|
||||
p.log("任务已完成:", i.taskShowTitle)
|
||||
}
|
||||
else {
|
||||
isOk = 0
|
||||
p.log(`正在运行:`, i.taskTitle, i.taskType)
|
||||
switch (i.taskType) {
|
||||
case 'SIGN':
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=apsDoTask`,
|
||||
'form': `functionId=apsDoTask&body={"taskType":"${i.taskType}","taskId":${i.id},"channel":4,"checkVersion":true,"linkId":"${context.linkId}","pipeExt":${this.dumps(i.pipeExt)}}&t=1738480459228&appid=activities_platform&client=ios&clientVersion=15.0.11&loginType=2&loginWQBiz=wegame`,
|
||||
algo: {
|
||||
appId: '54ed7'
|
||||
},
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'data.finished')) {
|
||||
p.log("任务完成...")
|
||||
}
|
||||
case 'ORDER_MARK':
|
||||
break
|
||||
case 'BROWSE_CHANNEL':
|
||||
case 'BROWSE_PRODUCT':
|
||||
case 'FOLLOW_SHOP':
|
||||
let apTaskDetail = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=apTaskDetail`,
|
||||
'form': `functionId=apTaskDetail&body={"taskType":"${i.taskType}","taskId":${i.id},"channel":4,"checkVersion":true,"linkId":"${context.linkId}","pipeExt":${this.dumps(i.pipeExt)}}&t=1738480907628&appid=activities_platform&client=ios&clientVersion=15.0.11&`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let taskItemList = this.haskey(apTaskDetail, 'data.taskItemList')
|
||||
if (taskItemList) {
|
||||
for (let j in Array.from(Array(i.taskLimitTimes - i.taskDoTimes), (_val, index) => index)) {
|
||||
if (taskItemList[j] && taskItemList[j].itemId) {
|
||||
if (i.timeLimitPeriod) {
|
||||
let start = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=apStartTaskTime`,
|
||||
'form': `functionId=apStartTaskTime&body={"taskType":"${i.taskType}","taskId":${i.id},"channel":4,"checkVersion":true,"linkId":"${context.linkId}","pipeExt":${this.dumps({
|
||||
...i.pipeExt, ...taskItemList[j].pipeExt
|
||||
})},"taskInsert":false,"itemId":"${encodeURIComponent(taskItemList[j].itemId)}"}&t=1738483884373&appid=activity_platform_se&client=ios&clientVersion=15.0.11&platform=3&loginType=2&loginWQBiz=wegame`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'acb1e'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(start, 'code', 1)) {
|
||||
p.log("失败了")
|
||||
break
|
||||
}
|
||||
p.log(`等待${i.timeLimitPeriod}秒...`)
|
||||
await this.wait(i.timeLimitPeriod * 1000)
|
||||
var doTask = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=apDoLimitTimeTask`,
|
||||
'form': `functionId=apDoLimitTimeTask&body={"linkId":"${context.linkId}"}&t=1738483906048&appid=activities_platform&client=ios&clientVersion=15.0.11&platform=3&loginType=2&loginWQBiz=wegame`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'ebecc'
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
var doTask = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=apsDoTask`,
|
||||
'form': `functionId=apsDoTask&body={"taskType":"${i.taskType}","taskId":${i.id},"channel":4,"checkVersion":true,"linkId":"${context.linkId}","pipeExt":${this.dumps({
|
||||
...i.pipeExt, ...taskItemList[j].pipeExt
|
||||
})},"taskInsert":false,"itemId":"${encodeURIComponent(taskItemList[j].itemId)}"}&t=1738480908001&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
algo: {'appId': '54ed7'},
|
||||
user
|
||||
}
|
||||
)
|
||||
}
|
||||
if (this.haskey(doTask, 'success')) {
|
||||
p.log("任务完成", `[${parseInt(j) + 1}/${i.taskLimitTimes - i.taskDoTimes}]`)
|
||||
}
|
||||
else {
|
||||
p.log("任务失败:", this.haskey(doTask, 'errMsg') || doTask)
|
||||
}
|
||||
await this.wait(3000)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isOk) {
|
||||
isOk = 1
|
||||
apTask = await this.curl({
|
||||
'url': `https://api.m.jd.com/api`,
|
||||
'form': `functionId=apTaskList&body={"linkId":"${context.linkId}","channel":4}&t=1738479849113&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(apTask, 'data')) {
|
||||
if (i.taskLimitTimes == i.taskDoTimes) {
|
||||
}
|
||||
else {
|
||||
switch (i.taskType) {
|
||||
case'ORDER_MARK':
|
||||
case 'SHARE_INVITE':
|
||||
break
|
||||
default:
|
||||
isOk = 0
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
finish: isOk
|
||||
}
|
||||
}
|
||||
|
||||
async _wheels(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let doIt = await this.doTask(p)
|
||||
}
|
||||
|
||||
async _superLeague(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let doIt = await this.doTask(p)
|
||||
let home = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=superLeagueHome`,
|
||||
'form': `functionId=superLeagueHome&body={"linkId":"${context.linkId}","taskId":"","inviter":""}&t=1738481450815&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user,
|
||||
algo: {'appId': 'b7d17', status: true},
|
||||
}
|
||||
)
|
||||
let drawNum = this.haskey(home, 'data.remainTimes') || 0
|
||||
p.log("可抽奖次数:", drawNum)
|
||||
for (let i of Array(drawNum)) {
|
||||
try {
|
||||
let lottery = await this.curl({
|
||||
url: 'https://api.m.jd.com/api?functionId=superLeagueLottery',
|
||||
form: `functionId=superLeagueLottery&body={"linkId":"${context.linkId}"}&t=1738481447131&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
algo: {
|
||||
'appId': '60dc4',
|
||||
expire: {
|
||||
code: 1000
|
||||
}
|
||||
},
|
||||
user
|
||||
})
|
||||
if (this.haskey(lottery, 'code', 18002)) {
|
||||
p.log('抽奖机会用完啦')
|
||||
break
|
||||
}
|
||||
if (this.haskey(lottery, 'data')) {
|
||||
drawNum--
|
||||
let data = lottery.data
|
||||
let prizeType = data.prizeType
|
||||
if (prizeType == 1) {
|
||||
p.log('优惠券:', data.prizeDesc, data.amount)
|
||||
}
|
||||
else if (prizeType == 2) {
|
||||
p.draw(`红包: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 3) {
|
||||
p.draw(`京豆: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 22) {
|
||||
p.draw(`超市卡: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 0) {
|
||||
p.log('没抽到奖品')
|
||||
}
|
||||
else if (prizeType == 17) {
|
||||
p.log('谢谢参与')
|
||||
}
|
||||
else {
|
||||
p.draw(`抽到类型: ${prizeType} ${data.codeDesc} ${data.prizeDesc}`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.err("抽奖错误")
|
||||
break
|
||||
}
|
||||
await this.wait(2000)
|
||||
} catch (e) {
|
||||
p.log(e)
|
||||
}
|
||||
}
|
||||
if (drawNum != 0) {
|
||||
home = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=superLeagueHome`,
|
||||
'form': `functionId=superLeagueHome&body={"linkId":"${context.linkId}","taskId":"","inviter":""}&t=1738481450815&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user,
|
||||
algo: {'appId': 'b7d17'},
|
||||
}
|
||||
)
|
||||
drawNum = this.haskey(home, 'data.remainTimes')
|
||||
}
|
||||
if (doIt.finish && drawNum == 0) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
|
||||
async _lotteryMachine(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let doIt = await this.doTask(p)
|
||||
let home = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=lotteryMachineHome`,
|
||||
'form': `functionId=lotteryMachineHome&body={"linkId":"${context.linkId}","taskId":"","inviter":""}&t=1738481450815&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user,
|
||||
algo: {'appId': 'd7439'},
|
||||
}
|
||||
)
|
||||
let drawNum = this.haskey(home, 'data.remainTimes') || 0
|
||||
p.log("可抽奖次数:", drawNum)
|
||||
for (let i of Array(drawNum)) {
|
||||
try {
|
||||
let lottery = await this.curl({
|
||||
url: 'https://api.m.jd.com/api?functionId=lotteryMachineDraw',
|
||||
form: `functionId=lotteryMachineDraw&body={"linkId":"${context.linkId}"}&t=1738481447131&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
algo: {
|
||||
'appId': 'd7439',
|
||||
expire: {
|
||||
code: 1000
|
||||
}
|
||||
},
|
||||
user
|
||||
})
|
||||
if (this.haskey(lottery, 'code', 18002)) {
|
||||
p.log('抽奖机会用完啦')
|
||||
break
|
||||
}
|
||||
if (this.haskey(lottery, 'data')) {
|
||||
drawNum--
|
||||
let data = lottery.data
|
||||
let prizeType = data.prizeType
|
||||
if (prizeType == 1) {
|
||||
p.log('优惠券:', data.prizeDesc, data.amount)
|
||||
}
|
||||
else if (prizeType == 2) {
|
||||
p.draw(`红包: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 3) {
|
||||
p.draw(`京豆: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 22) {
|
||||
p.draw(`超市卡: ${data.amount}`)
|
||||
}
|
||||
else if (prizeType == 0) {
|
||||
p.log('没抽到奖品')
|
||||
}
|
||||
else if (prizeType == 17) {
|
||||
p.log('谢谢参与')
|
||||
}
|
||||
else {
|
||||
p.draw(`抽到类型: ${prizeType} ${data.codeDesc} ${data.prizeDesc}`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.err("抽奖错误")
|
||||
break
|
||||
}
|
||||
await this.wait(2000)
|
||||
} catch (e) {
|
||||
p.log(e)
|
||||
}
|
||||
}
|
||||
if (drawNum != 0) {
|
||||
home = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=lotteryMachineHome`,
|
||||
'form': `functionId=lotteryMachineHome&body={"linkId":"${context.linkId}","taskId":"","inviter":""}&t=1738481450815&appid=activities_platform&client=ios&clientVersion=15.0.11`,
|
||||
user,
|
||||
algo: {'appId': 'd7439'},
|
||||
}
|
||||
)
|
||||
drawNum = this.haskey(home, 'data.remainTimes')
|
||||
}
|
||||
if (doIt.finish && drawNum == 0) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
314
parse/jd/jd_task_jijin.js
Normal file
314
parse/jd/jd_task_jijin.js
Normal file
@ -0,0 +1,314 @@
|
||||
import {Template} from '../../template.js'
|
||||
import jsdom from "jsdom";
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东财富号',
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
let ua = this.userAgents().jd
|
||||
let resourceLoader = new jsdom.ResourceLoader({
|
||||
userAgent: ua,
|
||||
"referer": "https://iu.jr.jd.com/",
|
||||
});
|
||||
let virtualConsole = new jsdom.VirtualConsole();
|
||||
this.jsConfig = {
|
||||
"url": "https://iu.jr.jd.com/",
|
||||
"referer": "https://iu.jr.jd.com/",
|
||||
"userAgent": ua,
|
||||
runScripts: "dangerously",
|
||||
resources: resourceLoader,
|
||||
includeNodeLocations: true,
|
||||
storageQuota: 10000000,
|
||||
pretendToBeVisual: true,
|
||||
virtualConsole,
|
||||
};
|
||||
let JSDOM = jsdom.JSDOM
|
||||
let a = new JSDOM(`<body><script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/aar2.min.js"></script> <script src="https://m.jr.jd.com/common/jssdk/jrbridge/2.0.0/jrbridge.js"></script> <script src="https://jrsecstatic.jdpay.com/jr-sec-dev-static/cryptico.min.js"></script> </body>`, this.jsConfig)
|
||||
await this.wait(1000)
|
||||
if (a.window.AAR2) {
|
||||
a.window.AAR2.init();
|
||||
this.crypto = {
|
||||
aar: new a.window.AAR2(),
|
||||
cry: a.window.cryptico
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.log("jsdom没有获取到aar2")
|
||||
this.jump = 1
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
const aar = this.crypto.aar
|
||||
let device = {
|
||||
deviceInfo: `{"jsToken":"","fp":"${this.md5(new Date().getTime().toString())}","sdkToken":"jdd016DZNHFZEX6ISWPRAZUKJDKGFIRQJ5MRXPZHLTK3ZIVKLBTD4SEZNDR6S${this.rand(10, 99)}JO2TLV${this.rand(10, 99)}HB5MV6JW52RVAZNXKEXXHGYDCX5MIJ7NSC4DY01234567","eid":"FQ7Z2DTGYZSJM5FKY${this.rand(10, 99)}JLAURRHP2UZHK2ID7554EMNWWNNSK3JBCTLTR45IOP3Z5K3YJHOG${this.rand(10, 99)}SJAOB${this.rand(10, 99)}KVS3RH7G2U","appType":1}`,
|
||||
}
|
||||
var nonce = aar.nonce()
|
||||
var signature = aar.sign(this.dumps(device), nonce)
|
||||
let query = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/queryMission`,
|
||||
json: {
|
||||
"reqData": this.dumps(device),
|
||||
"aar": {
|
||||
nonce, signature
|
||||
}
|
||||
},
|
||||
user
|
||||
}
|
||||
)
|
||||
let ed = this.haskey(query, 'resultData.data') || []
|
||||
let status = 1
|
||||
if (ed.length) {
|
||||
for (let i of ed) {
|
||||
if (i.status == 2) {
|
||||
p.log("任务已完成:", i.name)
|
||||
}
|
||||
else {
|
||||
status = 0
|
||||
p.log("正在运行:", i.name)
|
||||
let device2 = {
|
||||
deviceInfo: `{"jsToken":"","fp":"${this.md5(new Date().getTime().toString())}","sdkToken":"jdd016DZNHFZEX6ISWPRAZUKJDKGFIRQJ5MRXPZHLTK3ZIVKLBTD4SEZNDR6S${this.rand(10, 99)}JO2TLV${this.rand(10, 99)}HB5MV6JW52RVAZNXKEXXHGYDCX5MIJ7NSC4DY01234567","eid":"FQ7Z2DTGYZSJM5FKY${this.rand(10, 99)}JLAURRHP2UZHK2ID7554EMNWWNNSK3JBCTLTR45IOP3Z5K3YJHOG${this.rand(10, 99)}SJAOB${this.rand(10, 99)}KVS3RH7G2U","appType":1}`,
|
||||
missionId: i.missionId
|
||||
}
|
||||
let nonce2 = aar.nonce()
|
||||
let signature2 = aar.sign(this.dumps(device2), nonce2)
|
||||
let nonce3 = aar.nonce()
|
||||
let signature3 = aar.sign(this.dumps(device2), nonce3)
|
||||
if (i.name.includes("关注")) {
|
||||
var data = {}
|
||||
let doLink = i.doLink
|
||||
let pp = this.query(doLink, '&', 1)
|
||||
if (!this.dict[pp.appId]) {
|
||||
let getShop = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/uc/h5/m/getShopAppConfInfo`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let getHome = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/uc/h5/m/getHomePageHeadInfo`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(getShop, 'resultData.data') && this.haskey(getHome, 'resultData.data')) {
|
||||
data = {...getShop.resultData.data, ...getHome.resultData.data}
|
||||
this.dict[pp.appId] = data
|
||||
}
|
||||
}
|
||||
else {
|
||||
data = this.dict[pp.appId]
|
||||
}
|
||||
if (data.appid) {
|
||||
let unfollow = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/uc/h5/m/cancelFollowShop`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"nodeId": data.orgNodeId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"bizType": "notice",
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let receive = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/receiveMission`,
|
||||
json: {
|
||||
"reqData": this.dumps(device2),
|
||||
"aar": {
|
||||
"nonce": nonce2,
|
||||
"signature": signature2
|
||||
}
|
||||
},
|
||||
user,
|
||||
shell: true,
|
||||
referer: 'https://finshop.jd.com/',
|
||||
}
|
||||
)
|
||||
let task = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/couponActivityTake`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"nodeId": data.orgNodeId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"bizType": "notice",
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let follow = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/stock/h5/m/queryFollowFansCount`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"content": data.uid,
|
||||
"channel": 0,
|
||||
"bizType": 17,
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/uc/h5/m/queryShopFollowStatus`,
|
||||
'form': `reqData=${this.dumps({
|
||||
"appId": pp.appId,
|
||||
"origin": "h5",
|
||||
"deviceInfo": this.dumps(device),
|
||||
"modelPreviewType": "1"
|
||||
})}`,
|
||||
user,
|
||||
}
|
||||
)
|
||||
let reward = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/awardMission`,
|
||||
json: {
|
||||
"reqData": this.dumps(device2),
|
||||
"aar": {
|
||||
"nonce": nonce3,
|
||||
"signature": signature3
|
||||
}
|
||||
},
|
||||
user,
|
||||
shell: true,
|
||||
referer: 'https://finshop.jd.com/'
|
||||
}
|
||||
)
|
||||
if (this.haskey(reward, 'resultData.success')) {
|
||||
if (i.awardName == '京豆') {
|
||||
p.draw(i.awardRealNum)
|
||||
}
|
||||
else {
|
||||
p.msg(`${i.awardName}: ${i.awardRealNum}`)
|
||||
}
|
||||
status = 1
|
||||
}
|
||||
else {
|
||||
p.log(reward)
|
||||
}
|
||||
await this.wait(2000)
|
||||
}
|
||||
}
|
||||
else if (i.name.includes("自选")) {
|
||||
let doLink = i.doLink
|
||||
let pp = this.query(doLink, '&', 1)
|
||||
// var data2 = {}
|
||||
// console.log(pp, i)
|
||||
let itemId
|
||||
if (!this.dict[pp.fundCode]) {
|
||||
let product = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/jj/h5/m/getFundDetailPageInfo`,
|
||||
'form': `reqData={"itemId":"","createOrdermaket":"","fundCode":"${pp.fundCode}","clientVersion":null,"channel":"7"}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
itemId = this.haskey(product, 'resultData.datas.headerOfItem.itemId')
|
||||
if (itemId) {
|
||||
this.dict[pp.fundCode] = itemId
|
||||
}
|
||||
}
|
||||
else {
|
||||
itemId = this.dict[pp.fundCode]
|
||||
}
|
||||
if (itemId) {
|
||||
let cancel = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/jj/h5/m/cancelFundZxProduct`,
|
||||
'form': `reqData={"fundIds":["${itemId}"],"clientType":"ios","channel":"7"}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let receive = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/receiveMission`,
|
||||
json: {
|
||||
"reqData": this.dumps(device2),
|
||||
"aar": {
|
||||
"nonce": nonce2,
|
||||
"signature": signature2
|
||||
}
|
||||
},
|
||||
user,
|
||||
shell: true,
|
||||
referer: 'https://finshop.jd.com/',
|
||||
}
|
||||
)
|
||||
let add = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw/generic/jj/h5/m/addFundZxProduct`,
|
||||
'form': `reqData={"fundId":"${itemId}","clientType":"ios","systemId":"JJXQ0001","channel":"7"}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let reward = await this.curl({
|
||||
'url': `https://ms.jr.jd.com/gw2/generic/finshop/h5/m/awardMission`,
|
||||
json: {
|
||||
"reqData": this.dumps(device2),
|
||||
"aar": {
|
||||
"nonce": nonce3,
|
||||
"signature": signature3
|
||||
}
|
||||
},
|
||||
user,
|
||||
shell: true,
|
||||
referer: 'https://finshop.jd.com/'
|
||||
}
|
||||
)
|
||||
if (this.haskey(reward, 'resultData.success')) {
|
||||
if (i.awardName == '京豆') {
|
||||
p.draw(i.awardRealNum)
|
||||
}
|
||||
else {
|
||||
p.msg(`${i.awardName}: ${i.awardRealNum}`)
|
||||
}
|
||||
status = 1
|
||||
}
|
||||
else {
|
||||
p.log(reward)
|
||||
}
|
||||
await this.wait(2000)
|
||||
}
|
||||
else {
|
||||
status = 0
|
||||
p.log("没有获取到itemId")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = 0
|
||||
p.err("没有获取到数据...")
|
||||
}
|
||||
if (status) {
|
||||
p.info.work = true
|
||||
}
|
||||
if (p.prize.length) {
|
||||
let sum = p.prize.reduce((v, k) => {
|
||||
v += parseInt(k)
|
||||
return v
|
||||
}, 0)
|
||||
p.msg(`获得京豆: ${sum}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
parse/jd/jd_task_jutou.js
Normal file
53
parse/jd/jd_task_jutou.js
Normal file
@ -0,0 +1,53 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东惊喜红包",
|
||||
sync: 1,
|
||||
verify: 1,
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=jutouDisplayIndex&appid=pages-factory&body={"channelId":"${context.channelId}","lid":"MoIOQdTTwYxNCANy+PtpgKuTTLLFbZZT","ext":{"babelActivityId":"01817502"}}&client=wh5&clientVersion=15.0.11&loginType=2&h5st=&x-api-eid-token=jdd03C3HUEKC6G2V5WV6SOXJV5E4J2ILKIIHLPARTU7DKUSMS72ICFUVMMF7ZVZXDON6VLTUCVU2GNZ2RZRMVIDXGF2FBMUAAAAMU2QLD6YAAAAAADZUTVAX5ZTVVYAX`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '35fa0'
|
||||
}
|
||||
}
|
||||
)
|
||||
let n = 0
|
||||
for (let i of this.haskey(s, 'data.componentDisplayList')) {
|
||||
for (let j of i.materialInfo) {
|
||||
if (this.haskey(j, 'materialDetail.discount')) {
|
||||
n++
|
||||
if (j.materialType == 6) {
|
||||
p.msg(`红包: ${j.materialDetail.discount}`)
|
||||
}
|
||||
else if (j.materialType == 2) {
|
||||
p.log("优惠券:", j.materialDetail.discount)
|
||||
}
|
||||
else {
|
||||
p.log(j.materialDetail)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log(j.materialDetail)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!n) {
|
||||
console.log("本次执行没有获得红包")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
parse/jd/jd_task_pcSign.js
Normal file
44
parse/jd/jd_task_pcSign.js
Normal file
@ -0,0 +1,44 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东网页签到',
|
||||
crontab: 2
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `appid=asset-h5&clientVersion=1.0.0&client=pc&body={"type":1}&functionId=jsfbox_bean_sign`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '73c2f',
|
||||
type: 'wechat'
|
||||
},
|
||||
referer: 'https://bean.jd.com/myJingBean/list',
|
||||
ua: "Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/" + 59 + Math.round(Math.random() * 10) + ".0.3497." + Math.round(Math.random() * 100) + "Safari/537.36",
|
||||
extend: `uuid=${this.uuid(22, 'n')}&area=16_${this.rand(1000, 1300)}_${this.rand(1000, 1300)}_${this.rand(1, 19)}&loginType=2&t=${new Date().getTime()}`
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'data.receiveBeanNum')) {
|
||||
p.msg(`京豆: ${sign.data.receiveBeanNum}`)
|
||||
p.info.work = true
|
||||
}
|
||||
else if (this.haskey(sign, 'code', 301)) {
|
||||
p.log("重复签到")
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.log(sign)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
66
parse/jd/jd_task_price.js
Normal file
66
parse/jd/jd_task_price.js
Normal file
@ -0,0 +1,66 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东保价",
|
||||
crontab: 2,
|
||||
keyExpire: 600,
|
||||
prompt: {
|
||||
coupon: '1 #默认不使用券保价'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=mlproprice_skuOnceApply_jsf&appid=price_protection&loginType=2&body={"onceBatchId":"","couponConfirmFlag":null,"type":"25"}&client=apple&clientVersion=&x-api-eid-token=jdd03C3HUEKC6G2V5WV6SOXJV5E4J2ILKIIHLPARTU7DKUSMS72ICFUVMMF7ZVZXDON6VLTUCVU2GNZ2RZRMVIDXGF2FBMUAAAAMQFQIBMFAAAAAACIQ46Z6H2VWO6MX&h5st=&t=1718726274981`,
|
||||
user,
|
||||
algo: {
|
||||
status: true,
|
||||
appId: '6f46e'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(s, 'data')) {
|
||||
p.info.work = true
|
||||
}
|
||||
if (this.haskey(s, 'data.succAmount')) {
|
||||
p.msg(`保价: ${s.data.succAmount}`)
|
||||
}
|
||||
else if (this.haskey(s, 'data.confirmCouponInfos.0.couponId')) {
|
||||
let onceBatchId = this.haskey(s, 'data.onceBatchId')
|
||||
if (this.profile.coupon) {
|
||||
p.log("当前可用优惠券保价")
|
||||
let ss = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
'form': `functionId=mlproprice_skuOnceApply_jsf&appid=price_protection&loginType=2&body={"onceBatchId":"${onceBatchId}","couponConfirmFlag":1,"type":"25"}&client=apple&clientVersion=&x-api-eid-token=jdd03UT42BFT33TGS6GOIOWXCCOFR2T5UM44HG27BZ3JBLL5TQWMEHHCGMANY7T3YNDDBPISS4SS7Z7C7T3OFBOP5QFT2KIAAAAMRENKUBUQAAAAACBZLQEQUA7ANXQX&h5st=&t=1722874735852`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '6f46e'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(ss, 'data.succAmount')) {
|
||||
p.msg(`用券保价: ${ss.data.succAmount}`)
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(ss, ['data.onceApplyNoSuccessTips', 'data.responseMessage']) || s)
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.print("有可用券可以保价", p.user)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(s, ['data.onceApplyNoSuccessTips', 'data.responseMessage']) || s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
parse/jd/jd_task_receive.js
Normal file
43
parse/jd/jd_task_receive.js
Normal file
@ -0,0 +1,43 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东支付返京豆',
|
||||
crontab: `${this.rand(0, 59)} ${this.rand(0, 21)} */3 * *`
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let receive = await this.curl({
|
||||
'url': `https://api.m.jd.com/api`,
|
||||
'form': `functionId=rights_receiveJdBean_v1&appid=plus_business&loginType=2&loginWQBiz=&body={}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'b63ff',
|
||||
expire: {
|
||||
code: 'F10002'
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(receive, 'rs.receiveAmount')) {
|
||||
this.msg(`订单数量:${receive.rs.orderCount} 返豆: ${receive.rs.receiveAmount}`)
|
||||
p.info.work = true
|
||||
}
|
||||
else if (this.haskey(receive, 'code', '1780021')) {
|
||||
p.log("没有可以返豆的订单")
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(receive, 'msg') || receive)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
163
parse/jd/jd_task_rmCart.js
Normal file
163
parse/jd/jd_task_rmCart.js
Normal file
@ -0,0 +1,163 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东删除购物车',
|
||||
prompt: {
|
||||
whiteList: '保留关键词,关键词1|关键词2',
|
||||
blackList: '只删除关键词,关键词1|关键词2'
|
||||
},
|
||||
headers: {
|
||||
"referer": "https://cart.jd.com/cart_index/",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let cart = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?functionId=pcCart_jc_getCurrentCart&appid=JDC_mall_cart&loginType=3&t=1717947580116&client=pc&clientVersion=1.0.0&body={"serInfo":{"user-key":""},"cartExt":{"specialId":1}}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'f961a'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (!this.haskey(cart, 'resultData.cartInfo.vendors')) {
|
||||
p.err("没有获取到购物车数据")
|
||||
return
|
||||
}
|
||||
let skus = []
|
||||
let packs = []
|
||||
let whiteList, blackList
|
||||
if (this.profile.whiteList) {
|
||||
whiteList = (this.profile.whiteList).split(",").join('|')
|
||||
}
|
||||
else if (this.profile.blackList) {
|
||||
blackList = (this.profile.blackList).split(",").join('|')
|
||||
}
|
||||
let status = 0
|
||||
if (this.haskey(cart, 'resultData.cartInfo.vendors')) {
|
||||
status++
|
||||
for (let i of cart.resultData.cartInfo.vendors) {
|
||||
for (let j of this.haskey(i, 'sorted')) {
|
||||
if (this.haskey(j, 'item.items')) {
|
||||
if (j.item.items.length>0) {
|
||||
for (let k of j.item.items) {
|
||||
if (whiteList) {
|
||||
if (!k.item.Name.match(whiteList)) {
|
||||
packs.push(
|
||||
{
|
||||
"num": k.item.Num.toString(),
|
||||
"ybPackId": j.item.promotionId,
|
||||
"sType": "11",
|
||||
"TheSkus": [{"num": k.item.Num.toString(), "Id": k.item.Id.toString()}],
|
||||
"Id": j.item.promotionId
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
else if (blackList) {
|
||||
if (k.item.Name.match(blackList)) {
|
||||
packs.push(
|
||||
{
|
||||
"num": k.item.Num.toString(),
|
||||
"ybPackId": j.item.promotionId,
|
||||
"sType": "11",
|
||||
"TheSkus": [{"num": k.item.Num.toString(), "Id": k.item.Id.toString()}],
|
||||
"Id": j.item.promotionId
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
let packss = {
|
||||
"num": k.item.Num.toString(),
|
||||
"ybPackId": (j.item.promotionId || j.item.Id).toString(),
|
||||
"sType": "11",
|
||||
"TheSkus": [{"num": k.item.Num.toString(), "Id": k.item.Id.toString()}],
|
||||
"Id": (j.item.promotionId || j.item.vid).toString()
|
||||
}
|
||||
if (this.haskey(k, 'item.skuUuid')) {
|
||||
packss.skuUuid = k.item.skuUuid
|
||||
packss.TheSkus[0].skuUuid = k.item.skuUuid
|
||||
// packss.sType = "4"
|
||||
packss.useUuid = false
|
||||
packss.TheSkus[0].useUuid = false
|
||||
}
|
||||
packs.push(
|
||||
packss
|
||||
)
|
||||
}
|
||||
// if (k.item.stockState != "无货" && k.item.checkBoxText != "预售") {
|
||||
// }
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (whiteList) {
|
||||
if (!j.item.Name.match(whiteList)) {
|
||||
skus.push(
|
||||
{
|
||||
"num": j.item.Num.toString(),
|
||||
"Id": j.item.Id.toString(),
|
||||
"skuUuid": j.item.skuUuid,
|
||||
"useUuid": j.item.useUuid
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
else if (blackList) {
|
||||
if (j.item.Name.match(blackList)) {
|
||||
skus.push(
|
||||
{
|
||||
"num": j.item.Num.toString(),
|
||||
"Id": j.item.Id.toString(),
|
||||
"skuUuid": j.item.skuUuid,
|
||||
"useUuid": j.item.useUuid
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
skus.push(
|
||||
{
|
||||
"num": j.item.Num.toString(),
|
||||
"Id": j.item.Id.toString(),
|
||||
"skuUuid": j.item.skuUuid,
|
||||
"useUuid": j.item.useUuid
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p.log('即将删除购物车数目:', skus.length + packs.length)
|
||||
if (skus.length>0 || packs.length>0) {
|
||||
let cartRemove = await this.curl({
|
||||
'url': `https://api.m.jd.com/api`,
|
||||
'form': `functionId=pcCart_jc_cartRemove&appid=JDC_mall_cart&body=${this.dumps({
|
||||
"operations": [{
|
||||
"carttype": "4",
|
||||
"TheSkus": skus,
|
||||
"ThePacks": packs
|
||||
}], "serInfo": {}
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
p.msg(`删除购物车: ${skus.length + packs.length}`)
|
||||
if (status) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
85
parse/jd/jd_task_rmCoupon.js
Normal file
85
parse/jd/jd_task_rmCoupon.js
Normal file
@ -0,0 +1,85 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东优惠券删除',
|
||||
prompt: {
|
||||
blackList: "删除关键词,多个用|隔开"
|
||||
},
|
||||
headers: {
|
||||
referer: 'https://servicewechat.com/wx91d27dbf599dff74/760/page-frame.html'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
let field = await this.getField('blackList')
|
||||
if (!field) {
|
||||
this.shareCode({
|
||||
blackList: "专营店|个护|卖场店"
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.shareCode({
|
||||
blackList: field.join("|")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let list = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=queryJdCouponListAppletForJd&appid=jdmini-wx-search&body={"bizModelCode":"6","externalLoginType":"1","bizModeClientType":"WxMiniProgram","appId":"wx91d27dbf599dff74","token":"1999de6cba778f25f29720b0bbf7ff8b","tenantCode":"jgminise","sourceType":"wx_inter_myjd_couponlist","state":1,"wxadd":1,"filterswitch":1,"s":""}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '245ec'
|
||||
}
|
||||
}
|
||||
)
|
||||
let rm = []
|
||||
let reg = new RegExp(context.blackList)
|
||||
let status = 0
|
||||
// console.log(list)
|
||||
if (this.haskey(list, 'coupon.useable')) {
|
||||
status++
|
||||
|
||||
for (let i of list.coupon.useable) {
|
||||
if (this.match(reg, i.limitStr)) {
|
||||
rm.push(i.couponid)
|
||||
}
|
||||
}
|
||||
}
|
||||
let n = 0
|
||||
if (rm.length>0) {
|
||||
for (let _ of Array(Math.ceil(rm.length / 50))) {
|
||||
let cp = rm.splice(0, 50).map(d => {
|
||||
return `${d},1,0`
|
||||
}).join("|")
|
||||
let del = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=deleteCouponListApplet&appid=jdmini-wx-search&body={"bizModelCode":"6","externalLoginType":"1","bizModeClientType":"WxMiniProgram","appId":"wx91d27dbf599dff74","token":"1999de6cba778f25f29720b0bbf7ff8b","tenantCode":"jgminise","sourceType":"wx_inter_myjd_couponlist","couponinfolist":"${cp}"}&uuid=21466657159301714025030891&openudid=21466657159301714025030891&xAPIScval2=wx&g_ty=ls&g_tk=1678530361`,
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(del, 'deleteresult')) {
|
||||
p.log("删除中:", del.deleteresult.length)
|
||||
n += del.deleteresult.length
|
||||
}
|
||||
await this.wait(2000)
|
||||
}
|
||||
}
|
||||
if (n) {
|
||||
p.info.work = true
|
||||
p.msg(`删除${n}个优惠券`)
|
||||
}
|
||||
else {
|
||||
if (status) {
|
||||
p.info.work = true
|
||||
}
|
||||
p.log("本次执行,没有可删除的优惠券")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
103
parse/jd/jd_task_shopSign.js
Normal file
103
parse/jd/jd_task_shopSign.js
Normal file
@ -0,0 +1,103 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东店铺签到',
|
||||
crontab: `${this.rand(0, 59)} 0,${this.rand(1, 12)} * * *`,
|
||||
sync: 1,
|
||||
verify: 1,
|
||||
tempExpire: 7 * 86400,
|
||||
prompt: {
|
||||
token: "店铺签到token|token1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
await this.field('token')
|
||||
}
|
||||
|
||||
async batch(p) {
|
||||
p = this.getTemp(p.pid) || p
|
||||
if (!p.shopName) {
|
||||
var s = await this.curl({
|
||||
url: `https://api.m.jd.com/api?appid=interCenter_shopSign&loginType=2&functionId=interact_center_shopSign_getActivityInfo&body={"token":"${p.token}","venderId":""}`,
|
||||
referer: 'https://h5.m.jd.com/',
|
||||
algo: {
|
||||
appId: '4da33',
|
||||
}
|
||||
})
|
||||
if (this.haskey(s, 'data.id')) {
|
||||
let shopInfo = await this.curl({
|
||||
'url': `https://api.m.jd.com/`,
|
||||
form: `functionId=whx_getMShopOutlineInfo&body={"venderId":"${s.data.venderId}","originReferer":"shopx","source":"m-shop"}&t=1727955137220&avifSupport=0&webpSupport=0&appid=wx_mini_app&clientVersion=11.0.0&client=wh5&uuid=08635116374331727444274533&loginType=11&area=&fp=c68b3c68639ae2d76f00dfb51e463e08f251bf09`,
|
||||
referer: 'https://servicewechat.com/wx91d27dbf599dff74/765/page-frame.html',
|
||||
algo: {
|
||||
appId: '4da33',
|
||||
}
|
||||
})
|
||||
if (this.haskey(shopInfo, 'data.shopInfo.shopName')) {
|
||||
p.shopName = shopInfo.data.shopInfo.shopName
|
||||
p.activityId = s.data.id
|
||||
p.venderId = s.data.venderId
|
||||
p.continuePrizeRuleList = s.data.continuePrizeRuleList
|
||||
}
|
||||
}
|
||||
if (this.haskey(s, 'code', 402)) {
|
||||
p.expired = true
|
||||
}
|
||||
}
|
||||
p.hide = ['continuePrizeRuleList']
|
||||
return p
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/api?appid=interCenter_shopSign&loginType=2&functionId=interact_center_shopSign_getSignRecord&body={"token":"${context.token}","venderId":${context.venderId},"activityId":${context.activityId},"type":56,"actionType":7}&jsonp=jsonp1004`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '4da33',
|
||||
expire: {
|
||||
code: 407000007
|
||||
}
|
||||
}
|
||||
})
|
||||
if (this.haskey(s, 'code', 402)) {
|
||||
p.log('当前不存在有效的活动')
|
||||
p.context.finish = true
|
||||
return
|
||||
}
|
||||
let days = this.haskey(s, 'data.days')
|
||||
let maxDay = this.column(context.continuePrizeRuleList, 'days').reduce((v, k) => {
|
||||
return v += k
|
||||
}, 0)
|
||||
if (days>=maxDay) {
|
||||
console.log(`签到已满${maxDay}天,跳出签到`, context.token, `https://shop.m.jd.com/?venderId=${context.venderId}`)
|
||||
}
|
||||
else {
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com`,
|
||||
form: `appid=interCenter_shopSign&loginType=2&functionId=interact_center_shopSign_signCollectGift&body={"token":"${context.token}","venderId":${context.venderId},"activityId":${context.activityId},"type":56,"actionType":7}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '4da33',
|
||||
version: 'latest'
|
||||
},
|
||||
})
|
||||
if (this.haskey(sign, 'code', [403030023, 200])) {
|
||||
p.info.work = true
|
||||
if (sign.success) {
|
||||
p.log(`签到: ${days + 1}天`, context.token, context.shopName)
|
||||
}
|
||||
else {
|
||||
p.log(sign.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
69
parse/jd/jd_task_signIn.js
Normal file
69
parse/jd/jd_task_signIn.js
Normal file
@ -0,0 +1,69 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东整合签到",
|
||||
crontab: 3,
|
||||
sync: 1,
|
||||
verify: 1,
|
||||
model: 'user',
|
||||
display: true,
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
p.log("正在签到:", p.context.name)
|
||||
let appid = this.config.appids[this.n % this.config.appids.length]
|
||||
let signIn = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action`,
|
||||
form: `functionId=doInteractiveAssignment&appid=${appid}&body=${this.dumps({
|
||||
"sourceCode": context.sourceCode || 'acetttsign',
|
||||
"encryptProjectId": context.encryptProjectId,
|
||||
"encryptAssignmentId": context.encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"itemId": "1",
|
||||
})}&sign=11&t=1710422476977`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e2224',
|
||||
log: true,
|
||||
// code: ['0']
|
||||
}
|
||||
}
|
||||
)
|
||||
let subCode = this.haskey(signIn, 'subCode')
|
||||
if (subCode == '103') {
|
||||
p.log(signIn.msg)
|
||||
p.info.work = true
|
||||
}
|
||||
else if (subCode == '102') {
|
||||
p.context.finish = true
|
||||
p.log("项目已结束")
|
||||
}
|
||||
else if (subCode == '300') {
|
||||
p.log(signIn.msg)
|
||||
p.info.jump = true
|
||||
}
|
||||
else if (this.haskey(signIn, 'code', '31')) {
|
||||
p.err(signIn.msg)
|
||||
}
|
||||
if (this.haskey(signIn, 'rewardsInfo.successRewards')) {
|
||||
p.info.work = true
|
||||
for (let kk in signIn.rewardsInfo.successRewards) {
|
||||
for (let kkk of signIn.rewardsInfo.successRewards[kk]) {
|
||||
let text = `${kkk.rewardName}: ${kkk.quantity}`
|
||||
p.msg(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.n++
|
||||
}
|
||||
}
|
||||
|
||||
378
parse/jd/jd_task_smGame.js
Normal file
378
parse/jd/jd_task_smGame.js
Normal file
@ -0,0 +1,378 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东超市游戏',
|
||||
crontab: 4
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let temp = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/meta2GetRoomListByTemplateId`,
|
||||
'form': `appid=commonActivity&functionId=meta2GetRoomListByTemplateId&body={"templateId":"793888596"}&t=1713402796644`,
|
||||
user,
|
||||
algo: {
|
||||
expire: {
|
||||
'code': 201
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
let login = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/meta2LoginGame`,
|
||||
'form': `appid=commonActivity&functionId=meta2LoginGame&body={"channel":"2","roomId":"125"}&t=1713402797289`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let getToken = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_getRequestToken`,
|
||||
'form': `appid=commonActivity&functionId=arvr_getRequestToken&body=${this.getBody({
|
||||
"rewardType": 6,
|
||||
"activityId": "ba6e852dd2bc05a1de75b2d2dc9fda305096bcc0",
|
||||
"appId": "app_440",
|
||||
})}&t=1713402797485`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let accessToken = this.haskey(getToken, 'data')
|
||||
// 奖项目-正式
|
||||
let info3 = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_queryInteractiveInfoNew`,
|
||||
'form': `appid=commonActivity&functionId=arvr_queryInteractiveInfoNew&body=${this.getBody({
|
||||
"projectId": "2177780",
|
||||
"projectKey": "2NjrCfgtPwoW8zjA7zjvKgvN3aSL",
|
||||
"sourceCode": 5,
|
||||
"channel": "2",
|
||||
"queryTypes": 6,
|
||||
})}`,
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(info3, 'assignmentList.0.encryptAssignmentId')) {
|
||||
for (let i of Array(info3.assignmentList[0].assignmentTimesLimit - info3.assignmentList[0].completionCnt)) {
|
||||
let r = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_rewardNew`,
|
||||
'form': `appid=commonActivity&functionId=arvr_rewardNew&body=${this.getBody({
|
||||
"projectId": "2177780",
|
||||
"projectKey": "2NjrCfgtPwoW8zjA7zjvKgvN3aSL",
|
||||
"sourceCode": 5,
|
||||
"channel": "2",
|
||||
"encryptAssignmentId": info3.assignmentList[0].encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"rewardType": 1,
|
||||
})}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e3be6'
|
||||
}
|
||||
}
|
||||
)
|
||||
for (let g in this.haskey(r, 'rewardsInfo.successRewards')) {
|
||||
let data = r.rewardsInfo.successRewards[g]
|
||||
for (let k of data) {
|
||||
p.log("抽奖获得:", k.rewardName)
|
||||
}
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
}
|
||||
let info2 = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_queryInteractiveInfoNew`,
|
||||
'form': `appid=commonActivity&functionId=arvr_queryInteractiveInfoNew&body=${this.getBody({
|
||||
"projectId": "1753589",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
"sourceCode": 2,
|
||||
"channel": "2",
|
||||
})}&t=1713402797485`,
|
||||
user
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(info2, 'assignmentList')) {
|
||||
if (i.completionFlag) {
|
||||
p.log(`任务已经完成: ${i.assignmentName}`)
|
||||
}
|
||||
else {
|
||||
p.log(`正在运行: ${i.assignmentName}`)
|
||||
let extraType = i.ext.extraType
|
||||
if ([7777].includes(i.assignmentType)) {
|
||||
p.log("任务跳过")
|
||||
}
|
||||
else if (i.assignmentType == 9) {
|
||||
p.log("正在分享...")
|
||||
for (let __ of Array(3)) {
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_rewardNew`,
|
||||
'form': `appid=commonActivity&functionId=arvr_rewardNew&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1753589",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
"sourceCode": 2,
|
||||
"channel": "2",
|
||||
"encryptAssignmentId": i.encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"rewardType": 0,
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'e3be6'
|
||||
}
|
||||
}
|
||||
)
|
||||
p.log(this.haskey(s, 'msg'))
|
||||
if (!this.haskey(s, 'assignmentInfo')) {
|
||||
break
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
}
|
||||
else if (this.haskey(i, `ext.${i.ext.extraType}`)) {
|
||||
let extra = i.ext[extraType]
|
||||
if (extraType == 'sign') {
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
accessToken, "channel": "2",
|
||||
"sourceCode": 2,
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"itemId": "1",
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
p.log("签到:", this.haskey(sign, 'msg'))
|
||||
}
|
||||
else if (extraType == 'assistTaskDetail') {
|
||||
let index = parseInt(p.index) + 1
|
||||
for (let o of Array(i.assignmentTimesLimit)) {
|
||||
for (let k of Array(0)) {
|
||||
let assist = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
accessToken, "channel": "2",
|
||||
"sourceCode": 2,
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"itemId": extra.itemId,
|
||||
"actionType": 0,
|
||||
"completionFlag": true,
|
||||
"ext": {
|
||||
"assistEncryptAssignmentId": i.encryptAssignmentId,
|
||||
"assistInfoFlag": 2,
|
||||
"inviteId": ""
|
||||
},
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
index++
|
||||
p.log(assist)
|
||||
if (this.haskey(assist, 'msg', '任务完成')) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
for (let j of extra.slice(0, i.assignmentTimesLimit)) {
|
||||
if (['shoppingActivity', 'productsInfo', 'browseShop', 'brandMemberList'].includes(extraType)) {
|
||||
let d = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
accessToken, "channel": "2",
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"itemId": j.itemId || j.advId,
|
||||
sourceCode: 2,
|
||||
"actionType": 1,
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
await this.wait((i.ext.waitDuration || 0) * 1000 + 500)
|
||||
if (extraType == 'brandMemberList' && this.profile.openCard) {
|
||||
let jo = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action`,
|
||||
'form': `functionId=bindWithVender&body={"venderId":"${j.vendorIds}","shopId":"${j.vendorIds}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0,"channel":4202,"appid":"27004","needSecurity":true,"bizId":"shopmember_m_jd_com"}&t=1715046616857&appid=shopmember_m_jd_com&clientVersion=9.2.0&client=H5&&x-api-eid-token=jdd03C3HUEKC6G2V5WV6SOXJV5E4J2ILKIIHLPARTU7DKUSMS72ICFUVMMF7ZVZXDON6VLTUCVU2GNZ2RZRMVIDXGF2FBMUAAAAMPKC6XVGYAAAAACHGDUSO4UHYMGEX`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '27004'
|
||||
}
|
||||
}
|
||||
)
|
||||
p.log('开卡', j.title, this.haskey(jo, 'message') || jo)
|
||||
await this.wait(1000)
|
||||
}
|
||||
}
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
accessToken, "channel": "2",
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"itemId": j.itemId || j.advId,
|
||||
sourceCode: 2,
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
p.log(i.assignmentName, s.msg)
|
||||
if (this.haskey(s, 'msg', '风险等级未通过')) {
|
||||
return
|
||||
}
|
||||
if (this.haskey(s, 'msg', '活动太火爆了')) {
|
||||
break
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i.assignmentName) {
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
accessToken, "channel": "2",
|
||||
"sourceCode": 2,
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"itemId": "1",
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
p.log(i.assignmentName, s.msg)
|
||||
await this.wait(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
let ri = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_queryInteractiveRewardInfo`,
|
||||
'form': `appid=commonActivity&functionId=arvr_queryInteractiveRewardInfo&body=${this.getBody({
|
||||
"pageSize": 10,
|
||||
"currentPage": 1,
|
||||
"projectId": "1753589",
|
||||
"projectKey": "4HT4fFeDbw11QaPmWvhdWctUQqn3",
|
||||
"sourceCode": 2,
|
||||
"needExchangeRestScore": 1
|
||||
})}`,
|
||||
user,
|
||||
algo: {appId: '84692'}
|
||||
}
|
||||
)
|
||||
var score = this.haskey(ri, 'scoreInfoMap.usable') || 0
|
||||
p.log("当前体力:", score)
|
||||
// 东东超市-汪贝任务
|
||||
let info1 = await this.curl({
|
||||
'url': `https://api.m.jd.com/api/arvr_queryInteractiveInfoNew`,
|
||||
'form': `appid=commonActivity&functionId=arvr_queryInteractiveInfoNew&body=${this.getBody({
|
||||
"projectId": "1764671",
|
||||
"projectKey": "2nym8aW7jNKRbmxXLdbb75m3ebSH",
|
||||
"sourceCode": 2,
|
||||
"channel": "2",
|
||||
"queryTypes": 6,
|
||||
})}&t=1713402797485`,
|
||||
user
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(info1, 'assignmentList')) {
|
||||
if (i.completionFlag) {
|
||||
p.log(`任务已经完成: ${i.assignmentName}`)
|
||||
}
|
||||
else {
|
||||
if (new Date(i.assignmentEndTime).getTime()>new Date().getTime() && i.assignmentName && this.match(/收银|解锁|升级|补货|离线/, i.assignmentName)) {
|
||||
p.log(`正在运行: ${i.assignmentName}`)
|
||||
if (score>=i.exchangeRate) {
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action?functionId=arvr_doInteractiveAssignmentNew`,
|
||||
'form': `appid=commonActivity&body=${(await this.getBody(
|
||||
{
|
||||
"projectId": "1764671",
|
||||
"projectKey": "2nym8aW7jNKRbmxXLdbb75m3ebSH",
|
||||
accessToken, "channel": "2",
|
||||
"sourceCode": 2,
|
||||
subTaskId: i.encryptAssignmentId,
|
||||
"completionFlag": true,
|
||||
"exchangeNum": "1",
|
||||
}
|
||||
))}&sign=11&t=1653132222710`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '84692'
|
||||
}
|
||||
}
|
||||
)
|
||||
score = score - i.exchangeRate + (this.haskey(s, 'assignmentInfo.increUsedScore') || 0)
|
||||
p.log("使用体力:", i.exchangeRate, s.msg, '当前体力:', score)
|
||||
await this.wait(1000)
|
||||
}
|
||||
else {
|
||||
p.log("体力不足...")
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getBody(params) {
|
||||
let str = "",
|
||||
map = Object.keys(params).sort(function(d, k) {
|
||||
return d.localeCompare(k);
|
||||
});
|
||||
for (let __i of map) {
|
||||
str = str.concat(params[__i]);
|
||||
}
|
||||
let t = Date.now();
|
||||
let r = "".concat("c4491f13dce9c71f").concat(str).concat(t);
|
||||
let md5 = this.md5(r)
|
||||
params.timestamp = t;
|
||||
params.sign = md5;
|
||||
params.signKey = "c4491f13dce9c71f";
|
||||
return this.dumps(params);
|
||||
}
|
||||
}
|
||||
|
||||
175
parse/jd/jd_task_superMarket.js
Normal file
175
parse/jd/jd_task_superMarket.js
Normal file
@ -0,0 +1,175 @@
|
||||
import {Template} from '../../template.js'
|
||||
import {load} from 'cheerio'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东超市',
|
||||
crontab: 4
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
this.shareCode({
|
||||
id: '3nh7HzSjYemGqAHSbktTrf8rrH8M'
|
||||
})
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
if (this.turnCound == 0) {
|
||||
var html = await this.curl({
|
||||
'url': `https://pro.m.jd.com/mall/active/${context.id}/index.html?stath=20&navh=44&babelChannel=ttt1&tttparams=zZ1qguleyJnTGF0IjozOS45NjEwNTQsInVuX2FyZWEiOiIxXzI4MDBfNTU4MzhfMCIsImRMYXQiOiIiLCJwcnN0YXRlIjoiMCIsImFkZHJlc3NJZCI6IjUzODg3NDg3NyIsImxhdCI6IiIsInBvc0xhdCI6MzkuOTYxMDU0LCJwb3NMbmciOjExNi4zMjIwNjEsImdwc19hcmVhIjoiMF8wXzBfMCIsImxuZyI6IiIsInVlbXBzIjoiMC0wLTAiLCJnTG5nIjoxMTYuMzIyMDYxLCJtb2RlbCI6ImlQaG9uZTEzLDMiLCJkTG5nIjoiIn70=`,
|
||||
user,
|
||||
referer: 'https://pro.m.jd.com/mall/active/3nh7HzSjYemGqAHSbktTrf8rrH8M/index.html'
|
||||
}
|
||||
)
|
||||
// for(let i of this.matchAll(/<script>([^\<]+)<\/script>/g,html)){
|
||||
// p.log(this.jsonParse(i))
|
||||
// }
|
||||
let react = this.jsonParse(this.match([/__react_data__\s*=\s*(.*?)\s*;\n+/,], html))
|
||||
let signToken = this.match(/"signToken"\s*:\s*"(\w+)"/, html)
|
||||
if (signToken) {
|
||||
let sign = await this.curl({
|
||||
'url': `https://api.m.jd.com/atop_channel_sign_in`,
|
||||
'form': `appid=jd-super-market&t=1713230766545&functionId=atop_channel_sign_in&client=m&uuid=de21c6604748f97dd3977153e51a47f4efdb9a47&body={"signToken":"${signToken}","channelFollowStatus":1,"bizCode":"cn_retail_jdsupermarket","scenario":"sign","babelChannel":"ttt1","isJdApp":"1","isWx":"0"}`,
|
||||
user,
|
||||
algo: {
|
||||
appId: 'b8fc7'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(sign, 'success')) {
|
||||
p.log(`签到成功`)
|
||||
for (let i of sign.data.rewards) {
|
||||
p.log(`获得: ${i.rewardDesc}`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(sign, 'message') || sign)
|
||||
}
|
||||
}
|
||||
var data = {}
|
||||
if (this.haskey(react, 'activityData.floorList')) {
|
||||
data = react.activityData
|
||||
}
|
||||
for (let ii in data) {
|
||||
if (ii == 'floorList') {
|
||||
for (let jj of data[ii]) {
|
||||
if (jj.providerData && this.haskey(jj, 'providerData.data.floorData.name') == '汪贝任务楼层') {
|
||||
let floor = jj.providerData.data.floorData
|
||||
for (let i of floor.items) {
|
||||
// let ts = new Date().getTime().toString()
|
||||
// let token = this.md5(ts + "5YT%aC89$22OI@pQ")
|
||||
// let uuid = this.md5(user)
|
||||
if (i.completionFlag) {
|
||||
p.log(`任务已经完成: ${i.assignmentName}`)
|
||||
}
|
||||
else {
|
||||
p.log(`正在运行: ${i.assignmentName}`)
|
||||
let extraType = i.ext.extraType
|
||||
if (i.assignmentName.includes('邀请')) {
|
||||
if (this.haskey(i, 'ext.assistTaskDetail.itemId')) {
|
||||
}
|
||||
}
|
||||
else if (this.haskey(i, `ext.${i.ext.extraType}`)) {
|
||||
let extra = i.ext[extraType]
|
||||
try {
|
||||
for (let j of extra.slice(0, i.assignmentTimesLimit)) {
|
||||
if (['shoppingActivity', 'productsInfo', 'browseShop'].includes(extraType)) {
|
||||
let d = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action`,
|
||||
'form': `appid=jd-super-market&body=${this.dumps(
|
||||
{
|
||||
"bizCode": "cn_retail_jdsupermarket",
|
||||
"scenario": "sign",
|
||||
"assignmentType": i.assignmentType,
|
||||
"encryptAssignmentId": i.encryptAssignmentId,
|
||||
"itemId": j.itemId || j.advId,
|
||||
"actionType": 1,
|
||||
"babelChannel": "ttt1",
|
||||
"isJdApp": "0",
|
||||
"isWx": "0"
|
||||
}
|
||||
)}&sign=11&t=1653132222710&client=m&functionId=atop_channel_complete_task`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '51113'
|
||||
},
|
||||
// ciphers: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384'
|
||||
}
|
||||
)
|
||||
p.log(this.haskey(d, 'data.msg') || this.haskey(d, 'message'))
|
||||
await this.wait((i.ext.waitDuration || 0) * 1000 + 500)
|
||||
}
|
||||
let s = await this.curl({
|
||||
'url': `https://api.m.jd.com/client.action`,
|
||||
'form': `appid=jd-super-market&body=${this.dumps(
|
||||
{
|
||||
"bizCode": "cn_retail_jdsupermarket",
|
||||
"scenario": "sign",
|
||||
"assignmentType": i.assignmentType,
|
||||
"encryptAssignmentId": i.encryptAssignmentId,
|
||||
"itemId": j.itemId || j.advId,
|
||||
"babelChannel": "ttt1",
|
||||
"isJdApp": "0",
|
||||
"isWx": "0"
|
||||
}
|
||||
)}&sign=11&t=1653132222710&client=m&functionId=atop_channel_complete_task`,
|
||||
user, algo: {
|
||||
appId: '51113'
|
||||
},
|
||||
// ciphers: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384'
|
||||
}
|
||||
)
|
||||
p.log(i.assignmentName, this.haskey(s, 'data.msg') || this.haskey(s, 'message'))
|
||||
if (this.haskey(s, 'message', '风险等级未通过')) {
|
||||
return
|
||||
}
|
||||
if (this.haskey(s, 'message', '活动太火爆了')) {
|
||||
break
|
||||
}
|
||||
if (this.haskey(s, 'data.doTaskRewardsInfo.successRewards')) {
|
||||
for (let kkk in s.data.doTaskRewardsInfo.successRewards) {
|
||||
for (let kkkk of s.data.doTaskRewardsInfo.successRewards[kkk]) {
|
||||
p.log(`获得:`, kkkk.quantity, kkkk.rewardName)
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
} catch (e) {
|
||||
p.log(e)
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getBody(params) {
|
||||
let str = "",
|
||||
map = Object.keys(params).sort(function(d, k) {
|
||||
return d.localeCompare(k);
|
||||
});
|
||||
for (let __i of map) {
|
||||
str = str.concat(params[__i]);
|
||||
}
|
||||
let t = Date.now();
|
||||
let r = "".concat("c4491f13dce9c71f").concat(str).concat(t);
|
||||
let md5 = this.md5(r)
|
||||
params.timestamp = t;
|
||||
params.sign = md5;
|
||||
params.signKey = "c4491f13dce9c71f";
|
||||
return this.dumps(params);
|
||||
}
|
||||
}
|
||||
|
||||
213
parse/jd/jd_task_united.js
Normal file
213
parse/jd/jd_task_united.js
Normal file
@ -0,0 +1,213 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东大牌集合任务',
|
||||
public: 'isv',
|
||||
sync: 1,
|
||||
prompt: {
|
||||
actId: '活动Id1|Id2',
|
||||
},
|
||||
verify: 1,
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
await this.field('actId')
|
||||
}
|
||||
|
||||
async batch1(p) {
|
||||
let a = await this.curl({
|
||||
'url': `https://jinggengjcq-isv.isvjcloud.com/dm/front/jdJoinCardtf/shop/shopProduct?open_id=&mix_nick=BZwJHR&push_way=1&user_id=10299171`,
|
||||
json: {
|
||||
"jsonRpc": "2.0",
|
||||
"params": {
|
||||
"commonParameter": {
|
||||
"m": "POST",
|
||||
"oba": "6e5e793ff0ce0ac6293e2ee26f88dac6",
|
||||
"timestamp": 1713947376182,
|
||||
"userId": 10299171
|
||||
},
|
||||
"admJson": {
|
||||
"actId": p.actId,
|
||||
"method": "/jdJoinCardtf/shop/shopProduct",
|
||||
"userId": 10299171,
|
||||
"pushWay": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
let skuList = []
|
||||
if (this.haskey(a, 'data.data.0.numId')) {
|
||||
skuList = this.column(a.data.data, 'numId')
|
||||
}
|
||||
if (skuList) {
|
||||
p.skuList = skuList
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let isv = await p.getPublic('isv')
|
||||
if (isv) {
|
||||
for (let i of Array(2)) {
|
||||
var load = await this.curl({
|
||||
'url': `https://jinggengjcq-isv.isvjcloud.com/dm/front/jdJoinCardtf/activity/load?open_id=&mix_nick=&push_way=1&user_id=10299171`,
|
||||
'json': {
|
||||
"jsonRpc": "2.0",
|
||||
"params": {
|
||||
"commonParameter": {
|
||||
"oba": "259f36a73a857cfa37a7096fedb8bd60",
|
||||
"m": "POST",
|
||||
"timestamp": this.timestamp,
|
||||
"userId": 10299171,
|
||||
},
|
||||
"admJson": {
|
||||
"actId": p.context.actId,
|
||||
"userId": 10299171,
|
||||
"jdToken": isv,
|
||||
"source": "01",
|
||||
"method": "/openCardNew/activity_load",
|
||||
"buyerNick": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
if (this.haskey(load, 'data.data.missionCustomer.buyerNick')) {
|
||||
break
|
||||
}
|
||||
await this.wait(3000)
|
||||
}
|
||||
if (this.haskey(load, 'errorMessage', '获取京东用户信息失败~')) {
|
||||
p.log('获取京东用户信息失败~')
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.err('没有获取到isvToken')
|
||||
}
|
||||
let buyerNick = this.haskey(load, 'data.data.missionCustomer.buyerNick')
|
||||
if (buyerNick) {
|
||||
let missionCustome = load.data.data.missionCustomer
|
||||
let bean = 0
|
||||
let shopList = await this.curl({
|
||||
'url': `https://jinggengjcq-isv.isvjcloud.com/dm/front/jdJoinCardtf/shop/shopList?open_id=&mix_nick=${buyerNick}&push_way=1&user_id=10299171`,
|
||||
json: {
|
||||
"jsonRpc": "2.0",
|
||||
"params": {
|
||||
"commonParameter": {
|
||||
"m": "POST",
|
||||
"oba": "e4aae386ea7d1a32f77771570eea39cd",
|
||||
"timestamp": this.timestamp,
|
||||
"userId": 10299171
|
||||
},
|
||||
"admJson": {
|
||||
"method": "/jdJoinCardtf/shop/shopList",
|
||||
"userId": 10299171,
|
||||
"actId": p.context.actId,
|
||||
buyerNick,
|
||||
"pushWay": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
for (let i of this.haskey(shopList, 'data.data')) {
|
||||
let goodsNumId = i.shopId
|
||||
p.log("正在浏览:", i.shopTitle)
|
||||
let s = await this.curl({
|
||||
'url': `https://jinggengjcq-isv.isvjcloud.com/dm/front/jdJoinCardtf/mission/completeMission?open_id=&mix_nick=${buyerNick}&push_way=1&user_id=10299171`,
|
||||
json: {
|
||||
"jsonRpc": "2.0",
|
||||
"params": {
|
||||
"commonParameter": {
|
||||
"m": "POST",
|
||||
"oba": "259f36a73a857cfa37a7096fedb8bd60",
|
||||
"timestamp": new Date().getTime(),
|
||||
"userId": 10299171
|
||||
},
|
||||
"admJson": {
|
||||
"missionType": "viewShop",
|
||||
"goodsNumId": goodsNumId,
|
||||
"method": "/jdJoinCardtf/mission/completeMission",
|
||||
"userId": 10299171,
|
||||
"actId": p.context.actId,
|
||||
buyerNick,
|
||||
"pushWay": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
// console.log(this.dumps(s))
|
||||
let remark = this.haskey(s, 'data.data.remark') || ''
|
||||
p.log(remark)
|
||||
if (this.haskey(s, 'data.data.sendStatus') == false) {
|
||||
break
|
||||
}
|
||||
if (this.haskey(s, 'data.data.sendStatus')) {
|
||||
let num = this.match(/(\d+)个京豆/, remark)
|
||||
bean += parseInt(num)
|
||||
}
|
||||
else {
|
||||
if (this.dumps(s).includes("上限")) {
|
||||
break
|
||||
}
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
for (let _ of ['uniteAddCart', 'uniteCollectShop']) {
|
||||
if (_ == 'uniteAddCart' && missionCustome.hasAddCart) {
|
||||
continue
|
||||
}
|
||||
else if (_ == 'uniteCollectShop' && missionCustome.hasCollectShop) {
|
||||
continue
|
||||
}
|
||||
let collectShop = await this.curl({
|
||||
'url': `https://jinggengjcq-isv.isvjcloud.com/dm/front/jdJoinCardtf/mission/completeMission?open_id=&mix_nick=${buyerNick}&push_way=1&user_id=10299171`,
|
||||
json: {
|
||||
"jsonRpc": "2.0",
|
||||
"params": {
|
||||
"commonParameter": {
|
||||
"m": "POST",
|
||||
"oba": "b67770414453c05a26e57cde6ae600ab",
|
||||
"timestamp": new Date().getTime(),
|
||||
"userId": 10299171
|
||||
},
|
||||
"admJson": {
|
||||
"actId": p.context.actId,
|
||||
"missionType": _,
|
||||
"method": "/jdJoinCardtf/mission/completeMission",
|
||||
"userId": 10299171,
|
||||
buyerNick,
|
||||
"pushWay": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
let remark = this.haskey(collectShop, 'data.data.remark') || ''
|
||||
p.log(remark)
|
||||
if (this.haskey(collectShop, 'data.data.sendStatus')) {
|
||||
let num = this.match(/(\d+)个京豆/, remark)
|
||||
bean += parseInt(num)
|
||||
}
|
||||
await this.wait(1000)
|
||||
}
|
||||
if (bean>0) {
|
||||
p.msg(`获得京豆: ${bean}`)
|
||||
}
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.err("没有获取到buyerNickr")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
parse/jd/jd_task_user.js
Normal file
57
parse/jd/jd_task_user.js
Normal file
@ -0,0 +1,57 @@
|
||||
import {Template} from '../../template.js'
|
||||
import fs from 'fs'
|
||||
import ini from "ini"
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: "京东用户信息获取",
|
||||
userData: true,
|
||||
prompt: {
|
||||
fileFormat: "js #默认保存为ini文件"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user
|
||||
let s = await this.curl({
|
||||
'url': `https://kai.jd.com/client?appId=applet_jpass&body=%257B%257D&functionId=UserExportService.getUserInfo&requestId=0.72076678870461081641259143802&sign=431fa578b3a6c82c50b37ed7e6406973&_s=2&_i=55`,
|
||||
user,
|
||||
algo: {
|
||||
expire: {
|
||||
'data.code': '403'
|
||||
}
|
||||
}
|
||||
})
|
||||
if (this.haskey(s, 'data.data')) {
|
||||
p.log("数据获取成功...")
|
||||
// 当天已经获取到数据了,跳过重复获取
|
||||
p.info.work = true
|
||||
}
|
||||
else {
|
||||
p.err("数据获取失败...")
|
||||
return
|
||||
}
|
||||
let {pin, mobile, userName} = s.data.data
|
||||
let obj = {...(this.userData[user] || {}), ...{pin, mobile, userName}}
|
||||
this.userData[user] = obj
|
||||
}
|
||||
|
||||
async done() {
|
||||
if (this.userData) {
|
||||
// console.log(this.userData)
|
||||
if (this.profile.fileFormat === 'js') {
|
||||
let text = `export default ${JSON.stringify(this.userData, null, 4)}`
|
||||
await fs.writeFileSync(`${this.iniPath}/jdUser.js`, text)
|
||||
this.msg("写入jdUser.js")
|
||||
}
|
||||
else {
|
||||
let text = ini.stringify(this.userData)
|
||||
await fs.writeFileSync(`${this.iniPath}/jdUser.ini`, text)
|
||||
this.msg("写入jdUser.ini")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
278
qlCreate.js
Normal file
278
qlCreate.js
Normal file
@ -0,0 +1,278 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import ini from 'ini'
|
||||
import axios from "axios";
|
||||
|
||||
class Ql {
|
||||
constructor() {
|
||||
const dirpath = fileURLToPath(import.meta.url);
|
||||
const abspath = path.dirname(dirpath)
|
||||
let iniText = fs.readFileSync(`${abspath}/config/config.ini`, 'UTF-8')
|
||||
let obj = ini.parse(iniText)
|
||||
let env = obj.env
|
||||
this.config = {
|
||||
baseURL: env.QINGLONG_BaseUrl || 'http://127.0.0.1:5700',
|
||||
clientId: env.QINGLONG_ClientId,
|
||||
clientSecret: env.QINGLONG_ClientSecret
|
||||
};
|
||||
this.token = null
|
||||
}
|
||||
|
||||
// 获取 token
|
||||
async getToken() {
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/auth/token`, {
|
||||
params: {
|
||||
client_id: this.config.clientId,
|
||||
client_secret: this.config.clientSecret
|
||||
}
|
||||
});
|
||||
this.token = response.data.data.token;
|
||||
return this.token;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong token失败', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async setEnvs(data) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.put(
|
||||
`${this.config.baseURL}/open/envs`,
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 更新环境变量失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取环境变量
|
||||
async getEnvs(search = null) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/envs?searchValue=${search}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong环境变量失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加环境变量
|
||||
async addEnv(name, value, remarks = '') {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.post(`${this.config.baseURL}/open/envs`, [{
|
||||
name,
|
||||
value,
|
||||
remarks
|
||||
}], {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 添加qinglong环境变量失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除环境变量
|
||||
async deleteEnv(envId) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.delete(`${this.config.baseURL}/open/envs`, {
|
||||
data: [envId],
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 删除qinglong环境变量失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取定时任务列表
|
||||
async getCrons() {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/crons`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong定时任务失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 运行任务
|
||||
async runCrons(cronIds) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.put(`${this.config.baseURL}/open/crons/run`, cronIds, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 运行qinglong任务失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取任务日志
|
||||
async getCronLogs(cronId) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/crons/${cronId}/log`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('获取任务日志失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async addCron(command) {
|
||||
const token = this.token
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${this.config.baseURL}/open/crons`,
|
||||
command,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 创建定时任务失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async wait(t) {
|
||||
return new Promise(e => setTimeout(e, t))
|
||||
}
|
||||
|
||||
async create() {
|
||||
await this.getToken()
|
||||
let dirpath = fileURLToPath(import.meta.url);
|
||||
let abspath = path.dirname(dirpath)
|
||||
let crons = await this.getCrons()
|
||||
let data = {}
|
||||
for (let i of crons.data) {
|
||||
let command = i.command.match(/task\s*qitoqito_psyduck\/(\w+\.js)/)
|
||||
if (command) {
|
||||
let script = command[1]
|
||||
data[script] = {
|
||||
name: i.name,
|
||||
schedule: i.schedule,
|
||||
id: i.id,
|
||||
command: i.command
|
||||
}
|
||||
}
|
||||
}
|
||||
let dicts = {}
|
||||
let dir = fs.readdirSync(`${abspath}/parse`);
|
||||
dir.forEach(async function(item, index) {
|
||||
let stat = fs.lstatSync(`${abspath}/parse/` + item)
|
||||
if (stat.isDirectory() === true) {
|
||||
for (let script of fs.readdirSync(`${abspath}/parse/${item}`)) {
|
||||
try {
|
||||
if (script.match(/\w+\_\w+\_\w/)) {
|
||||
let imp = await import(`${abspath}/parse/${item}/${script}`)
|
||||
let psyDuck = new imp.Main()
|
||||
let crontab = psyDuck.crontab()
|
||||
let code = `
|
||||
import path from 'path';
|
||||
import {
|
||||
fileURLToPath
|
||||
} from 'url';
|
||||
!(async () => {
|
||||
let dirpath = fileURLToPath(import.meta.url).replace('.swap','');
|
||||
let abspath = path.dirname(dirpath)
|
||||
let filename = dirpath.match(/(\\w+)\\.js/)[1]
|
||||
let type = filename.split('_')[0]
|
||||
if (['js', 'jx', 'jr', 'jw'].includes(type)) {
|
||||
type = 'jd'
|
||||
}
|
||||
let length = process.argv.length
|
||||
let params = {
|
||||
filename
|
||||
}
|
||||
if (length > 2) {
|
||||
for (let i = 2; i < length; i++) {
|
||||
let key = process.argv[i].match(/^-\\w+$/)
|
||||
if (key) {
|
||||
params[key[0].substr(1)] = process.argv[i + 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
let psyDuck = await import (\`\${abspath}/parse/\${type}/\${filename}.js\`)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
})().catch((e) => {
|
||||
console.log(e.message)
|
||||
})`
|
||||
fs.writeFile(`${abspath}/${script}`, code, function(err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(`🐯❄️ 写入成功: ${script}`)
|
||||
})
|
||||
if (!data[script]) {
|
||||
dicts[script] = {
|
||||
name: `PsyDuck_${psyDuck.profile.title}`,
|
||||
schedule: crontab,
|
||||
command: `task qitoqito_psyduck/${script}`,
|
||||
labels: [`PsyDuck`]
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`🐽🐽️ 写入失败: ${script}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
await this.wait(20000)
|
||||
let commands = Object.values(dicts)
|
||||
for (let i in dicts) {
|
||||
try {
|
||||
let add = await this.addCron(dicts[i])
|
||||
if (add.data.name) {
|
||||
console.log('任务添加成功: ', i)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('任务添加失败: ', i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let qinglong = new Ql()
|
||||
qinglong.create()
|
||||
1
template.js
Normal file
1
template.js
Normal file
File diff suppressed because one or more lines are too long
110
util/cache.js
Normal file
110
util/cache.js
Normal file
@ -0,0 +1,110 @@
|
||||
import redis from 'redis'
|
||||
import Tfc from 'ttl-file-cache'
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
export class Cache {
|
||||
#db
|
||||
|
||||
constructor(p = {}) {
|
||||
this._db = p.db
|
||||
this._type = p.db.type || 'redis'
|
||||
this._category = p.category || 'config'
|
||||
}
|
||||
|
||||
async connect() {
|
||||
if (this._type == 'redis') {
|
||||
// var redis = require('redis');
|
||||
this._cache = await redis.createClient({
|
||||
url: `redis://:${this._db.password || ''}@${this._db.host || '127.0.0.1'}:${this._db.prot || 6379}/${this._db.db}`
|
||||
})
|
||||
await this._cache.connect();
|
||||
}
|
||||
else {
|
||||
let dirpath = fileURLToPath(import.meta.url).split('/util')[0];
|
||||
this._cache = new Tfc({dir: `${dirpath}/temp`})
|
||||
}
|
||||
}
|
||||
|
||||
async close() {
|
||||
if (this._type == 'redis') {
|
||||
await this._cache.quit()
|
||||
}
|
||||
}
|
||||
|
||||
async get(key, index = '') {
|
||||
try {
|
||||
var data = null
|
||||
if (this._type == 'redis') {
|
||||
let _type = await this._cache.type(key)
|
||||
if (_type == 'hash') {
|
||||
data = await this._cache.hGetAll(key)
|
||||
if (index) {
|
||||
data = data[index]
|
||||
}
|
||||
}
|
||||
else {
|
||||
data = await this._cache.get(key)
|
||||
}
|
||||
}
|
||||
else {
|
||||
let dd = await this._cache.get(key)
|
||||
if (dd) {
|
||||
data = dd.toString()
|
||||
if (index) {
|
||||
let dd = JSON.parse(data)
|
||||
data = dd[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
return data
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async set(a, b, c = null, d = null) {
|
||||
d = d || {expire: null, padding: null}
|
||||
let {expire, padding} = d
|
||||
expire = expire || 0
|
||||
if (this._type == 'redis') {
|
||||
if (!c) {
|
||||
if (typeof b == 'object') {
|
||||
if (padding) {
|
||||
this._cache.del(a)
|
||||
}
|
||||
for (let i in b) {
|
||||
this._cache.HSET(a, i, b[i])
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._cache.set(a, b)
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._cache.HSET(a, b, c)
|
||||
}
|
||||
if (typeof expire && expire) {
|
||||
this._cache.expire(a, expire)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!c) {
|
||||
this._cache.set(a, b, expire)
|
||||
}
|
||||
else {
|
||||
let d = await this.get(a)
|
||||
if (d) {
|
||||
var data = JSON.parse(d)
|
||||
}
|
||||
else {
|
||||
var data = {}
|
||||
}
|
||||
data[b] = c
|
||||
this._cache.set(a, data, expire)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// export default Cache;
|
||||
1
util/common.js
Normal file
1
util/common.js
Normal file
File diff suppressed because one or more lines are too long
1
util/jdAlgo.js
Normal file
1
util/jdAlgo.js
Normal file
File diff suppressed because one or more lines are too long
323
util/message.js
Normal file
323
util/message.js
Normal file
@ -0,0 +1,323 @@
|
||||
import CryptoJS from 'crypto-js'
|
||||
|
||||
export class Message {
|
||||
constructor(message) {
|
||||
this.func = process.psyDuck
|
||||
this.msg = this.func.message
|
||||
this.title = `🐽 消息提醒: ${this.func.profile.title}`
|
||||
message.push([`PsyDuck [https://github.com/qitoqito/psyduck]`])
|
||||
this.message = message.map(d => d.join("\n"))
|
||||
}
|
||||
|
||||
async send(msgAry) {
|
||||
if (this.msg.hasOwnProperty('TELEGRAM_TOKEN')) {
|
||||
await this.tgNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('BARK_TOKEN')) {
|
||||
await this.barkNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('PUSHPLUS_TOKEN')) {
|
||||
await this.ppNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('FTQQ_TOKEN')) {
|
||||
await this.ftqqNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('DINGTALK_TOKEN')) {
|
||||
await this.ddNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('IGOT_TOKEN')) {
|
||||
await this.igotNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('WEIXIN_TOKEN')) {
|
||||
await this.wechatNotify()
|
||||
}
|
||||
if (this.msg.hasOwnProperty('WXAM_TOKEN')) {
|
||||
await this.wxamNotify()
|
||||
}
|
||||
}
|
||||
|
||||
async wxamNotify() {
|
||||
let message = this.message.join("\n\n")
|
||||
|
||||
function ChangeUserId(am, desp) {
|
||||
const QYWXAM_TOKEN_AY = am.split(',');
|
||||
if (QYWXAM_TOKEN_AY[2]) {
|
||||
const userIdTmp = QYWXAM_TOKEN_AY[2].split("|");
|
||||
let userId = "";
|
||||
for (let i = 0; i<userIdTmp.length; i++) {
|
||||
const count = "账号" + (i + 1);
|
||||
const count2 = "签到号 " + (i + 1);
|
||||
if (desp.match(count2)) {
|
||||
userId = userIdTmp[i];
|
||||
}
|
||||
}
|
||||
if (!userId) userId = QYWXAM_TOKEN_AY[2];
|
||||
return userId;
|
||||
}
|
||||
else {
|
||||
return "@all";
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let am = this.msg['WXAM_TOKEN'].split(",")
|
||||
let s = await this.func.curl({
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
||||
json: {
|
||||
corpid: `${am[0]}`,
|
||||
corpsecret: `${am[1]}`,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
)
|
||||
let token = s.access_token
|
||||
let options;
|
||||
let html = message.replace(/\n/g, "<br/>")
|
||||
if (am.length>4) {
|
||||
switch (am[4]) {
|
||||
case '0':
|
||||
options = {
|
||||
msgtype: 'textcard',
|
||||
textcard: {
|
||||
title: `${this.title}`,
|
||||
description: `${message}`,
|
||||
url: 'https://github.com/qitoqito/kedaya',
|
||||
btntxt: '更多'
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
options = {
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: `${this.title}\n\n${message}`
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
options = {
|
||||
msgtype: 'mpnews',
|
||||
mpnews: {
|
||||
articles: [{
|
||||
title: `${this.title}`,
|
||||
thumb_media_id: `${am[4]}`,
|
||||
author: `智能助手`,
|
||||
content_source_url: ``,
|
||||
content: `${html}`,
|
||||
digest: `${message}`
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
options = {
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: `${this.title}\n\n${message}`
|
||||
}
|
||||
}
|
||||
}
|
||||
let data = await this.func.curl({
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${token}`,
|
||||
json: {
|
||||
touser: `${ChangeUserId(this.msg['WXAM_TOKEN'], message)}`,
|
||||
agentid: `${am[3]}`,
|
||||
safe: '0',
|
||||
...options
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
)
|
||||
if (data.errcode === 0) {
|
||||
console.log('[Message] 成员ID:' + ChangeUserId(this.msg['WXAM_TOKEN'], message) + '企业微信应用消息发送通知消息成功🎉');
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] 企业微信应用消息发送通知消息失败: ${data.errmsg}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Message] 成员ID:' + ChangeUserId(this.msg['WXAM_TOKEN'], message) + '企业微信应用消息发送通知消息失败');
|
||||
}
|
||||
}
|
||||
|
||||
async wechatNotify() {
|
||||
try {
|
||||
let data = await this.func.curl({
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${this.msg['WEIXIN_TOKEN']}`,
|
||||
json: {
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: ` ${this.title}\n\n${this.message.join("\n\n")}`,
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
)
|
||||
if (data.errcode === 0) {
|
||||
console.log('[Message] 企业微信发送通知消息成功🎉');
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] 企业微信发送通知消息失败: ${data.errmsg}`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Message] 企业微信发送通知消息失败")
|
||||
}
|
||||
}
|
||||
|
||||
async igotNotify() {
|
||||
try {
|
||||
let data = await this.func.curl({
|
||||
'url': `https://push.hellyw.com/${this.func['IGOT_TOKEN']}`,
|
||||
'form': `title=${encodeURIComponent(this.title)}&content=${encodeURIComponent(this.message.join("\n\n"))}`,
|
||||
}
|
||||
)
|
||||
if (data.ret === 0) {
|
||||
console.log('[Message] iGot发送通知消息成功🎉')
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] iGot发送通知消息失败:${data.errMsg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`[Message] iGot发送通知消息失败`)
|
||||
}
|
||||
}
|
||||
|
||||
async ftqqNotify() {
|
||||
try {
|
||||
let url = this.msg['FTQQ_TOKEN'].includes('SCT') ? `https://sctapi.ftqq.com/${this.msg['FTQQ_TOKEN']}.send` : `https://sc.ftqq.com/${this.msg['FTQQ_TOKEN']}.send`
|
||||
let s = await this.func.curl({
|
||||
url,
|
||||
'form': `text=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.message.join("\n\n").replace(/[\n\r]/g, '\n\n'))}`,
|
||||
'headers': {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
}
|
||||
) || {}
|
||||
if (s.errno === 0 || s.data.errno === 0) {
|
||||
console.log('[Message] Server酱发送通知消息成功🎉')
|
||||
}
|
||||
else if (s.errno === 1024) {
|
||||
// 一分钟内发送相同的内容会触发
|
||||
console.log(`[Message] Server酱发送通知消息异常: ${s.errmsg}`)
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] Server酱发送通知消息异常: ${JSON.stringify(s)}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Message] Server酱发送通知消息失败")
|
||||
}
|
||||
}
|
||||
|
||||
async ppNotify() {
|
||||
let body = {
|
||||
token: this.msg['PUSHPLUS_TOKEN'],
|
||||
title: this.title,
|
||||
content: this.message.join("\n\n"),
|
||||
topic: this.msg['PUSHPLUS_TOPIC']
|
||||
};
|
||||
try {
|
||||
let p = {
|
||||
'url': `http://www.pushplus.plus/send`,
|
||||
'json': body
|
||||
} || {}
|
||||
let s = await this.func.curl(p)
|
||||
if (s.code == 200) {
|
||||
console.log(`[Message] push+发送${this['PUSHPLUS_TOPIC'] ? '一对多' : '一对一'}通知消息完成🎉`)
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] push+发送${this['PUSHPLUS_TOPIC'] ? '一对多' : '一对一'}通知消息失败:${s.msg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Message] Push+发送消息失败")
|
||||
}
|
||||
}
|
||||
|
||||
async ddNotify() {
|
||||
try {
|
||||
let url;
|
||||
if (this.msg['DINGTALK_SECRET']) {
|
||||
let dateNow = Date.now();
|
||||
let text = `${dateNow}\n${this.msg['DINGTALK_SECRET']}`
|
||||
var hash = CryptoJS.HmacSHA256(text, this.msg['DINGTALK_SECRET']);
|
||||
var sign = CryptoJS.enc.Base64.stringify(hash);
|
||||
url = `https://oapi.dingtalk.com/robot/send?access_token=${this.msg['DINGTALK_TOKEN']}×tamp=${dateNow}&sign=${sign}`
|
||||
}
|
||||
else {
|
||||
url = `https://oapi.dingtalk.com/robot/send?access_token=${this.msg['DINGTALK_TOKEN']}`
|
||||
}
|
||||
let s = await this.func.curl({
|
||||
url,
|
||||
json: {
|
||||
"msgtype": "text",
|
||||
"text": {
|
||||
"content": ` ${this.title}\n\n${this.message.join("\n\n")}`
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
) || {}
|
||||
if (this.func.haskey(s, 'errcode', 0)) {
|
||||
console.log('[Message] 钉钉发送通知消息成功🎉')
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] 钉钉发送通知消息失败: ${s.errmsg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Message] 钉钉发送通知消息失败")
|
||||
}
|
||||
}
|
||||
|
||||
async barkNotify() {
|
||||
let url = this.msg['BARK_URL'] || 'https://api.day.app'
|
||||
url += `/${this.msg['BARK_TOKEN']}`
|
||||
let p = {
|
||||
url,
|
||||
'form': `title=${encodeURIComponent(this.title)}&body=${encodeURIComponent(this.message.join("\n\n"))}&sound=${this.msg['BARK_SOUND']}&group=${this.msg['BARK_GROUP']}`,
|
||||
}
|
||||
try {
|
||||
let s = await this.func.curl(p) || {}
|
||||
if (s.code == 200) {
|
||||
console.log('[Message] Bark APP发送通知消息成功🎉')
|
||||
}
|
||||
else {
|
||||
console.log(`[Message] Bark APP发送通知消息失败`)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("[Message] Bark发送通知消息失败")
|
||||
}
|
||||
}
|
||||
|
||||
async tgNotify() {
|
||||
let url = this.msg['TELEGRAM_URL'] || 'https://api.telegram.org'
|
||||
url += `/bot${this.msg['TELEGRAM_TOKEN']}/sendMessage`
|
||||
let p = {
|
||||
url,
|
||||
form: `chat_id=${this.msg['TELEGRAM_ID']}&text=${this.title}\n\n${this.message.join("\n\n")}&disable_web_page_preview=true`,
|
||||
}
|
||||
if (this.msg['TELEGRAM_PROXY']) {
|
||||
p.proxy = this.msg['TELEGRAM_PROXY']
|
||||
}
|
||||
try {
|
||||
let s = await this.func.curl(p)
|
||||
if (s.ok) {
|
||||
console.log('[Message] Telegram发送通知消息成功🎉')
|
||||
}
|
||||
else if (s.error_code === 400) {
|
||||
console.log('[Message] 请主动给bot发送一条消息并检查接收用户ID是否正确')
|
||||
}
|
||||
else if (s.error_code === 401) {
|
||||
console.log('[Message] Telegram bot token 填写错误')
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Message] Telegram 发送通知消息失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
242
util/panel.js
Normal file
242
util/panel.js
Normal file
@ -0,0 +1,242 @@
|
||||
import axios from 'axios'
|
||||
import ini from 'ini'
|
||||
import fs from 'fs'
|
||||
|
||||
export class Panel {
|
||||
constructor(dict = {}) {
|
||||
this.dict = dict
|
||||
this.env = process.psyDuck.env
|
||||
this.type = process.psyDuck.type
|
||||
this.func = process.psyDuck
|
||||
this.config = {
|
||||
baseURL: this.env.QINGLONG_BaseUrl || 'http://127.0.0.1:5700',
|
||||
clientId: this.env.QINGLONG_ClientId,
|
||||
clientSecret: this.env.QINGLONG_ClientSecret
|
||||
};
|
||||
this.token = null;
|
||||
}
|
||||
|
||||
async send() {
|
||||
switch (this.env.panel) {
|
||||
case 'qinglong':
|
||||
await this._qlTask()
|
||||
break;
|
||||
case 'ini':
|
||||
await this._iniTask()
|
||||
break
|
||||
default:
|
||||
await this._jsTask()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
async _qlTask() {
|
||||
let envs = await this.getEnvs(`${this.type}_cookie`.toUpperCase())
|
||||
// let pins = []
|
||||
if (envs.length) {
|
||||
// console.log(envs)
|
||||
for (let i of envs) {
|
||||
let pin = this.func.userName(i.value)
|
||||
if (this.dict[pin]) {
|
||||
i.value = this.dict[pin]
|
||||
let ary = ['_id', 'id', 'name', 'value']
|
||||
let d = ary.reduce((v, k) => {
|
||||
if (i[k]) {
|
||||
v[k] = i[k]
|
||||
}
|
||||
return v
|
||||
}, {})
|
||||
let data = await this.setEnvs(d)
|
||||
if (data.code == 200) {
|
||||
this.func.msg(`更新: ${pin} 成功`)
|
||||
}
|
||||
else {
|
||||
this.func.msg(`更新: ${pin} 失败`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _iniTask() {
|
||||
let dict = {}
|
||||
for (let i in this.func.cookies) {
|
||||
if (!['test', 'all', 'local'].includes(i)) {
|
||||
dict[i] = this.func.cookies[i]
|
||||
}
|
||||
}
|
||||
for (let i in dict) {
|
||||
for (let j in dict[i]) {
|
||||
let pin = this.func.userName(dict[i][j])
|
||||
if (this.dict[pin]) {
|
||||
dict[i][j] = this.dict[pin]
|
||||
}
|
||||
}
|
||||
}
|
||||
let text = []
|
||||
for (let i in dict) {
|
||||
text.push(`[${i}]`)
|
||||
for (let j of dict[i]) {
|
||||
text.push(j)
|
||||
}
|
||||
}
|
||||
await fs.writeFileSync(`${this.func.abspath}/cookie/${this.type}.ini`, text.join("\n"))
|
||||
this.func.msg(`${this.type}.ini 更新成功`)
|
||||
}
|
||||
|
||||
async _jsTask() {
|
||||
let dict = {}
|
||||
for (let i in this.func.cookies) {
|
||||
if (!['test', 'all', 'local'].includes(i)) {
|
||||
dict[i] = this.func.cookies[i]
|
||||
}
|
||||
}
|
||||
for (let i in dict) {
|
||||
for (let j in dict[i]) {
|
||||
let pin = this.func.userName(dict[i][j])
|
||||
if (this.dict[pin]) {
|
||||
dict[i][j] = this.dict[pin]
|
||||
}
|
||||
}
|
||||
}
|
||||
let text = `export default ${JSON.stringify(dict, null, 4)}`
|
||||
await fs.writeFileSync(`${this.func.abspath}/cookie/${this.type}.js`, text)
|
||||
this.func.msg(`${this.type}.js 更新成功`)
|
||||
}
|
||||
|
||||
// 获取 token
|
||||
async getToken() {
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/auth/token`, {
|
||||
params: {
|
||||
client_id: this.config.clientId,
|
||||
client_secret: this.config.clientSecret
|
||||
}
|
||||
});
|
||||
this.token = response.data.data.token;
|
||||
return this.token;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong token失败', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async setEnvs(data) {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.put(
|
||||
`${this.config.baseURL}/open/envs`,
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 更新环境变量失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取环境变量
|
||||
async getEnvs(search = null) {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/envs?searchValue=${search}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong环境变量失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加环境变量
|
||||
async addEnv(name, value, remarks = '') {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.post(`${this.config.baseURL}/open/envs`, [{
|
||||
name,
|
||||
value,
|
||||
remarks
|
||||
}], {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 添加qinglong环境变量失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除环境变量
|
||||
async deleteEnv(envId) {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.delete(`${this.config.baseURL}/open/envs`, {
|
||||
data: [envId],
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 删除qinglong环境变量失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取定时任务列表
|
||||
async getCrons() {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/crons`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 获取qinglong定时任务失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 运行任务
|
||||
async runCrons(cronIds) {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.put(`${this.config.baseURL}/open/crons/run`, cronIds, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('[Error] 运行qinglong任务失败');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取任务日志
|
||||
async getCronLogs(cronId) {
|
||||
const token = await this.getToken();
|
||||
try {
|
||||
const response = await axios.get(`${this.config.baseURL}/open/crons/${cronId}/log`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
console.error('获取任务日志失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user