Last active
July 12, 2022 14:02
-
-
Save SandyGifford/17038e4780271a5063d0e9217bd08841 to your computer and use it in GitHub Desktop.
Adds a button to Linear which, when clicked, copies a markdown list of all checked tickets to the clipboard
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
(() => { | |
const BUTTON_CLASS_NAME = "getTicketListButton"; | |
document.querySelectorAll(`.${BUTTON_CLASS_NAME}`).forEach((btn) => btn.parentElement?.removeChild(btn)); | |
const btn = document.createElement("button"); | |
document.body.append(btn); | |
btn.className = BUTTON_CLASS_NAME; | |
btn.style.position = "fixed"; | |
btn.style.bottom = "10px"; | |
btn.style.right = "10px"; | |
btn.style.padding = "10px 20px"; | |
btn.style.background = "#334"; | |
btn.style.color = "white"; | |
btn.style.fontWeight = "bold"; | |
btn.style.border = "none"; | |
btn.style.borderRadius = "10px"; | |
btn.style.fontSize = "20px"; | |
btn.style.zIndex = "1"; | |
btn.textContent = "Copy ticket list to clipboard"; | |
btn.addEventListener("click", async () => { | |
const message = Array.from(document.querySelectorAll("a[href^='/reclaim/issue/RAI-']")) | |
.map((a) => { | |
if (!a.querySelector("input[checked]")?.checked) return; | |
const title = a.querySelector("span[color='labelTitle']")?.textContent; | |
const url = new URL(a.href).href; | |
const [ticketNum] = a.href.match(/(RAI-\d+)/); | |
return `- ${title} ([${ticketNum}](${url}))`; | |
}) | |
.filter((i) => !!i) | |
.join("\n"); | |
await navigator.clipboard.writeText(message); | |
alert("copied!"); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
linear.ticket.list.mov