Skip to content

Instantly share code, notes, and snippets.

@pioug
Last active February 5, 2020 09:21
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 pioug/33d2a6a7e1ac8e5c52404cbfee11f2d6 to your computer and use it in GitHub Desktop.
Save pioug/33d2a6a7e1ac8e5c52404cbfee11f2d6 to your computer and use it in GitHub Desktop.
Highlight Zendesk tickets based on their priority
// ==UserScript==
// @name Zendesk Highlight
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Highlight Zendesk tickets based on their priority
// @author Gilles Piou
// @match https://bandlab.zendesk.com/*
// @grant none
// ==/UserScript==
(function() {
"use strict";
const observer = new MutationObserver(mutationRecords => {
mutationRecords.forEach(function(m) {
m.addedNodes.forEach(function(node) {
if (!node.innerText || node.nodeName !== "TR") {
return;
}
if (/\n(\s)*Urgent(\s)*\n/.test(node.innerText)) {
node.style.backgroundColor = "#f48fb1";
} else if (/\n(\s)*High(\s)*\n/.test(node.innerText)) {
node.style.backgroundColor = "#ffab91";
} else if (/\n(\s)*Normal(\s)*\n/.test(m.addedNodes[0].innerText)) {
node.style.backgroundColor = "#fff59d";
} else if (/\n(\s)*Low(\s)*\n/.test(m.addedNodes[0].innerText)) {
node.style.backgroundColor = "#90caf9";
}
});
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment