Skip to content

Instantly share code, notes, and snippets.

@vallieres
Last active December 12, 2022 17:13
Show Gist options
  • Save vallieres/dbdc73ec8b32c451c377bdcbcc95eedb to your computer and use it in GitHub Desktop.
Save vallieres/dbdc73ec8b32c451c377bdcbcc95eedb to your computer and use it in GitHub Desktop.
Copy branch name from JIRA webpage to clipboard
// Create here:
// https://katanya.co.uk/labs/bookmarklet-generator
let jiraIssue = jQuery('a[data-testid="issue.views.issue-base.foundation.breadcrumbs.current-issue.item"] span')[0].textContent.toUpperCase();
let jiraTicketName = jQuery('h1[data-test-id="issue.views.issue-base.foundation.summary.heading"]')[0].textContent;
jiraTicketName = jiraTicketName.toLowerCase().split(" ").join("-").split("/").join("-");
jiraTicketName = jiraTicketName.replace(/[^a-z0-9-_]+/g, '');
let branchName = jiraIssue + "_" + jiraTicketName;
function setClipboard(a) {
var b = document.createElement("textarea"), c = document.getSelection();
b.textContent = a, document.body.appendChild(b), c.removeAllRanges(), b.select(), document.execCommand("copy"), c.removeAllRanges(), document.body.removeChild(b)
}
setClipboard(branchName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment