Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
How to stop JS autoclick loop

I've made a script that auto-click a button on load. This button will add an item on cart and also make a pop-up. After you click the close pop-up icon, the page will be refreshed and triggering auto-click loop. Is there a way to bypass this?

my script:

var a = document.getElementById("discount");
if (discount.dataset.value === "TEST"){for ( var i = 0; i < 50; i++ ) {
  document.getElementById("clickMe").click();
}}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Check if this is working for you!

if (!localStorage.getItem('autoClick')) { // check if code already ran
  // if not then do the clicks

  var a = document.getElementById("discount");
  if (discount.dataset.value === "TEST"){for ( 
  var i = 0; i < 50; i++ ) {
    document.getElementById("clickMe").click();
  }}

  localStorage.setItem('autoClick', true); // save that you did the clicks
} else {
  // if you did the click and pop-up refreshed the page, 
  // let's remove the state so you can auto click again on next refresh
  localStorage.removeItem('autoClick'); 
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try use 'break' in you 'for loop'.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda