Discussion about this post

User's avatar
Mike Koncsics's avatar

This worked in Firefox, too. Thanks!

RickM's avatar

Follow-up. I asked Google Gemini to modify the javascript code, to add the feature of searching for all instances of "Expand Full Comment" and click on them. Seems to work. Code is:

- - - -

javascript: (() => {

const maxClicks = 400;

let clickCount = 0;

const escapeHandler = (e) => {

if (e.key === "Escape") {

cleanup("Action stopped by user via Escape key.");

}

};

addEventListener("keydown", escapeHandler);

const intervalID = setInterval(() => {

/* 1. First, click all "Expand Full Comment" instances currently visible */

const expandText = "expand full comment";

const allElements = document.querySelectorAll("button, a, span, div");

allElements.forEach(el => {

if (el.textContent.toLowerCase().trim() === expandText) {

el.click();

}

});

/* 2. Then, look for the "Load More" / "More Comments" button to trigger the next batch */

const allButtons = document.querySelectorAll(".comment-list-container button");

let targetButton = null;

for (const btn of allButtons) {

const text = btn.innerText.toLowerCase();

if (text.includes("more comments") || text.includes("load more")) {

targetButton = btn;

break;

}

}

if (targetButton && clickCount < maxClicks) {

targetButton.scrollIntoView({ behavior: "smooth", block: "nearest" });

targetButton.click();

clickCount++;

} else {

const msg =

clickCount >= maxClicks

? "Stopped: Click limit reached."

: "Finished: No more buttons found.";

cleanup(msg);

}

}, 2000);

function cleanup(message) {

clearInterval(intervalID);

removeEventListener("keydown", escapeHandler);

alert(message);

}

})();

- - - -

5 more comments...

No posts

Ready for more?