Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created April 28, 2023 22:51
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 bleonard/723a03e3d47429685e485e6cae3ffc02 to your computer and use it in GitHub Desktop.
Save bleonard/723a03e3d47429685e485e6cae3ffc02 to your computer and use it in GitHub Desktop.
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();
@bleonard
Copy link
Author

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