Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getdave/3859bd66eb5266a5504c56d0ca41f920 to your computer and use it in GitHub Desktop.
Save getdave/3859bd66eb5266a5504c56d0ca41f920 to your computer and use it in GitHub Desktop.
Bookmarktlet to automatically expand all those "Load more..." links into your Github PRs.
javascript:(function()%7Bfunction%20githubLoadAllPRComments()%20%7B%0A%0A%20%20%20%20function%20recursiveExpandLoadMore()%20%7B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Remove%20all%20existing%20timers%0A%20%20%20%20%20%20%20%20if(theTimeout)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20clearTimeout(theTimeout)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20const%20disabledLoadBtns%20%3D%20document.querySelector('.ajax-pagination-btn%5Bdisabled%5D')%3B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20If%20any%20buttons%20are%20already%20in%20the%20loading%20state%20then%20requeue%0A%20%20%20%20%20%20%20%20if(disabledLoadBtns)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20theTimeout%20%3D%20setTimeout(recursiveExpandLoadMore%2C%201000)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20const%20loadBtn%20%3D%20document.querySelector('.ajax-pagination-btn%3Anot(%5Bdisabled%5D)')%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%2F%2F%20If%20there%20are%20no%20more%20load%20buttons%20then%20we're%20all%20done.%20%20%0A%20%20%20%20%20%20%20%20if(!loadBtn)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20alert(%22All%20loaded%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Trigger%20the%20next%20button%0A%20%20%20%20%20%20%20%20loadBtn.click()%3B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Requeue%0A%20%20%20%20%20%20%20%20theTimeout%20%3D%20setTimeout(recursiveExpandLoadMore%2C%204000)%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20let%20theTimeout%20%3D%20null%3B%0A%0A%20%20%20%20recursiveExpandLoadMore()%3B%0A%7D%0A%0AgithubLoadAllPRComments()%3B%7D)()%3B
function githubLoadAllPRComments() {
function recursiveExpandLoadMore() {
// Remove all existing timers
if(theTimeout) {
clearTimeout(theTimeout);
}
const disabledLoadBtns = document.querySelector('.ajax-pagination-btn[disabled]');
// If any buttons are already in the loading state then requeue
if(disabledLoadBtns) {
theTimeout = setTimeout(recursiveExpandLoadMore, 1000);
}
const loadBtn = document.querySelector('.ajax-pagination-btn:not([disabled])');
// If there are no more load buttons then we're all done.
if(!loadBtn) {
alert("All loaded");
return;
}
// Trigger the next button
loadBtn.click();
// Requeue
theTimeout = setTimeout(recursiveExpandLoadMore, 4000);
}
let theTimeout = null;
recursiveExpandLoadMore();
}
githubLoadAllPRComments();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment