Make branch name a link

Makes the branch name in the "merged commit" message a link as well

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Make branch name a link
// @namespace    http://tampermonkey.net/
// @version      2024-02-07
// @description  Makes the branch name in the "merged commit" message a link as well
// @author       Alexander M. Scheurer <[email protected]>
// @match        https://github.com/*/*/pull/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant        GM_addElement
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  let base_ref = document.querySelector(".base-ref");
  if (base_ref === null) return;

  let children = base_ref.children;

  let branch_name = base_ref.innerText;
  let href = `${document.location.href.split("/pull")[0]}/tree/${branch_name}`;

  let a = GM_addElement(base_ref, "a", {
    href,
  });
  for (let child of children) {
    child.remove();
    a.appendChild(child);
  }
})();