Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafecolton/bc8548e55cf50b9864ae720534458f76 to your computer and use it in GitHub Desktop.
Save rafecolton/bc8548e55cf50b9864ae720534458f76 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