Last active
October 2, 2021 20:35
-
-
Save kkoziarski/f861ba884f6e6faa0a0831c0d2f22b7c to your computer and use it in GitHub Desktop.
Copy JIRA issue number bookmarklet
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
javascript: (function() { | |
var id; | |
var descr; | |
var a = document.querySelector('#ghx-detail-issue .ghx-group .ghx-key dl.ghx-detail-list dd a'); | |
if (a) { | |
/*side details*/ | |
id = a.textContent; | |
descr = document.querySelector('#ghx-detail-issue .ghx-group .ghx-detail-summary dl.ghx-detail-list dd.ghx-detail-description').textContent; | |
} else if (a = document.getElementById("key-val")) { | |
/*full page details*/ | |
id = a.textContent; | |
descr = document.querySelector('#summary-val').textContent; | |
} else { | |
var qsParam = getQueryStringParameterByName('selectedIssue'); | |
if (qsParam) { | |
descr = document.querySelector('#summary-val').textContent; | |
id = qsParam; | |
} | |
} | |
if (id) { | |
/*window.prompt("Copy to clipboard: Ctrl+C, Enter", id);*/ | |
sendToClipbord(id + ' ' + (descr || '')); | |
} | |
function sendToClipbord(myString) { | |
var textarea = document.createElement('textarea'); | |
document.body.appendChild(textarea); | |
textarea.value = myString; | |
textarea.style.position = 'fixed'; | |
textarea.focus(); | |
textarea.select(); | |
document.execCommand('Copy'); | |
textarea.remove(); | |
} | |
function getQueryStringParameterByName(name, url) { | |
if (!url) url = window.location.href; | |
name = name.replace(/[\[\]]/g, "\\$&"); | |
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
results = regex.exec(url); | |
if (!results) return null; | |
if (!results[2]) return ''; | |
return decodeURIComponent(results[2].replace(/\+/g, " ")); | |
} | |
})(); |
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
javascript: (function() { | |
var id; | |
var a = document.querySelector('#ghx-detail-issue .ghx-group .ghx-key dl.ghx-detail-list dd a'); | |
if (a) { | |
id = a.textContent; | |
} else if (a = document.getElementById("key-val")) { | |
id = a.textContent; | |
} else { | |
var qsParam = getQueryStringParameterByName('selectedIssue'); | |
if (qsParam) { | |
id = qsParam; | |
} | |
} | |
if (id) { | |
/*window.prompt("Copy to clipboard: Ctrl+C, Enter", id);*/ | |
sendToClipbord(id); | |
} | |
function sendToClipbord(myString) { | |
var textarea = document.createElement('textarea'); | |
document.body.appendChild(textarea); | |
textarea.value = myString; | |
textarea.style.position = 'fixed'; | |
textarea.focus(); | |
textarea.select(); | |
document.execCommand('Copy'); | |
textarea.remove(); | |
} | |
function getQueryStringParameterByName(name, url) { | |
if (!url) url = window.location.href; | |
name = name.replace(/[\[\]]/g, "\\$&"); | |
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
results = regex.exec(url); | |
if (!results) return null; | |
if (!results[2]) return ''; | |
return decodeURIComponent(results[2].replace(/\+/g, " ")); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think there is a small typo athttps://gist.github.com/kkoziarski/f861ba884f6e6faa0a0831c0d2f22b7c#file-jira-copy-id-bookmarklet-js-L9
should be