Skip to content

Commit

Permalink
feat: 支持禁用自动点赞
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Feb 12, 2025
1 parent c8bbc1c commit f6f5e26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
USERNAMES=lidenghui
PASSWORDS=.JSn6qQPKjsLx@@ # 密码外面要加上双引号,密码内部如果有双引号,需要加上转义字符,linux使用\转义,Windows使用"转义 (注意GitHub action不需要增加处理,也不需要加引号)
WEBSITE=https://linux.do # 需要阅读的网站,支持后面那些:https://meta.discourse.org, https://meta.appinn.net, https://community.openai.com
# 是否开启自动点赞
AUTO_LIKE=true
#运行时间,单位为分钟
RUN_TIME_LIMIT_MINUTES=20
# 电报通知报错信息(可不填)
Expand Down
7 changes: 5 additions & 2 deletions bypasscf.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const totalAccounts = usernames.length; // 总的账号数
const delayBetweenBatches =
runTimeLimitMillis / Math.ceil(totalAccounts / maxConcurrentAccounts);
const isLikeSpecificUser = process.env.LIKE_SPECIFIC_USER || "false";
const isAutoLike = process.env.AUTO_LIKE || "true";
let bot;
if (token && chatId) {
bot = new TelegramBot(token);
Expand Down Expand Up @@ -250,15 +251,17 @@ async function launchBrowserForUser(username, password) {
// 在每个新的文档加载时执行外部脚本
await page.evaluateOnNewDocument(
(...args) => {
const [specificUser, scriptToEval] = args;
const [specificUser, scriptToEval, isAutoLike] = args;
localStorage.setItem("read", true);
localStorage.setItem("specificUser", specificUser);
localStorage.setItem("isFirstRun", "false");
localStorage.setItem("autoLikeEnabled", isAutoLike);
console.log("当前点赞用户:", specificUser);
eval(scriptToEval);
},
specificUser,
externalScript
externalScript,
isAutoLike
); //变量必须从外部显示的传入, 因为在浏览器上下文它是读取不了的
// 添加一个监听器来监听每次页面加载完成的事件
page.on("load", async () => {
Expand Down

0 comments on commit f6f5e26

Please sign in to comment.