I wrote the following code to automatically 'LIKE' all of the comments on a LinkedIn post using a randomized wait time.
The code can find all of the 'LIKE' buttons and can click on them however, the page will only update all of the 'LIKE' buttons after the full code has been executed
IN SHORT: The page DOES NOT update the 'LIKE' button after each click() has been executed.
QUESTION:
I do not know but does the LinkedIn page fail to update after each click() or is my code running all of the click() executing at the same time?
I am trying to avoid all the click() at the same time
// WAIT FUNCTION
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
// RANDOMIZE WAIT TIME
function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// ADD ALL LIKE BUTTONS TO LIST
let likeButtons = document.querySelectorAll('.artdeco-button__text.react-button__text')
// LOOP LIKE ACTION
likeButtons.forEach(likeButton =>{
// DO CLICK
console.log("likeButton.click()");
likeButton.click();
// ACTIVE WAIT
var waitTime = randomNumber(1000,4000);
console.log("wait time is "+ waitTime);
wait(waitTime);
}
)