Skip to content

Instantly share code, notes, and snippets.

@flotwig
Created April 20, 2022 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flotwig/62d13cae35e817ad7b400c507d5f6d5a to your computer and use it in GitHub Desktop.
Save flotwig/62d13cae35e817ad7b400c507d5f6d5a to your computer and use it in GitHub Desktop.
recursively load github comments userscript
// ==UserScript==
// @name recursively load github comment threads
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author https://github.com/refined-github/refined-github/issues/1892#issuecomment-1044913449
// @match https://github.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant none
// ==/UserScript==
(function() {
window.addEventListener('load', function () {
loadComments();
})
let tryAttempts = 0;
function loadComments () {
let needRescheduling = false;
const buttons = document.querySelectorAll(".ajax-pagination-btn[data-disable-with]")
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 = document.querySelectorAll(".js-toggle-outdated-comments[data-view-component]");
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