Skip to content

Instantly share code, notes, and snippets.

@SandyGifford
Last active July 12, 2022 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SandyGifford/17038e4780271a5063d0e9217bd08841 to your computer and use it in GitHub Desktop.
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
(() => {
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!");
});
})();
@SandyGifford
Copy link
Author

linear.ticket.list.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment