Last active
December 12, 2022 17:13
-
-
Save vallieres/dbdc73ec8b32c451c377bdcbcc95eedb to your computer and use it in GitHub Desktop.
Copy branch name from JIRA webpage 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
// 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