Update yingsheng.js

This commit is contained in:
smallfawn
2023-08-29 19:31:29 +08:00
committed by GitHub
parent 797d038903
commit 33ab2eea52

View File

@@ -1,11 +1,11 @@
/**
*
* new Env("硬声")
* cron 2 17 * * * yingsheng.js
* Show:
* 23/08/29 更新点赞任务
* 变量名:yingsheng_data
* 变量值:抓yingsheng.elecfans.com 请求头Headers中Authorization或者token
* scriptVersionNow = "0.0.1";
* scriptVersionNow = "0.0.2";
*/
const $ = new Env("硬声");
@@ -14,18 +14,18 @@ const Notify = 1; //0为关闭通知,1为打开通知,默认为1
let envSplitor = ["@", "\n"]; //多账号分隔符
let strSplitor = '&'; //多变量分隔符
let scriptVersionNow = "0.0.1";
let scriptVersionNow = "0.0.2";
async function start() {
await getVersion("smallfawn/QLScriptPublic@main/yingsheng.js");
await getNotice();
console.log("\n================== 用户信息 ==================\n");
console.log("\n====================================\n");
let taskall = [];
for (let user of $.userList) {
if (user.ckStatus) {
taskall.push(await user.sign_in_info());
taskall.push(await user.task());
await $.wait(1000);
}
}
@@ -42,12 +42,18 @@ class UserInfo {
* //该加密实现 https://yingshengstatic.elecfans.com/80f05da.js 关键词 (t.headers.sign = v)
* @param {*} r 如果是get传入params 如果是post传入data/body
*/
getSign(timestamp, r) {
getSign(timestamp, r, type) {
//let newData = r
var n = "lw0270iBJzxXdJLRtePEENsauRzkHSqm"
var n
if (type == "h5") {
n = "lw0270iBJzxXdJLRtePEENsauRzkHSqm"
} else if (type == "android") {
n = "cnry8k3o4WdCGU1Tq09cRVOPCnfJzt7p"
}
const crypto = require("crypto");
let l = { timestamp: timestamp, Authorization: this.ck, platform: "h5" }
let l = { timestamp: timestamp, Authorization: this.ck, platform: type }
var data = {};
Object.keys(r).map(function (t) {
data[t] = r[t];
@@ -72,7 +78,12 @@ class UserInfo {
}
return str.slice(0, -1);
}
var f = convertObjectToString(l)
if(type == "android") {
f += "cnry8k3o4WdCGU1Tq09cRVOPCnfJzt7p"
}
var h = crypto.createHash("sha1"),
d = crypto.createHash("sha1");
h.update(f);
@@ -81,12 +92,11 @@ class UserInfo {
var v = d.digest("hex");
return v
}
getHeaders(data) {
getHeaders_H5(data) {
const timestamp = Math.round(new Date().getTime() / 1e3)
return {
"Host": "yingsheng.elecfans.com",
"Connection": "keep-alive",
//"Content-Length": "11",
"Authorization": this.ck,
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, /",
@@ -94,7 +104,7 @@ class UserInfo {
"User-Agent": "Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/81.0.4044.138 Mobile Safari/537.36appAndroid",
"platform": "h5",
"token": this.ck,
"sign": this.getSign(timestamp, data),
"sign": this.getSign(timestamp, data, "h5"),
"version": "2.7.4",
"Origin": "https://yingsheng.elecfans.com",
"X-Requested-With": "com.hq.hardvoice",
@@ -104,15 +114,35 @@ class UserInfo {
"Referer": `https://yingsheng.elecfans.com/task?token=${this.ck}&version=2.7.4&time=${timestamp}&statusH=30`,
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
//"Cookie": "Hm_lvt_85785f4374cae14ef4845ab2a22ab1d6=1693213217; Hm_lpvt_85785f4374cae14ef4845ab2a22ab1d6=1693213222"
}
}
getHeaders_ANDROID(data) {
const timestamp = Math.round(new Date().getTime() / 1e3)
return {
"Host": "ysapi.elecfans.com",
"Connection": "keep-alive",
"Authorization": this.ck,
"Content-Type": "application/json;charset=UTF-8",
"model": "MI 8 Lite",
"timestamp": timestamp,
"User-Agent": "okhttp/3.12.6",
//"markId":"",
"platform": "android",
"sign": this.getSign(timestamp, data, "android"),
"version": "2.7.4",
"Accept-Encoding": "gzip",
}
}
async task() {
await this.sign_in_info()
await this.video_list()
}
async sign_in_info() {
try {
const data = { "date": "" }
let options = {
url: `https://yingsheng.elecfans.com/ysapi/wapi/activity/signin/data?date=`,
headers: this.getHeaders(data),
headers: this.getHeaders_H5(data),
},
result = await httpRequest(options);
//console.log(options);
@@ -140,7 +170,7 @@ class UserInfo {
const data = { "date": "" }
let options = {
url: `https://yingsheng.elecfans.com/ysapi/wapi/activity/signin/signin`,
headers: this.getHeaders(data),
headers: this.getHeaders_H5(data),
body: JSON.stringify(data)
},
result = await httpRequest(options);
@@ -156,6 +186,53 @@ class UserInfo {
console.log(e);
}
}
async video_list() {
try {
const data = { "page": 1 }
let options = {
url: `https://ysapi.elecfans.com/api/recommend/video/index?page=1`,
headers: this.getHeaders_ANDROID(data),
},
result = await httpRequest(options);
//console.log(options);
//console.log(result);
if (result.message == "success") {
$.DoubleLog(`✅账号[${this.index}] 刷新视频列表成功🎉`);
for (let index = 0; index < 5; index++) {
console.log()
await this.video_like(result.data.data[index].detail.id)
}
} else {
$.DoubleLog(`❌账号[${this.index}] 刷新视频列表失败`);
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
async video_like(id) {
try {
const data = { "type": 1, "video_id": id }
let options = {
url: `https://ysapi.elecfans.com/api/video/publish/thumbsup`,
headers: this.getHeaders_ANDROID(data),
body: JSON.stringify(data)
},
result = await httpRequest(options);
//console.log(options);
//console.log(result);
if (result.message == "success") {
$.DoubleLog(`✅账号[${this.index}] 点赞视频成功🎉`);
} else {
$.DoubleLog(`❌账号[${this.index}] 点赞视频失败`);
//console.log(result);
}
} catch (e) {
console.log(e);
}
}
}
!(async () => {
@@ -196,6 +273,7 @@ function httpRequest(options, method = null) {
return new Promise((resolve) => {
$[method](options, (err, resp, data) => {
if (err) {
console.log(resp)
console.log(`${method}请求失败`);
$.logErr(err);
} else {