Last active
October 29, 2024 06:44
-
-
Save haridsv/7ffb51c1d8212e76bf21fc78e6c38984 to your computer and use it in GitHub Desktop.
Expand all pages ("Load more..." buttons) in a Github PR conversation view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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