-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkhz.js
188 lines (156 loc) · 4.12 KB
/
khz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
* 脚本地址: ql raw https://js.dayplus.xyz/https://raw.githubusercontent.com/hualuoyixiao/qinglong/master/khz.js
* 垦荒者
* 下载地址: http://ken.kenhz.cn/?id=27310807
*
* cron 15 8 * * *
* ========= 抓包 =========
* 抓取域名:http://ken.kenhz.cn
* 请求头:Authorization的值
* ========= 青龙 =========
* 变量名: khzToken
* 变量值:Bearer eyJhbGciOiJIUzUxMiJ9.eyJsxxx........
* 多个账号用 @分割
*
*/
const axios = require('axios');
const QS = require('qs');
// 开始执行
console.log("🔔垦荒者V1.0, 开始运行! By:花落分享");
// 获取环境变量
var khzToken = process.env.khzToken;
var khzs = [];
if(typeof(khzToken) == 'undefined'){
console.log('\n khzToken 未填写');
}else{
khzs = khzToken.split("@");
}
console.log('\n ------------- 共'+khzs.length+'个账号 -------------');
// 看广告参数
var adParam = {
"adType": "10086",
"checkString": "49378b9159d242a496f4eda24fc277791",
"type": "2"
}
var idx = 1
for (var i = 0; i < khzs.length; i++) {
var khz = khzs[i];
console.log('\n 开始第'+(i+1)+'个账号');
// 获取广告次数
var adThen = getAdCount(khz);
adThen.then(function (data) {
var adCount = data.data;
console.log('\n 已观看:'+adCount+'次广告');
idx = adCount + 1;
var timer = setInterval(function () {
if (idx > 6) {
clearInterval(timer);
console.log('\n 广告已全部观看,开始领取奖励。。。');
var powerResult = getPower(khz);
powerResult.then(function (data) {
console.log('\n 领取结果:' + data.msg);
});
}else{
console.log('\n 开始第'+(idx)+'轮广告');
var adResult = sendAd(khz);
adResult.then(function (data) {
console.log('\n 观看结果:'+data.msg);
});
}
idx++;
}, 10000);
});
}
// console.log("\n ------------- 开始登录-------------");
/**
* 获取用户信息
*/
function getUserInfo(khzTokenOne){
axios.get('http://ken.kenhz.cn/api/jiadian-user/info/info',{
headers:{
'User-Agent':'okhttp/4.9.0',
'Authorization':khzTokenOne
}
})
.then(res => {
const { data } = res.data
console.log("\n 手机号:"+data.mobile);
console.log("\n 注册地:"+data.districtName);
})
.catch(err => {
console.log('Error: ', err);
});
}
/**
* 获取观看广告次数
* @param {Object} khzTokenOne
*/
function getAdCount(khzTokenOne){
return httpGet("http://ken.kenhz.cn/api/jiadian-power/advertise/check_show_advert_count",khzTokenOne);
}
/**
* 观看广告
*/
function sendAd(khzTokenOne){
return post("http://ken.kenhz.cn/api/jiadian-power/advertise/confirm_show_advert",adParam,true,khzTokenOne);
}
/**
* 领取奖励
*/
function getPower(khzTokenOne){
return post("http://ken.kenhz.cn/api/jiadian-power/power/grant/power",{},true,khzTokenOne);
}
/**
* post方法,对应post请求
* @param {String} url [请求的url地址]
* @param {Object} params [请求时携带的参数]
* @param {Boolean} json [true:json格式请求头;false:FormData格式请求头]
*/
function post(url, params = {}, json = false,khzTokenOne) {
// json格式请求头
const headerJSON = {
"Content-Type": "application/json",
'User-Agent':'okhttp/4.9.0',
'Authorization':khzTokenOne
};
// FormData格式请求头
const headerFormData = {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
'User-Agent':'okhttp/4.9.0',
'Authorization':khzTokenOne
};
return new Promise((resolve, reject) => {
axios
.post(url, json ? JSON.stringify(params) : QS.stringify(params), {
headers: json ? headerJSON : headerFormData
})
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err.data);
});
});
}
/**
* GET请求
*/
function httpGet(url,khzTokenOne) {
// FormData格式请求头
const headerFormData = {
'User-Agent':'okhttp/4.9.0',
'Authorization':khzTokenOne
};
return new Promise((resolve, reject) => {
axios
.get(url,{
headers: headerFormData
})
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err.data);
});
});
}