Created
April 28, 2023 22:51
-
-
Save bleonard/723a03e3d47429685e485e6cae3ffc02 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 getItem() { | |
let node, text; | |
let output = ""; | |
let labels = ['roadmap']; | |
node = document.querySelector(".mat-dialog-content .roadmap-project-header-first-line"); | |
text = node.innerText; | |
output += "\nTitle: [Roadmap] " + text | |
const lines = document.querySelectorAll(".key-value-line"); | |
let team = null; | |
let objective = null; | |
for(let i=0; i<lines.length; i++) { | |
const line = lines[i]; | |
const label = line.querySelector(".key").innerText; | |
const value = line.querySelector(".value").innerText; | |
if(label === "Team") { | |
team = value; | |
} | |
if(label === "Objective") { | |
objective = value; | |
} | |
} | |
output += "\nObjective: " + objective; | |
output += "\nTeam: " + team; | |
node = document.querySelector(".mat-dialog-content .prop-content"); | |
text = node.innerText; | |
output += "\n\nDescription:\n" + text | |
output += "\n\nLabels: " + labels.join(", ") | |
node = document.querySelector(".mat-dialog-content"); | |
node.focus(); | |
return output + "\n\n\n"; | |
} | |
function updatePage() { | |
const node = document.querySelector(".iconhx-rightbar"); | |
if(!node) return; | |
const toolbar = node?.parentElement?.parentElement; | |
if(!toolbar) return; | |
const found = toolbar.querySelector(".exporter"); | |
if (found) return; | |
const button = document.createElement("button"); | |
button.className = "exporter"; | |
button.innerText = "Export to Clipboard"; | |
button.addEventListener("click", function () { | |
const issue = getItem(); | |
console.log(issue); | |
navigator.clipboard.writeText(issue); | |
}); | |
toolbar.appendChild(button); | |
} | |
// Select the node that will be observed for mutations | |
const targetNode = document.body; | |
const config = { attributes: true, childList: true, subtree: true }; | |
const callback = (mutationList, observer) => { | |
updatePage(); | |
}; | |
const observer = new MutationObserver(callback); | |
observer.observe(targetNode, config); | |
// do it now if it's there | |
updatePage(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.loom.com/share/63cda9782c244fcb8e4a3e91762d7019