Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Like tweets in twitter but throttled using timeout

This is the code I made to like tweets

I am trying to make the code to like tweets but I need a set timeout thing so that i don't get banned while using

for (let i = 0; i < 5; i++)
for(var j = 1; j < 9; j++) {
for (const d of document.querySelectorAll('div[data-testid="like"]')) {
    d.scrollIntoView(true);
    d.click()
  }}; 

I am trying to make a timeout but i don't know how to

I have tried to make it like this but it did not work

for (let i = 0; i < 5; i++)
for(var j = 1; j < 9; j++) {
for (const d of document.querySelectorAll('div[data-testid="like"]')) {
    d.scrollIntoView(true);
    await sleep({ seconds: 1 });
    d.click()
  }}; 

  const sleep = ({ seconds }) =>
    new Promise((proceed) => {
      console.log(`WAITING FOR ${seconds} SECONDS...`);
      setTimeout(proceed, seconds * 1);
    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Don't do this in a loop.

From your comments it sounds like you want a bookmarklet

javascript:(function() { const likes = document.querySelectorAll('div[data-testid=like]'); let cnt = 0; const clickLike = () => { if (cnt >= likes.length) return; const like = likes[cnt]; like.scrollIntoView(true); like.click(); cnt++; setTimeout(clickLike, 1000); }; clickLike(); })() 

Example in a page

window.addEventListener("DOMContentLoaded", () => { // page is ready
  const likes = document.querySelectorAll('div[data-testid=like]');
  let cnt = 0;
  const clickLike = () => {
    if (cnt >= likes.length) return; // stop
    const like = likes[cnt];
    like.classList.add("clicked"); // for show
    like.scrollIntoView({behavior: "smooth"});
    like.click();
    cnt++;
    setTimeout(clickLike, 1000); // wait a second
  };
  clickLike(); // start
});
div[data-testid=like] {
  height: 100px
}
div[data-testid=like].clicked { border: 1px solid green; }
<div data-testid="like">Like 1</div>
<div data-testid="like">Like 2</div>
<div data-testid="like">Like 3</div>
<div data-testid="like">Like 4</div>
<div data-testid="like">Like 5</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!