mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
Some checks failed
Build and push Docker images / docker (push) Failing after 2m16s
Mirror and run GitLab CI / build (push) Failing after 1m44s
Publishing to NPM / publish (push) Failing after 14s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, linux) (push) Failing after 1m41s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, macos) (push) Failing after 52s
Package Node.js project into an executable / node${{ matrix.nodev }}-${{ matrix.platform }}-x64 (18, win) (push) Failing after 52s
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linux) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (linuxstatic) (push) Has been cancelled
Package Node.js project into an executable / node18-${{ matrix.platform }}-arm64 (alpine) (push) Has been cancelled
73 lines
2.4 KiB
JavaScript
73 lines
2.4 KiB
JavaScript
const { getRandomOne, createDir, createFile, dyids_dir } = require('../utils');
|
|
const config = require('../data/config');
|
|
|
|
let global_var = {
|
|
inner: {},
|
|
get(key) {
|
|
return this.inner[key];
|
|
},
|
|
set(key, value) {
|
|
this.inner[key] = value;
|
|
},
|
|
/**
|
|
* 全局变量初始化
|
|
* 更新config
|
|
* @param {string} cookie
|
|
* @param {string} num
|
|
*/
|
|
async init(cookie, num) {
|
|
if (cookie) {
|
|
const
|
|
key_map = new Map([
|
|
['DedeUserID', 'myUID'],
|
|
['bili_jct', 'csrf']]),
|
|
LotteryOrderMap = new Map([
|
|
[0, 'UIDs'],
|
|
[1, 'TAGs'],
|
|
[2, 'Articles'],
|
|
[3, 'APIs'],
|
|
[4, 'TxT'],
|
|
]);
|
|
|
|
config.updata(num);
|
|
|
|
if (!/buvid3/.test(cookie)) {
|
|
const charset = '0123456789ABCDEF'.split('');
|
|
const buvid3 = 'x'.repeat(8).split('').map(() => getRandomOne(charset)).join('')
|
|
+ '-'
|
|
+ 'x'.repeat(4).split('').map(() => getRandomOne(charset)).join('')
|
|
+ '-'
|
|
+ 'x'.repeat(4).split('').map(() => getRandomOne(charset)).join('')
|
|
+ '-'
|
|
+ 'x'.repeat(4).split('').map(() => getRandomOne(charset)).join('')
|
|
+ '-'
|
|
+ 'x'.repeat(17).split('').map(() => getRandomOne(charset)).join('')
|
|
+ 'infoc';
|
|
this.set('cookie', cookie + ';' + buvid3);
|
|
} else {
|
|
this.set('cookie', cookie);
|
|
}
|
|
|
|
cookie.split(/\s*;\s*/).forEach(item => {
|
|
const _item = item.split('=');
|
|
if (key_map.has(_item[0]))
|
|
this.set(key_map.get(_item[0]), _item[1]);
|
|
});
|
|
|
|
const { LotteryOrder } = config;
|
|
this.set('Lottery',
|
|
LotteryOrder
|
|
.map(it => LotteryOrderMap.get(it))
|
|
.filter(it => typeof it === 'string')
|
|
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
|
|
.flat()
|
|
);
|
|
}
|
|
await createDir('dyids');
|
|
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a');
|
|
}
|
|
};
|
|
|
|
|
|
module.exports = global_var;
|