GitHub: involved issues

Make the Pulls and Issues links show your involved issues

当前为 2016-11-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub: involved issues
  3. // @namespace https://akinori.org
  4. // @description Make the Pulls and Issues links show your involved issues
  5. // @license 2-clause BSDL
  6. // @author Akinori MUSHA
  7. // @include https://github.com/*
  8. // @version 0.9.9
  9. // @homepage https://github.com/knu/userjs-github_involved_issues
  10. // @grant none
  11.  
  12. // ==/UserScript==
  13. "use strict";
  14. (function () {
  15. const meta = document.querySelector("meta[name=user-login]")
  16.  
  17. if (!meta)
  18. return
  19.  
  20. const user = meta.content
  21. const encode = function (decoded) {
  22. return encodeURIComponent(decoded).replace(/%20/g, "+")
  23. }
  24.  
  25. const links = document.querySelectorAll(".header-nav-link")
  26. for (let i = 0; i < links.length; i++) {
  27. const href = links[i].getAttribute("href")
  28. switch (href) {
  29. case "/pulls":
  30. links[i].setAttribute("href", href + "?q=" + encode("is:open is:pr involves:" + user))
  31. break
  32. case "/issues":
  33. links[i].setAttribute("href", href + "?q=" + encode("is:open is:issue involves:" + user))
  34. break
  35. }
  36. }
  37. })();