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

174
Views
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 answers
Answer question

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 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!