auto-expand-github-issues

cleanup noisy timeline items and auto expand

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         auto-expand-github-issues
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @description  cleanup noisy timeline items and auto expand
// @author       pengx17
// @match        https://github.com/*/issues/*
// @match        https://github.com/*/pull/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @require      https://cdn.jsdelivr.net/npm/@holoflows/[email protected]/umd/index.cjs
// @grant        none
// @license    MIT
// ==/UserScript==

(function () {
  "use strict";

  // Your code here...
  async function main() {
    const { LiveSelector, MutationObserverWatcher } = HoloflowsKit;
    autoLoadMore();
    hideGitHubActionItems();

    ////
    function autoLoadMore() {
      const loadMoreButton = new LiveSelector().querySelector(
        "button.ajax-pagination-btn"
      );
      // auto expand github timeline
      new MutationObserverWatcher(
        loadMoreButton,
        document.querySelector("#repo-content-turbo-frame")
      )
        .useForeach((node, key, meta) => {
          node.click();
        })
        .startWatch({ attributes: true, childList: true, subtree: true });
    }

    function hideGitHubActionItems() {
      const items = new LiveSelector().querySelectorAll(
        ".js-timeline-item .js-updatable-content"
      );
      // auto expand github timeline
      new MutationObserverWatcher(
        items,
        document.querySelector("#repo-content-turbo-frame")
      )
        .useForeach((node, key, meta) => {
          const hideNode = () => {
            if (node.innerText.includes("with  GitHub Actions") || node.innerText.includes('View deployment')) {
              node.style.display = "none";
            } else {
              node.style.display = "block";
            }
          };
          hideNode();
          return {
            onNodeMutation: hideNode,
          };
        })
        .startWatch({ attributes: true, childList: true, subtree: true });
    }
  }

  main();
})();