Forked from kkoziarski/jira-copy-description-bookmarklet.js
Created
August 24, 2021 12:39
-
-
Save BenjaminHerbert/66fba4ce27bf124585c587bcf91bab1d 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