Auto Load GitHub Issue Comments

Automatically load all comments in GitHub issues

当前为 2024-12-24 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Auto Load GitHub Issue Comments
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically load all comments in GitHub issues
// @author       Your Name
// @match        https://github.com/*/*/issues/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    let tryAttempts = 0;

    function loadComments() {
        let needRescheduling = false;

        // Find and click pagination buttons
        const paginationButtons = document.querySelectorAll(".ajax-pagination-btn[data-disable-with]");
        paginationButtons.forEach((button) => {
            button.click();
            needRescheduling = true;
            tryAttempts = 0; // Reset attempts if new pagination button is found
        });

        // Retry logic
        if (needRescheduling || tryAttempts < 5) {
            if (needRescheduling) {
                console.log("Loading more comments...");
            } else {
                console.log("Retrying to find comments to load...");
            }
            tryAttempts++;
            setTimeout(loadComments, 500); // Retry after 500ms
        } else {
            console.log("All comments loaded.");

            // Load resolved comments
            const resolvedButtons = document.querySelectorAll(".js-toggle-outdated-comments[data-view-component]");
            resolvedButtons.forEach((button) => {
                button.click();
            });

            console.log("All resolved comments loaded.");
        }
    }

    // Trigger on page load
    window.addEventListener('load', function () {
        console.log("GitHub Auto Comment Loader: Started");
        loadComments();
    });
})();