Last active
July 30, 2025 18:29
-
-
Save wjkennedy/c88014897bff5b144d7f2276602936c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function () { | |
| function addCopyButton(container, keyText) { | |
| // Prevent duplicate buttons | |
| if (container.querySelector('.copy-issue-key-btn')) return; | |
| const button = document.createElement('button'); | |
| button.textContent = 'Copy'; | |
| button.className = 'copy-issue-key-btn'; | |
| button.style.marginLeft = '8px'; | |
| button.style.cursor = 'pointer'; | |
| button.style.border = '1px solid #ccc'; | |
| button.style.background = '#f4f5f7'; | |
| button.style.fontSize = '11px'; | |
| button.style.padding = '2px 6px'; | |
| button.style.borderRadius = '3px'; | |
| button.onclick = () => { | |
| navigator.clipboard.writeText(keyText).then(() => { | |
| button.textContent = 'Copied!'; | |
| setTimeout(() => (button.textContent = 'Copy'), 2000); | |
| }).catch((err) => { | |
| console.error('Copy failed', err); | |
| alert('Failed to copy'); | |
| }); | |
| }; | |
| container.appendChild(button); | |
| } | |
| function injectCopyButtons() { | |
| // Issue View | |
| const issueKeyElem = document.querySelector('[data-testid="issue.views.issue-base.foundation.breadcrumbs.breadcrumb-current-issue-container"]'); | |
| if (issueKeyElem) { | |
| const keyText = issueKeyElem.textContent.trim(); | |
| addCopyButton(issueKeyElem, keyText); | |
| } | |
| // List View (search results) | |
| const listElems = document.querySelectorAll('[data-testid="business-list.ui.list-view.key-cell.issue-key"]'); | |
| listElems.forEach(elem => { | |
| const keyText = elem.textContent.trim(); | |
| addCopyButton(elem, keyText); | |
| }); | |
| } | |
| // Observe DOM changes (SPA navigation) | |
| const observer = new MutationObserver((mutations) => { | |
| mutations.forEach(() => { | |
| injectCopyButtons(); | |
| }); | |
| }); | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| // Initial run | |
| injectCopyButtons(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment