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

577
Vistas
Chrome Console Script broken: Uncaught TypeError: Cannot read properties of undefined (reading 'push')

I'm using the following code on Instagram follow request page to open each user in a new tab and then unfollow it.

https://www.instagram.com/accounts/access_tool/current_follow_requests

 var i=0;  
 var unfollow="global";  
 var final="global";  
 var link=["link","link2"];  
 var proWindow=[""]  
 proWindow.length=0  
 link.length=0;  
 var ids = document.querySelectorAll(".-utLf");  
 for(i=0;i<ids.length;i++){  
   link.push('https://www.instagram.com/'+ids[i].innerText+'/');  
      console.log(link[i]);  
      proWindow[i]=window.open(link[i]);  
 }  

and then the following code to unfollow each user:

for(i=0;i<ids.length;i++){
 unfollow = proWindow[i].document.querySelector("button.sqdOP");
 unfollow.click();
 await new Promise(resolve => setTimeout(resolve, 1000));
 final = proWindow[i].document.querySelector(".aOOlW");
 final.click();}
console.log("Completed");  

however, I'm seeing the following error on the console Uncaught TypeError: Cannot read properties of undefined (reading 'push')

This preivously used to work fine but now is showing this error.

What change needs to be done to fix this code?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This error originates from trying to push something undefined to an array. That could happend if the nodelist returned by the queryselector contains something with an undefined innertext for some reason.

This should work better:

if (ids[i].innerText){ // To check if the value is undefined
    link.push('https://www.instagram.com/'+ids[i].innerText+'/');  
    console.log(link[i]);  
    proWindow[i]=window.open(link[i]);    
}
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