Skip to content

Commit

Permalink
feat: env可自定义UA (#371)
Browse files Browse the repository at this point in the history
Co-authored-by: 简佳 <15779599039@163.com>
  • Loading branch information
JianJia2018 and 简佳 authored Apr 10, 2024
1 parent 364bcd1 commit 7e4650c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion env.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = Object.freeze({
* - `NOTE` 帐号备注
* - `NUMBER` 表示是第几个账号
* - `CLEAR` 是否启用清理功能
* - `ACCOUNT_UA` 账号UA, 可在浏览器控制台输入 navigator.userAgent 查看
* ## 高级功能
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
Expand All @@ -25,6 +26,7 @@ module.exports = Object.freeze({
NOTE: "",
NUMBER: 1,
CLEAR: true,
ACCOUNT_UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",

ENABLE_CHAT_CAPTCHA_OCR: "",
ENABLE_MULTIPLE_ACCOUNT: false,
Expand Down Expand Up @@ -59,7 +61,8 @@ module.exports = Object.freeze({
NOTE: "",
NUMBER: 1,
CLEAR: true,
WAIT: 60 * 1000
WAIT: 60 * 1000,
ACCOUNT_UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
],

Expand Down
2 changes: 1 addition & 1 deletion lib/net/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const DEFAULT_REDIRECT = false;
/**错误尝试次数 */
const DEFAULT_RETRY_TIMES = 6;
/**Google Chrome */
const DEFAULT_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36';
const DEFAULT_UA = process.env.ACCOUNT_UA || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36';
/**默认url编码 */
const DEFAULT_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8';
/**
Expand Down
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function main() {
process.env.NUMBER = acco.NUMBER;
process.env.CLEAR = acco.CLEAR;
process.env.NOTE = acco.NOTE;
process.env.ACCOUNT_UA = acco.ACCOUNT_UA;
const err_msg = await main();
if (err_msg) {
return err_msg
Expand Down

0 comments on commit 7e4650c

Please sign in to comment.