有人能帮我修复这个代码吗?这段代码的目的是点赞一篇文章,然后转到下一张照片。我试着运行代码,但程序不喜欢post。
setInterval(function() {
var heart = document.querySelector('button.coreSpriteHeartOpen');
var arrow = document.querySelector('a.coreSpriteRightPaginationArrow');
if (heart) {
heart.click();
count++;
console.log(`You've liked ${count} photo(s)`);
}
arrow.click();
}, 3000);我尝试使用glyphsSpriteHeart__outline__24__grey_9作为心脏,但它仍然不起作用。
发布于 2020-01-23 21:29:51
我试着运行你的代码,问题出在"count“声明中,这个代码运行得很好:
setInterval(function() {
var count = 0;
var heart = document.querySelector('button.coreSpriteHeartOpen');
var arrow = document.querySelector('a.coreSpriteRightPaginationArrow');
if (heart) {
heart.click();
count++;
console.log(`You've liked ${count} photo(s)`);
}
arrow.click();
}, 3000);发布于 2021-04-01 04:30:53
let likes = 0;
setInterval(() => {
const heart = document.querySelector('svg[aria-label="Like"]').parentNode;
const arrow = document.querySelector('a.coreSpriteRightPaginationArrow');
if (heart) {
heart.click()
likes++;
console.log(`You've liked ${likes} post(s)`);
}
arrow.click();
}, 5000);使用这个,它就会起作用。
https://stackoverflow.com/questions/59878734
复制相似问题