Github See Your Closed PRs

See PRs you created that are merged or closed

  1. // ==UserScript==
  2. // @name Github See Your Closed PRs
  3. // @namespace happyviking
  4. // @version 1.1.0
  5. // @description See PRs you created that are merged or closed
  6. // @author HappyViking
  7. // @match https://github.com/*
  8. // @run-at document-end
  9. // @license MIT
  10. // @require https://unpkg.com/bundled-github-url-detector@1.0.0/index.js
  11. // ==/UserScript==
  12.  
  13. const gh = githubUrlDetection
  14.  
  15. const addClosedButton = () => {
  16. if (!gh.isPRList()) return
  17. const username = gh.utils.getUsername()
  18. if (!username) return
  19. const toolbar = document.getElementById("js-issues-toolbar")
  20. if (!toolbar) return
  21. const query = toolbar.getElementsByClassName("table-list-header-toggle");
  22. if (query.length == 0) return
  23. const buttonParent = query[0]
  24.  
  25. const button = document.createElement("a")
  26. button.classList.add("btn-link")
  27. button.textContent = "Closed (yours)"
  28. button.href = encodeURI("https://"
  29. + window.location.hostname
  30. + window.location.pathname
  31. + `?q=is:pr+is:closed+author:${username}`)
  32. buttonParent.append(button)
  33. }
  34.  
  35. addClosedButton()
  36. document.addEventListener("soft-nav:end", addClosedButton);
  37. document.addEventListener("navigation:end", addClosedButton);