Skip to content

Instantly share code, notes, and snippets.

@haridsv
Last active July 3, 2020 08:56
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 = 0;
var rcvdMutationCnt = 0;
var level = 0;
const observer = new MutationObserver(function(mutationsList, observer) {
++rcvdMutationCnt;
console.log("Current mutation count: " + rcvdMutationCnt + " target mutation count: " + tgtMutationCnt + " in level: " + level);
if (rcvdMutationCnt == tgtMutationCnt) {
++level;
console.log("Target mutation count achieved, checking if level: " + level + " exists");
loadAll();
}
});
function loadAll() {
var paginationButtons = document.querySelectorAll(".ajax-pagination-btn");
console.log("loadAll found " + paginationButtons.length + " buttons in level: " + level);
tgtMutationCnt += paginationButtons.length;
paginationButtons.forEach(l => {
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