Skip to content

Instantly share code, notes, and snippets.

@monperrus
Last active February 12, 2025 20:53
Show Gist options
  • Select an option

  • Save monperrus/4f3fa3ecd4fcc9c617734acb7069869c to your computer and use it in GitHub Desktop.

Select an option

Save monperrus/4f3fa3ecd4fcc9c617734acb7069869c to your computer and use it in GitHub Desktop.
Greasemonkey / Tampermonhey / Violentmonkey userscript to automatically show all comments on Github
// ==UserScript==
// @name Github Show All Hidden Comments
// @description Load and show all comments on Github, credits https://github.com/refined-github/refined-github/issues/1892#issuecomment-1044913449
// @url https://gist.github.com/monperrus/4f3fa3ecd4fcc9c617734acb7069869c/edit
// @namespace monperrus
// @author @rentecaaron
// @license Public domain
// @grant none
// @version 1.1.0
//
// @include /https://github.com/.*/(issues|pull)/.*/
// @match https://gist.github.com/*
//
// ==/UserScript==
// test URL https://github.com/rust-lang/rfcs/pull/2544
window.addEventListener('load', function () {
loadComments();
})
let tryAttempts = 0;
function loadComments () {
let needRescheduling = false;
//const buttons = document.querySelectorAll(".ajax-pagination-btn[data-disable-with]")
const buttons = Array.from(document.querySelectorAll('button')).filter(
button => button.textContent.includes('Load more')
);
console.log(buttons)
buttons.forEach((button) => {
button.click();
needRescheduling = true;
tryAttempts = 0;
})
if (needRescheduling || tryAttempts < 5) {
if (needRescheduling) {
console.log("Loading comments.")
} else {
console.log("Looking for more to load.");
}
tryAttempts++;
setTimeout(loadComments, 500)
} else {
console.log("All comments loaded.");
const resolvedButtons = Array.from(document.querySelectorAll('button')).filter(
button => button.textContent.includes('Load more')
);
resolvedButtons.forEach((button) => {
button.click();
})
console.log("All resolved comments loaded.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment