Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Created July 17, 2020 22:48
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 23maverick23/9e9d1b4c412123a291ba5c8b42095194 to your computer and use it in GitHub Desktop.
Save 23maverick23/9e9d1b4c412123a291ba5c8b42095194 to your computer and use it in GitHub Desktop.
OA: Fix timesheet exception bug (Tampermonkey)
// ==UserScript==
// @name DEMO: Hide OpenAir schedule exception icons (bug workaround; 17 Jul 2020)
// @namespace http://rymo.io/
// @version 0.1
// @description DEMO: Hides all schedule exception icons on the timesheet.
// @author @rymoio
// @match https://demo.openair.com/timesheet.pl?*
// @run-at document-idle
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener('load', function() {
console.log("DEBUG >>> Greasemonkey script start...");
// callback executed when canvas was found
function handleElem(elem) {
var klassName = "scheduleException";
var elems = document.getElementsByClassName(klassName);
for (var i=0, len=elems.length|0; i<len; i=i+1|0) {
elems[i].style.display = "none";
console.log(`Hiding ${i+1} icon${i ? "s" : ""}`);
}
}
// set up the mutation observer
var observer = new MutationObserver(function (mutations, me) {
// `mutations` is an array of mutations that occurred
// `me` is the MutationObserver instance
var elem = document.getElementById('timesheet_header_lower');
if (elem) {
handleElem(elem);
me.disconnect(); // stop observing
console.log("DEBUG >>> Greasemonkey script end.");
return;
}
});
// start observing
observer.observe(document, {
childList: true,
subtree: true
});
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment