Skip to content

Instantly share code, notes, and snippets.

@haridsv
Last active October 29, 2024 06:44
Show Gist options
  • Save haridsv/7ffb51c1d8212e76bf21fc78e6c38984 to your computer and use it in GitHub Desktop.
Save haridsv/7ffb51c1d8212e76bf21fc78e6c38984 to your computer and use it in GitHub Desktop.
Expand all pages ("Load more..." buttons) in a Github PR conversation view.
NOTE: Doesn't work because of github CSP meta tags.
javascript:s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='https://git.io/JJTwA';void(0);
{
var tgtMutationCnt, rcvdMutationCnt;
var level = 0;
function observeMutation(mutationsList, observer) {
++rcvdMutationCnt;
console.log("Received mutation count: " + rcvdMutationCnt + " target mutation count: " + tgtMutationCnt + " in level: " + level);
if (rcvdMutationCnt == tgtMutationCnt) {
console.log("Target mutation count achieved, checking if level: " + level + " exists");
setTimeout(loadAll, 2000);
}
observer.disconnect();
}
function loadAll() {
tgtMutationCnt = 0;
rcvdMutationCnt = 0;
++level;
var paginationButtons = document.querySelectorAll(".ajax-pagination-btn");
if (paginationButtons.length > 0) {
paginationButtons = Array.from(paginationButtons).filter(function(it) {
return it.textContent.trim() == 'Load more…';
});
console.log("loadAll found " + paginationButtons.length + " buttons in level: " + level);
tgtMutationCnt += paginationButtons.length;
paginationButtons.forEach(l => {
var observer = new MutationObserver(observeMutation);
observer.observe(l, { childList: true, subtree: true });
l.click();
});
}
}
loadAll();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment