Skip to content

Instantly share code, notes, and snippets.

@adamturtle
Last active November 26, 2021 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamturtle/08bde8ee69165b0fc6b7db1a487721d4 to your computer and use it in GitHub Desktop.
Save adamturtle/08bde8ee69165b0fc6b7db1a487721d4 to your computer and use it in GitHub Desktop.
Copy Jira issue number to clipboard
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