Auto Load GitHub Issue Comments

Automatically load all comments in GitHub issues

  1. // ==UserScript==
  2. // @name Auto Load GitHub Issue Comments
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Automatically load all comments in GitHub issues
  6. // @author Your Name
  7. // @match https://github.com/*/*/issues/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. let tryAttempts = 0;
  16.  
  17. function loadComments() {
  18. let needRescheduling = false;
  19.  
  20. // Find and click pagination buttons
  21. const paginationButtons = document.querySelectorAll(".ajax-pagination-btn[data-disable-with]");
  22. paginationButtons.forEach((button) => {
  23. button.click();
  24. needRescheduling = true;
  25. tryAttempts = 0; // Reset attempts if new pagination button is found
  26. });
  27.  
  28. // Retry logic
  29. if (needRescheduling || tryAttempts < 5) {
  30. if (needRescheduling) {
  31. console.log("Loading more comments...");
  32. } else {
  33. console.log("Retrying to find comments to load...");
  34. }
  35. tryAttempts++;
  36. setTimeout(loadComments, 500); // Retry after 500ms
  37. } else {
  38. console.log("All comments loaded.");
  39.  
  40. // Load resolved comments
  41. const resolvedButtons = document.querySelectorAll(".js-toggle-outdated-comments[data-view-component]");
  42. resolvedButtons.forEach((button) => {
  43. button.click();
  44. });
  45.  
  46. console.log("All resolved comments loaded.");
  47. }
  48. }
  49.  
  50. // Trigger on page load
  51. window.addEventListener('load', function () {
  52. console.log("GitHub Auto Comment Loader: Started");
  53. loadComments();
  54. });
  55. })();