Greasy Fork is available in English.

GitHub Auto-Expand Project Fields

Automatically expands collapsed custom project fields in the GitHub issue/PR sidebar (workaround for https://github.com/orgs/community/discussions/15592).

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

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

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

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

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

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

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

Advertisement:

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

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

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

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

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

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

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

Advertisement:

// ==UserScript==
// @name         GitHub Auto-Expand Project Fields
// @namespace    https://x.com/ArtemR
// @version      1.0
// @description  Automatically expands collapsed custom project fields in the GitHub issue/PR sidebar (workaround for https://github.com/orgs/community/discussions/15592).
// @author       Artem Russakovskii
// @license      MIT
// @match        https://github.com/*/*/issues/*
// @match        https://github.com/*/*/pull/*
// @run-at       document-idle
// @grant        none
// ==/UserScript==

(() => {
  // Remember what we already started so MutationObserver doesn't re-trigger
  // mid-load (for PRs, a second load() aborts the in-flight fetch).
  const started = new Set();
  let path = location.pathname;

  function expand() {
    if (location.pathname !== path) {
      started.clear();
      path = location.pathname;
    }

    // Issues: React sidebar. Prefer structure/icons over English tooltip text.
    for (const section of document.querySelectorAll(
      '[class*="ProjectItemSectionViewContainer"]'
    )) {
      const btn = section.querySelector(
        'button[aria-expanded="false"]:has(.octicon-chevron-down)'
      );
      const key = section.querySelector('a[href*="/projects/"]')?.href;
      if (!btn || !key || started.has(key)) {
        continue;
      }

      started.add(key);
      btn.click();
    }

    // PRs: Catalyst widget. Use load() (fetches fields); setOpen() only flips the chevron.
    for (const widget of document.querySelectorAll(
      "collapsible-sidebar-widget:not([open])"
    )) {
      const key = widget.getAttribute("url");
      if (!key || typeof widget.load !== "function" || started.has(key)) {
        continue;
      }

      started.add(key);
      widget.load();
    }
  }

  new MutationObserver(expand).observe(document.body, {
    childList: true,
    subtree: true,
  });
  expand();
})();