Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save justinpersaud/6993832c26c2359fba1ac6245ddb77c4 to your computer and use it in GitHub Desktop.
Save justinpersaud/6993832c26c2359fba1ac6245ddb77c4 to your computer and use it in GitHub Desktop.
Expand all hidden github comments on issues
function loadAllComments() {
let needRescheduling = false;
const buttons = Array.from(document.querySelectorAll('button'));
buttons.forEach((button) => {
if (button.classList.contains('ajax-pagination-btn')) {
if(!button.hasAttribute('disabled') && button.innerText === 'Load more…') {
console.log("found", button);
needRescheduling = true;
button.dispatchEvent(new MouseEvent('click', {
bubbles: true,
cancelable: true
}));
}
else if(button.hasAttribute('disabled') && button.innerText === 'Loading…') {
console.log("waiting", button);
needRescheduling = true;
}
else {
console.log("unrecognized 'Load more' button", button);
}
}
});
if (needRescheduling) {
setTimeout(loadAllComments, 200)
}
else {
console.log("all comments loaded");
}
}
loadAllComments();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment