Skip to content

Instantly share code, notes, and snippets.

@hlship
Last active April 8, 2021 18:44
Show Gist options
  • Save hlship/8300ea44c562ed8a8e7d16c5cde5fa67 to your computer and use it in GitHub Desktop.
Save hlship/8300ea44c562ed8a8e7d16c5cde5fa67 to your computer and use it in GitHub Desktop.
Greasemonkey Script to copy issue number / description to clipboard
// ==UserScript==
// @name Copy JIRA Tag
// @description Copies the text of the JIRA issue number and description to the clipboard
// @version 2
// @grant GM.notification
// @grant GM.setClipboard
// @include https://jira.walmart.com/browse/*
// ==/UserScript==
let key = document.getElementById("key-val")
let summary = document.getElementById("summary-val")
let tag = document.createElement("span")
tag.className = "aui-icon aui-icon-small aui-iconfont-tag"
tag.style = "cursor: pointer"
tag.title = "Click to copy JIRA key/summary to clipboard"
tag.innerHTML = "Copy Issue Tag"
let md = document.createElement("span")
md.className = "aui-icon aui-icon-small aui-iconfont-link"
md.style = "cursor:pointer"
md.title = "Click to copy MarkDown link to clipboard"
md.innerHTML = "Copy Issue Link"
key.parentNode.append(tag)
key.parentNode.append(md)
tag.addEventListener("click", function(me) {
let text = key.textContent.trim() + " - " + summary.textContent.trim()
GM.setClipboard(text)
GM.notification({text: "JIRA tag copied to clipboard"})
})
md.addEventListener("click", function(me) {
let issueId = key.textContent.trim()
let text = "[" + issueId + "](https://jira.walmart.com/browse/" + issueId + ")"
GM.setClipboard(text)
GM.notification({text: "JIRA link copied to clipboard"})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment