2026.3.0
This commit is contained in:
commit
fea86725ab
4 files changed
+115
No files matched your search
@@ -0,0 +1,40 @@
|
||||
$(function() {
|
||||
// Only run on issue show page
|
||||
const regex = /^\/issues\/\d+/;
|
||||
if (regex.test(window.location.pathname)) {
|
||||
|
||||
//search for the span element that contains the text "Mileage" and get its parent element's class name
|
||||
const allSpans = document.querySelectorAll('span');
|
||||
const wantedSpan = [...allSpans].find(el => el.textContent.includes('Mileage'));
|
||||
const element = wantedSpan.parentElement.parentElement.className;
|
||||
console.log(element);
|
||||
|
||||
// Get the first child element of the element with the class name and add a click event listener to it
|
||||
const firstElement = document.getElementsByClassName(element)[0].children[1];
|
||||
if (firstElement) {
|
||||
firstElement.addEventListener('click', function() {
|
||||
try {
|
||||
const text = firstElement.innerText;
|
||||
|
||||
// If the text is already "Copied!", don't do anything
|
||||
if (text == "Copied!") {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(text);
|
||||
|
||||
firstElement.innerHTML = "<b>Copied!</b>";
|
||||
firstElement.style.color = "#4CAF50"; // Turn green
|
||||
|
||||
setTimeout(() => {
|
||||
firstElement.innerText = text;
|
||||
firstElement.style.color = "";
|
||||
}, 2000);
|
||||
|
||||
} catch (err) {
|
||||
console.error('Unable to copy', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user