-
-
Save ericboehs/18a2f065b3ce4534609566c0b638e6a5 to your computer and use it in GitHub Desktop.
Adds a sidebar link to GitHub issues to redirect you to ZenHub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GitHub to ZenHub Link | |
// @namespace boehs.com | |
// @include *://github.com/*/issues/* | |
// @grant none | |
// @run-at document-ready | |
// ==/UserScript== | |
(() => { | |
const regex = /https:\/\/github\.com\/(.+)\/(.+)\/issues\/(\d+)$/; | |
const input = window.location.href; | |
const match = input.match(regex); | |
if (match) { | |
const org = match[1]; | |
const repo = match[2]; | |
const issueNumber = match[3]; | |
let workspace = localStorage.getItem('zenhubWorkspace'); | |
if (!workspace) { | |
workspace = prompt("Enter your ZenHub workspace name (e.g. backend-team-abc123):"); | |
localStorage.setItem('zenhubWorkspace', workspace); | |
} | |
const url = `https://app.zenhub.com/workspaces/${workspace}/issues/gh/${org}/${repo}/${issueNumber}`; | |
zenhubLinkHtml = '<br /><a href="' + url + '" class="discussion-sidebar-item Link--primary btn-link text-bold no-underline p-0 mt-3"><div style="display: flex; align-items: center;"><svg aria-hidden="true" height="24" viewBox="0 0 24 24" version="1.1" width="24" class="mr-1" stroke="currentColor" fill="none"> <path stroke-linecap="round" stroke-linejoin="round" d="M15.182 16.318A4.486 4.486 0 0012.016 15a4.486 4.486 0 00-3.198 1.318M21 12a9 9 0 11-18 0 9 9 0 0118 0zM9.75 9.75c0 .414-.168.75-.375.75S9 10.164 9 9.75 9.168 9 9.375 9s.375.336.375.75zm-.375 0h.008v.015h-.008V9.75zm5.625 0c0 .414-.168.75-.375.75s-.375-.336-.375-.75.168-.75.375-.75.375.336.375.75zm-.375 0h.008v.015h-.008V9.75z" /></svg><span>Open in ZenHub</span></div></a>' | |
document.querySelector('#partial-discussion-sidebar').insertAdjacentHTML('beforeend', zenhubLinkHtml) | |
} | |
})() |
If you need to change your ZenHub Workspace, delete the zenhubWorkspace key in your browser's local storage (available in your web inspector when viewing a GitHub issue) and it will prompt you again.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Safar Userscript adds a ZenHub link to GitHub's issue sidebar for if you need to move your GitHub issue in your ZenHub pipeline or add an estimate.
It should work in Tampermonkey or other user script extensions in Chrome/FF.
I also updated my ZH to GH Redirector to not redirect if the referrer is from github.com.