FIRST commit

This commit is contained in:
Faker
2024-11-12 11:17:55 +08:00
commit dbfb6cecc2
403 changed files with 36107 additions and 0 deletions

270
function/common.js Normal file
View File

@@ -0,0 +1,270 @@
let request = require('request');
let CryptoJS = require('crypto-js');
let qs = require('querystring');
let urls = require('url');
let path = require('path');
let notify = require('./sendNotify');
let mainEval = require("./eval");
let assert = require('assert');
let jxAlgo = require("./jxAlgo");
let config = require("./config");
let user = {}
try {
user = require("./user")
} catch (e) {}
class env {
constructor(name) {
this.config = { ...config,
...process.env,
...user,
};
this.name = name;
this.message = [];
this.sharecode = [];
this.code = [];
this.timestamp = new Date().getTime();
this.time = this.start = parseInt(this.timestamp / 1000);
this.options = {
'headers': {}
};
console.log(`\n🔔${this.name}, 开始!\n`)
console.log(`=========== 脚本执行-北京时间(UTC+8)${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()} ===========\n`)
}
done() {
let timestamp = new Date().getTime();
let work = ((timestamp - this.timestamp) / 1000).toFixed(2)
console.log(`=========================脚本执行完成,耗时${work}s============================\n`)
console.log(`🔔${this.name}, 结束!\n`)
}
notify(array) {
let text = '';
for (let i of array) {
text += `${i.user} -- ${i.msg}\n`
}
console.log(`\n=============================开始发送提醒消息=============================`)
notify.sendNotify(this.name + "消息提醒", text)
}
wait(t) {
return new Promise(e => setTimeout(e, t))
}
setOptions(params) {
this.options = params;
}
setCookie(cookie) {
this.options.headers.cookie = cookie
}
jsonParse(str) {
try {
return JSON.parse(str);
} catch (e) {
try {
let data = this.match([/try\s*\{\w+\s*\(([^\)]+)/, /\w+\s*\(([^\)]+)/], str)
return JSON.parse(data);
} catch (ee) {
try {
let cb = this.match(/try\s*\{\s*(\w+)/, str)
if (cb) {
let func = "";
let data = str.replace(cb, `func=`)
eval(data);
return func
}
} catch (eee) {
return str
}
}
}
}
curl(params, extra = '') {
if (typeof(params) != 'object') {
params = {
'url': params
}
}
params = Object.assign({ ...this.options
}, params);
params.method = params.body ? 'POST' : 'GET';
if (params.hasOwnProperty('cookie')) {
params.headers.cookie = params.cookie
}
if (params.hasOwnProperty('ua') || params.hasOwnProperty('useragent')) {
params.headers['user-agent'] = params.ua
}
if (params.hasOwnProperty('referer')) {
params.headers.referer = params.referer
}
if (params.hasOwnProperty('params')) {
params.url += '?' + qs.stringify(params.params)
}
if (params.hasOwnProperty('form')) {
params.method = 'POST'
}
return new Promise(resolve => {
request(params, async (err, resp, data) => {
try {
if (params.console) {
console.log(data)
}
this.source = this.jsonParse(data);
if (extra) {
this[extra] = this.source
}
} catch (e) {
console.log(e, resp)
} finally {
resolve(data);
}
})
})
}
dumps(dict) {
return JSON.stringify(dict)
}
loads(str) {
return JSON.parse(str)
}
notice(msg) {
this.message.push({
'index': this.index,
'user': this.user,
'msg': msg
})
}
notices(msg, user, index = '') {
this.message.push({
'user': user,
'msg': msg,
'index': index
})
}
urlparse(url) {
return urls.parse(url, true, true)
}
md5(encryptString) {
return CryptoJS.MD5(encryptString).toString()
}
haskey(data, key, value) {
value = typeof value !== 'undefined' ? value : '';
var spl = key.split('.');
for (var i of spl) {
i = !isNaN(i) ? parseInt(i) : i;
try {
data = data[i];
} catch (error) {
return '';
}
}
if (data == undefined) {
return ''
}
if (value !== '') {
return data === value ? true : false;
} else {
return data
}
}
match(pattern, string) {
pattern = (pattern instanceof Array) ? pattern : [pattern];
for (let pat of pattern) {
// var match = string.match(pat);
var match = pat.exec(string)
if (match) {
var len = match.length;
if (len == 1) {
return match;
} else if (len == 2) {
return match[1];
} else {
var r = [];
for (let i = 1; i < len; i++) {
r.push(match[i])
}
return r;
}
break;
}
// console.log(pat.exec(string))
}
return '';
}
matchall(pattern, string) {
pattern = (pattern instanceof Array) ? pattern : [pattern];
var match;
var result = [];
for (var pat of pattern) {
while ((match = pat.exec(string)) != null) {
var len = match.length;
if (len == 1) {
result.push(match);
} else if (len == 2) {
result.push(match[1]);
} else {
var r = [];
for (let i = 1; i < len; i++) {
r.push(match[i])
}
result.push(r);
}
}
}
return result;
}
compare(property) {
return function(a, b) {
var value1 = a[property];
var value2 = b[property];
return value1 - value2;
}
}
filename(file, rename = '') {
if (!this.runfile) {
this.runfile = path.basename(file).replace(".js", '').replace(/-/g, '_')
}
if (rename) {
rename = `_${rename}`;
}
return path.basename(file).replace(".js", rename).replace(/-/g, '_');
}
rand(n, m) {
var random = Math.floor(Math.random() * (m - n + 1) + n);
return random;
}
random(arr, num) {
var temp_array = new Array();
for (var index in arr) {
temp_array.push(arr[index]);
}
var return_array = new Array();
for (var i = 0; i < num; i++) {
if (temp_array.length > 0) {
var arrIndex = Math.floor(Math.random() * temp_array.length);
return_array[i] = temp_array[arrIndex];
temp_array.splice(arrIndex, 1);
} else {
break;
}
}
return return_array;
}
compact(lists, keys) {
let array = {};
for (let i of keys) {
if (lists[i]) {
array[i] = lists[i];
}
}
return array;
}
unique(arr) {
return Array.from(new Set(arr));
}
end(args) {
return args[args.length - 1]
}
}
module.exports = {
env,
eval: mainEval,
assert,
jxAlgo,
}

1
function/config.js Normal file
View File

@@ -0,0 +1 @@
module.exports = {"ThreadJs":[],"invokeKey":"RtKLB8euDo7KwsO0"}

1
function/dylank.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylano.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylans.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylanv.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylanw.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylanx.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylany.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylanz.js Normal file

File diff suppressed because one or more lines are too long

1
function/dylib.js Normal file

File diff suppressed because one or more lines are too long

1
function/getH5st3_0.js Normal file

File diff suppressed because one or more lines are too long

1
function/getToken.js Normal file

File diff suppressed because one or more lines are too long

3
function/h5source/47.js Normal file

File diff suppressed because one or more lines are too long

12
function/h5st41.js Normal file

File diff suppressed because one or more lines are too long

1
function/jdCommon.js Normal file

File diff suppressed because one or more lines are too long

1
function/jdCommon1.js Normal file

File diff suppressed because one or more lines are too long

1
function/jdCrypto.js Normal file

File diff suppressed because one or more lines are too long

35
function/jdcookie.js Normal file
View File

@@ -0,0 +1,35 @@
/*
此文件为Node.js专用。其他用户请忽略
*/
//此处填写京东账号cookie。
let CookieJDs = [
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX;
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推
]
// 判断环境变量里面是否有京东ck
if (process.env.JD_COOKIE) {
if (process.env.JD_COOKIE.indexOf('&') > -1) {
CookieJDs = process.env.JD_COOKIE.split('&');
} else if (process.env.JD_COOKIE.indexOf('\n') > -1) {
CookieJDs = process.env.JD_COOKIE.split('\n');
} else {
CookieJDs = [process.env.JD_COOKIE];
}
}
if (JSON.stringify(process.env).indexOf('GITHUB')>-1) {
console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`);
!(async () => {
await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`)
await process.exit(0);
})()
}
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))]
console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=================\n`);
console.log(`============脚本执行时间:${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('chinese',{hour12:false})}=============\n`)
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
for (let i = 0; i < CookieJDs.length; i++) {
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`);
const index = (i + 1 === 1) ? '' : (i + 1);
exports['CookieJD' + index] = CookieJDs[i].trim();
}
console.log('>>>>>>>>>>>>>>Faker 提示:任务正常运行中>>>>>>>>>>>>>>>\n')

1
function/proxy.js Normal file

File diff suppressed because one or more lines are too long

204
function/ql.js Normal file
View File

@@ -0,0 +1,204 @@
'use strict';
const got = require('got');
require('dotenv').config();
const { readFile } = require('fs/promises');
const path = require('path');
const qlDir = '/ql';
const fs = require('fs');
let Fileexists = fs.existsSync('/ql/data/config/auth.json');
let authFile="";
if (Fileexists)
authFile="/ql/data/config/auth.json"
else
authFile="/ql/config/auth.json"
//const authFile = path.join(qlDir, 'config/auth.json');
const api = got.extend({
prefixUrl: 'http://127.0.0.1:5600',
retry: { limit: 0 },
});
async function getToken() {
const authConfig = JSON.parse(await readFile(authFile));
return authConfig.token;
}
module.exports.getEnvs = async () => {
const token = await getToken();
const body = await api({
url: 'api/envs',
searchParams: {
searchValue: 'JD_COOKIE',
t: Date.now(),
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).json();
return body.data;
};
module.exports.getEnvsCount = async () => {
const data = await this.getEnvs();
return data.length;
};
module.exports.addEnv = async (cookie, remarks) => {
const token = await getToken();
const body = await api({
method: 'post',
url: 'api/envs',
params: { t: Date.now() },
json: [{
name: 'JD_COOKIE',
value: cookie,
remarks,
}],
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.updateEnv = async (cookie, eid, remarks) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
_id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.updateEnv11 = async (cookie, eid, remarks) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs',
params: { t: Date.now() },
json: {
name: 'JD_COOKIE',
value: cookie,
id: eid,
remarks,
},
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.DisableCk = async (eid) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/disable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.EnableCk = async (eid) => {
const token = await getToken();
const body = await api({
method: 'put',
url: 'api/envs/enable',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};
module.exports.getstatus = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
tempid = 0;
if (envs[i]._id) {
tempid = envs[i]._id;
}
if (envs[i].id) {
tempid = envs[i].id;
}
if (tempid == eid) {
return envs[i].status;
}
}
return 99;
};
module.exports.getEnvById = async(eid) => {
const envs = await this.getEnvs();
var tempid = 0;
for (let i = 0; i < envs.length; i++) {
tempid = 0;
if (envs[i]._id) {
tempid = envs[i]._id;
}
if (envs[i].id) {
tempid = envs[i].id;
}
if (tempid == eid) {
return envs[i].value;
}
}
return "";
};
module.exports.getEnvByPtPin = async (Ptpin) => {
const envs = await this.getEnvs();
for (let i = 0; i < envs.length; i++) {
var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
if(tempptpin==Ptpin){
return envs[i];
}
}
return "";
};
module.exports.delEnv = async (eid) => {
const token = await getToken();
const body = await api({
method: 'delete',
url: 'api/envs',
params: { t: Date.now() },
body: JSON.stringify([eid]),
headers: {
Accept: 'application/json',
authorization: `Bearer ${token}`,
'Content-Type': 'application/json;charset=UTF-8',
},
}).json();
return body;
};

166
function/qlApi.js Normal file
View File

@@ -0,0 +1,166 @@
/*
* @Author: chenghao
* @Date: 2022-02-14 10:19:21
* @Last Modified by: chenghao
* @Last Modified time: 2022-03-20 13:57:10
* @Desc: 青龙依赖
* @From: https://github.com/whyour/qinglong/issues/1369
*/
const axios = require('axios')
const QL_URL = 'http://127.0.0.1:5700'
const CLIENT_ID = process.env.CLIENT_ID
const CLIENT_SECRET = process.env.CLIENT_SECRET
/**
*获取青龙token
*/
function getQLToken() {
return new Promise((resolve, reject) => {
axios
.get(
QL_URL +
`/open/auth/token?client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}`
)
.then(res => {
if (res.data.code === 200) {
resolve(res.data.data.token)
} else {
reject(res.data.message)
}
})
})
}
/**
*构造请求头
* @returns headers
*/
async function generateRequestHeader() {
return new Promise(async resolve => {
const token = await getQLToken()
resolve({
Authorization: 'Bearer ' + token,
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4577.63 Safari/537.36',
'Content-Type': 'application/json;charset=UTF-8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9'
})
})
}
/**
*初始化请求实例
* @returns axios instance
*/
async function init() {
if (!CLIENT_ID || !CLIENT_SECRET)
return Promise.reject('未获取到 CLIENT_ID 或 CLIENT_SECRET')
const headers = await generateRequestHeader()
return new Promise(resolve => {
resolve(
axios.create({
baseURL: QL_URL,
timeout: 10000,
headers
})
)
})
}
/**
*
*获取青龙环境变量
* @param {*} instance
* @returns [] envlist
*/
function getQLEnvs(instance, searchValue = 'JD_COOKIE') {
return new Promise(resolve => {
instance
.get('/open/envs', {
params: {
searchValue,
t: +new Date()
}
})
.then(res => {
resolve(res.data.data.filter(v => v.status === 0))
})
})
}
/**
*创建ck环境变量
* @param {*} instance
* @param {*} [ck=[]]
* @returns
*/
function createCkEnv(instance, ck = []) {
return new Promise(resolve => {
instance
.post(`/open/envs?t=${+new Date()}`, ck)
.then(res => {
resolve(res.data)
})
.catch(error => {
console.log(error.response.data)
})
})
}
/**
* 更新环境变量
* @param {*} instance
* @param {*} ck
* @returns
*/
function updateCkEnv(instance, ck = {}) {
return new Promise(resolve => {
instance
.put(`/open/envs?t=${+new Date()}`, ck)
.then(res => {
resolve(res.data)
})
.catch(error => {
console.log(error.response.data)
})
})
}
/**
* 删除环境变量
* @param {*} instance
* @param {*} ckIds
* @returns
*/
function deleteCkEnv(instance, ckIds = []) {
return new Promise(resolve => {
instance({
method: 'delete',
url: `/open/envs?t=${+new Date()}`,
data: ckIds
}).then(resolve)
})
}
/**
*切换ck状态
* @param {*} instance
* @param {*} path
* @param {*} id
* @returns
*/
function toggleCKEnv(instance, id, path = 'enable') {
return new Promise(resolve => {
instance.put(`/open/envs/${path}?t=${+new Date()}`, [id]).then(res => {
resolve(res.data)
})
})
}
exports.createEnv = createCkEnv
exports.deleteEnv = deleteCkEnv
exports.getEnv = getQLEnvs
exports.initInstance = init
exports.updateCkEnv = updateCkEnv
exports.toggleCKEnv = toggleCKEnv

1
function/savePrize.js Normal file

File diff suppressed because one or more lines are too long

1
function/sendJDNotify.js Normal file

File diff suppressed because one or more lines are too long

2326
function/sendNotify.js Normal file

File diff suppressed because it is too large Load Diff