Add CircleCI Workflows Link

現在のブランチにおける CircleCI Workflows ページへのリンクを追加する

  1. // ==UserScript==
  2. // @name Add CircleCI Workflows Link
  3. // @namespace https://github.com/matzkoh
  4. // @version 1.0.2
  5. // @description 現在のブランチにおける CircleCI Workflows ページへのリンクを追加する
  6. // @author matzkoh
  7. // @match https://github.com/*/*/pull/*
  8. // ==/UserScript==
  9.  
  10. function $b64d7b61b1022cc4$export$f22da7240b7add18(path, rule) {
  11. const matches = path.match(rule.match)
  12. const userName = rule.getUserName(matches)
  13. const repoName = rule.getRepoName(matches)
  14. const branchName = rule.getBranchName(matches)
  15. const btn = document.createElement('a')
  16. btn.textContent = 'CircleCI Workflows'
  17. btn.href = `https://app.circleci.com/pipelines/github/${userName}/${repoName}?branch=${encodeURIComponent(
  18. branchName,
  19. )}`
  20. btn.target = '_blank'
  21. btn.style.display = 'inline-block'
  22. btn.style.height = '20px'
  23. btn.style.lineHeight = '20px'
  24. btn.style.paddingLeft = '20px'
  25. btn.style.background = 'url("https://avatars0.githubusercontent.com/ml/7?s=16") left center no-repeat'
  26. rule.insertButton(btn)
  27. }
  28.  
  29. const $ac3fdcd981491f74$var$rules = [
  30. {
  31. // プルリク
  32. match: /([^/]+)\/(([^/]+))\/pull\//,
  33. getUserName(matches) {
  34. return matches[1]
  35. },
  36. getRepoName(matches) {
  37. return matches[2]
  38. },
  39. getBranchName() {
  40. return document.querySelector('clipboard-copy[value]').value
  41. },
  42. insertButton(btn) {
  43. const sidebar = document.getElementById('partial-discussion-sidebar')
  44. const sidebarItem = document.createElement('div')
  45. sidebarItem.className = 'discussion-sidebar-item'
  46. const header = document.createElement('div')
  47. header.className = 'discussion-sidebar-heading text-bold'
  48. header.textContent = 'CircleCI'
  49. sidebarItem.appendChild(header)
  50. btn.classList.add('text-inherit')
  51. btn.classList.add('text-bold')
  52. btn.textContent = 'Workflows'
  53. sidebarItem.appendChild(btn)
  54. sidebar.insertBefore(sidebarItem, sidebar.firstChild)
  55. },
  56. },
  57. ]
  58. const { pathname: $ac3fdcd981491f74$var$path } = location
  59. const $ac3fdcd981491f74$var$rule = $ac3fdcd981491f74$var$rules.find(({ match: match }) =>
  60. match.test($ac3fdcd981491f74$var$path),
  61. )
  62. if ($ac3fdcd981491f74$var$rule)
  63. (0, $b64d7b61b1022cc4$export$f22da7240b7add18)($ac3fdcd981491f74$var$path, $ac3fdcd981491f74$var$rule)