Last active
November 26, 2021 15:30
-
-
Save adamturtle/08bde8ee69165b0fc6b7db1a487721d4 to your computer and use it in GitHub Desktop.
Copy Jira issue number to clipboard
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
AJS.$(document).ready(function () { | |
function copyStringToClipboard (str) { | |
var el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style = {position: 'absolute', left: '-9999px'}; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
} | |
window.addEventListener('keydown', function (event) { | |
let jiraIssueSelected = document.querySelector('.ghx-issue.ghx-selected') | |
if (!(event.keyCode == 74 && event.metaKey)) { | |
return | |
} | |
if (!jiraIssueSelected) { | |
return | |
} | |
copyStringToClipboard(jiraIssueSelected.dataset.issueKey) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment