Skip to content

Commit

Permalink
chore: ...
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Sep 3, 2024
1 parent 214b3b9 commit c52999d
Show file tree
Hide file tree
Showing 4 changed files with 403 additions and 145 deletions.
6 changes: 4 additions & 2 deletions bypasscf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TelegramBot from "node-telegram-bot-api";
dotenv.config();
const token = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
let bot
let bot;
if (token && chatId) {
bot = new TelegramBot(token);
}
Expand Down Expand Up @@ -219,7 +219,9 @@ async function launchBrowserForUser(username, password) {
} catch (err) {
// throw new Error(err);
console.log("Error:", err);
sendToTelegram(`${err.message}`);
if (token && chatId) {
sendToTelegram(`${err.message}`);
}
}
}
async function login(page, username, password) {
Expand Down
139 changes: 1 addition & 138 deletions external_likeUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"https://meta.appinn.net",
"https://community.openai.com",
];
const commentLimit = 1000;
const specificUserPostListLimit = 100;
const currentURL = window.location.href;
let specificUser = localStorage.getItem("specificUser") || "14790897";
Expand Down Expand Up @@ -95,7 +94,7 @@
let isDataSufficient = false;

while (!isDataSufficient) {
// lastOffset += 20;
// lastOffset += 20; //对于user_actions
lastOffset += 1; //对于page来说
// 举例:https://linux.do/user_actions.json?offset=0&username=14790897&filter=5
// const url = `${BASE_URL}/user_actions.json?offset=${lastOffset}&username=${specificUser}&filter=5`;
Expand Down Expand Up @@ -182,12 +181,6 @@
}
}

// 检查是否点赞
// const postId = data.post_id;

// const targetId = `discourse-reactions-counter-${postId}-right`;

// const element = document.getElementById(targetId);
function likeSpecificPost() {
const urlParts = window.location.pathname.split("/");
const lastPart = urlParts[urlParts.length - 1]; // 获取最后一部分
Expand Down Expand Up @@ -260,134 +253,4 @@
});
button.dispatchEvent(event);
}

const button = document.createElement("button");
button.textContent =
localStorage.getItem("read") === "true" ? "停止阅读" : "开始阅读";
button.style.position = "fixed";
button.style.bottom = "20px";
button.style.left = "20px";
button.style.zIndex = 1000;
button.style.backgroundColor = "#e0e0e0";
button.style.color = "#333";
button.style.border = "1px solid #aaa";
button.style.padding = "8px 16px";
button.style.borderRadius = "8px";
document.body.appendChild(button);

button.onclick = function () {
const currentlyReading = localStorage.getItem("read") === "true";
const newReadState = !currentlyReading;
localStorage.setItem("read", newReadState.toString());
button.textContent = newReadState ? "停止阅读" : "开始阅读";
if (newReadState) {
if (BASE_URL == "https://linux.do") {
const maxPostNumber = 600;
const randomPostNumber = Math.floor(Math.random() * maxPostNumber) + 1;
const newUrl = `https://linux.do/t/topic/13716/${randomPostNumber}`;
window.location.href = newUrl;
} else {
window.location.href = `${BASE_URL}/t/topic/1`;
}
}
};

const userInput = document.createElement("input");
userInput.type = "text";
userInput.placeholder = "输入要点赞的用户ID";
userInput.style.position = "fixed";
userInput.style.bottom = "90px";
userInput.style.left = "20px";
userInput.style.zIndex = "1000";
userInput.style.padding = "6px";
userInput.style.border = "1px solid #aaa";
userInput.style.borderRadius = "8px";
userInput.style.backgroundColor = "#e0e0e0";
userInput.style.width = "100px";
userInput.value = localStorage.getItem("specificUser") || "14790897";

document.body.appendChild(userInput);

const saveUserButton = document.createElement("button");
saveUserButton.textContent = "保存用户ID";
saveUserButton.style.position = "fixed";
saveUserButton.style.bottom = "60px";
saveUserButton.style.left = "20px";
saveUserButton.style.zIndex = "1000";
saveUserButton.style.backgroundColor = "#e0e0e0";
saveUserButton.style.color = "#333";
saveUserButton.style.border = "1px solid #aaa";
saveUserButton.style.padding = "8px 16px";
saveUserButton.style.borderRadius = "8px";
document.body.appendChild(saveUserButton);

saveUserButton.onclick = function () {
const newSpecificUser = userInput.value.trim();
if (newSpecificUser) {
localStorage.setItem("specificUser", newSpecificUser);
localStorage.removeItem("specificUserPostList");
specificUser = newSpecificUser;
console.log(
`新的specificUser已保存: ${specificUser},specificUserPostList已重置`
);
}
};

const likeLimitInput = document.createElement("input");
likeLimitInput.type = "number";
likeLimitInput.placeholder = "输入点赞数量";
likeLimitInput.style.position = "fixed";
likeLimitInput.style.bottom = "180px";
likeLimitInput.style.left = "20px";
likeLimitInput.style.zIndex = "1000";
likeLimitInput.style.padding = "6px";
likeLimitInput.style.border = "1px solid #aaa";
likeLimitInput.style.borderRadius = "8px";
likeLimitInput.style.backgroundColor = "#e0e0e0";
likeLimitInput.style.width = "100px";
likeLimitInput.value = localStorage.getItem("likeLimit") || 200;
document.body.appendChild(likeLimitInput);

const saveLikeLimitButton = document.createElement("button");
saveLikeLimitButton.textContent = "保存点赞数量";
saveLikeLimitButton.style.position = "fixed";
saveLikeLimitButton.style.bottom = "140px";
saveLikeLimitButton.style.left = "20px";
saveLikeLimitButton.style.zIndex = "1000";
saveLikeLimitButton.style.backgroundColor = "#e0e0e0";
saveLikeLimitButton.style.color = "#333";
saveLikeLimitButton.style.border = "1px solid #aaa";
saveLikeLimitButton.style.padding = "8px 16px";
saveLikeLimitButton.style.borderRadius = "8px";
document.body.appendChild(saveLikeLimitButton);

saveLikeLimitButton.onclick = function () {
const newLikeLimit = parseInt(likeLimitInput.value.trim(), 10);
if (newLikeLimit && newLikeLimit > 0) {
localStorage.setItem("likeLimit", newLikeLimit);
likeLimit = newLikeLimit;
console.log(`新的likeLimit已保存: ${likeLimit}`);
}
};

// 增加清除数据的按钮
const clearDataButton = document.createElement("button");
clearDataButton.textContent = "清除所有数据";
clearDataButton.style.position = "fixed";
clearDataButton.style.bottom = "20px";
clearDataButton.style.left = "140px";
clearDataButton.style.zIndex = "1000";
clearDataButton.style.backgroundColor = "#ff6666"; // 红色背景,提示删除操作
clearDataButton.style.color = "#fff"; // 白色文本
clearDataButton.style.border = "1px solid #ff3333"; // 深红色边框
clearDataButton.style.padding = "8px 16px";
clearDataButton.style.borderRadius = "8px";
document.body.appendChild(clearDataButton);

clearDataButton.onclick = function () {
localStorage.removeItem("lastOffset");
localStorage.removeItem("clickCounter");
localStorage.removeItem("clickCounterTimestamp");
console.log("所有数据已清除,除了 specificUser 和 specificUserPostList");
};
})();
9 changes: 4 additions & 5 deletions index_likeUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,7 @@
let targetButton = null;
buttons.forEach((button) => {
const ariaLabel = button.getAttribute("aria-label");
if (
ariaLabel &&
(ariaLabel.includes(`#${lastPart}`))
) {
if (ariaLabel && ariaLabel.includes(`#${lastPart}`)) {
targetButton = button;
console.log("找到post number按钮:", targetButton);
return;
Expand All @@ -221,7 +218,8 @@
} else {
console.log(`未找到包含 #${lastPart} 的按钮`);
}
} else {//大于10000说明是主题帖,选择第一个
} else {
//大于10000说明是主题帖,选择第一个
reactionButton = document.querySelectorAll(
".discourse-reactions-reaction-button"
)[0];
Expand Down Expand Up @@ -390,6 +388,7 @@
localStorage.removeItem("lastOffset");
localStorage.removeItem("clickCounter");
localStorage.removeItem("clickCounterTimestamp");
localStorage.removeItem("specificUserPostList");
console.log("所有数据已清除,除了 specificUser 和 specificUserPostList");
};
})();
Loading

0 comments on commit c52999d

Please sign in to comment.