Make branch name a link

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

  1. // ==UserScript==
  2. // @name Make branch name a link
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-02-07
  5. // @description Makes the branch name in the "merged commit" message a link as well
  6. // @author Alexander M. Scheurer <ams@patentrenewal.com>
  7. // @match https://github.com/*/*/pull/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @grant GM_addElement
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. let base_ref = document.querySelector(".base-ref");
  17. if (base_ref === null) return;
  18.  
  19. let children = base_ref.children;
  20.  
  21. let branch_name = base_ref.innerText;
  22. let href = `${document.location.href.split("/pull")[0]}/tree/${branch_name}`;
  23.  
  24. let a = GM_addElement(base_ref, "a", {
  25. href,
  26. });
  27. for (let child of children) {
  28. child.remove();
  29. a.appendChild(child);
  30. }
  31. })();