Created
April 20, 2022 17:47
-
-
Save flotwig/62d13cae35e817ad7b400c507d5f6d5a to your computer and use it in GitHub Desktop.
recursively load github comments userscript
This file contains hidden or 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
// ==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