|
前言
论坛点赞机器网页版并不稳定,多数无法实现全自动点赞,且容易触发请求过多。这里提供一个改进版本。
var stopClick = false;
async function clickWithDelay() {
while (!stopClick) {
const buttons = document.querySelectorAll('.discourse-reactions-reaction-button');
var trueButton = 0;
for (const bt of buttons) {
if (bt.classList.contains('already_clicked')) continue;
bt.classList.add('already_clicked');
trueButton++;
if (bt.innerHTML.indexOf("d-icon-far-heart") == -1) {
console.log("已点赞,滚动...");
await scoll();
continue;
}
if (stopClick) {
console.log("已停止");
break;
}
await scoll();
bt.click();
await new Promise(resolve => setTimeout(resolve, 1800));
let randomNum = Math.floor(Math.random() * 5);
await new Promise(resolve => setTimeout(resolve, 1000 * randomNum));
console.log("点赞成功");
if(document.body.innerHTML.indexOf(`class="di` + `alog-content"`) != -1){
console.log("请求过多,等待30秒...");
await new Promise(resolve => setTimeout(resolve, 1000 * 30));
console.log("已等待");
}
}
if(trueButton == 0) scoll();
}
}
async function scoll() {
for (var a = 0; a setTimeout(resolve, 30));
}
}
function stopClickWithDelay() {
stopClick = true;
}
clickWithDelay();
// 调用 stopClickWithDelay 来停止点击操作
// stopClickWithDelay();
实战效果
直接打开控制台粘贴代码,等待5分钟后,回复此贴。
来都来了,直接打开控制台粘贴进去,等上5分钟再回来,这是义务
然后再回复 |
|