Last active
April 24, 2023 07:55
-
-
Save luqasn/49c4e68cc23fa529d79d9d1466dc0760 to your computer and use it in GitHub Desktop.
Zendesk Timestamp Copy Helper
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
// ==UserScript== | |
// @name Zendesk Timestamp Copier | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Lucas Romero | |
// @match https://*.zendesk.com/agent/tickets/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=zendesk.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
(new MutationObserver(check)).observe(document, {childList: true, subtree: true}); | |
function check(changes, observer) { | |
const highlightedItems = document.querySelectorAll("time[dateTime]"); | |
highlightedItems.forEach((userItem) => { | |
const parent = userItem.parentElement; | |
if (parent.childElementCount > 1) { | |
return; | |
} | |
var a = document.createElement('a'); | |
a.style.padding = ".5rem"; | |
var linkText = document.createTextNode("(copy)"); | |
a.appendChild(linkText); | |
a.href = "#"; | |
a.addEventListener("click", function(e){ | |
e.preventDefault(); | |
navigator.clipboard.writeText(userItem.getAttribute("dateTime")); | |
}); | |
parent.insertBefore(a, userItem.nextSibling) | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment