Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
Javascript for loading a large number of facebook activity log comments rather than manually scrolling?

A script for deleting a number comments at once from facebook posts has worked as follows:

  • fb.com > Account > Settings & privacy > Activty log > Comments
  • Function F12 > Console
  • Copy and paste to the console:

.

setInterval(() => {
    for (const Button of document.querySelectorAll('div[aria-label="Action options"]')) {
        Button.click();
        document.querySelector('div[role="menuitem"]').click()
    }
}, 1000)

It processes (deletes) the comments that have been loaded on the screen. By scrolling down, the page loads and displays more comments. Without having to manually do this scrolling to load more, is there a away to load many screens worth?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I made a little snippet a while ago for a very similar purpose. I just tested it on the page in question in Firefox. I added your snippet to where I think it would run best, but didn't want to delete anything, so that part was not tested.

Not sure how the UI works if you delete before scrolling again, but deleting in batches before triggering the next scroll event might be safer than trying to load a huge list first.

If the scrolling stops prematurely, you can adjust the delay timer or the part where it compares scrollHeight to the previous value. It might work well enough by making sure those values are not equal, rather than checking if the new value is greater than the last.

I have the delay timer set to 2 seconds, but you will likely need to tweak that value depending on your system, connection, etc. You could also get a little more creative and add some randomness to the timing to avoid being flagged as a bot.

In my testing, moving to another tab caused issues, so I would recommend leaving FB as the active tab. But feel free to try it, the laptop I tested on has seen better days. It might be safe to split to a new window, didn't test that.

Anway, good luck and I hope this helps. Happy deletions and cheers!

(() => {
var options = {delayMS:2000};
var delay = ms => new Promise(r => setTimeout(r, ms))
//":root" works in most cases
var trackedElement = document.querySelector(":root");

var keepScrolling = async (prev) => {
//store the current scrollHeight before attempting to scroll down.
prev = trackedElement.scrollHeight;
//scroll down
window.scrollTo(0,trackedElement.scrollHeight);
//wait for content to load - load times depend on different factors so feel free to try different values
await delay(options.delayMS);
//if scrollHeight has increased, then keep scrolling
if(trackedElement.scrollHeight > prev){
    console.log("length has been added, restart loop...");
    
    //perform tasks here...

for (const Button of document.querySelectorAll('div[aria-label="Action options"]')) {
        Button.click();
        document.querySelector('div[role="menuitem"]').click()
    }
    
    keepScrolling(prev);
}else{
    //if no change is detected, then the bottom has been reached or the delay timer needs to be increased to allow the content to load before attempting to scroll.
    console.log("Length unchanged. Stopping Scroller");
}

}
//initialize auto-scrolling
keepScrolling(0)
})()
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda