Skip to content

Instantly share code, notes, and snippets.

@rsc-awhite
Created June 26, 2017 01:24
Show Gist options
  • Save rsc-awhite/90f11a3d0d07a17e5ed6aecaf99def95 to your computer and use it in GitHub Desktop.
Save rsc-awhite/90f11a3d0d07a17e5ed6aecaf99def95 to your computer and use it in GitHub Desktop.
/*
# Author: Andrew White
# Last updated: 26/06/2017
# Purpose: Overrides generic icons in Munki update page depending on regex match.
*/
// Future version probably has proper functions, icon array, nicer regex matches
dir = "custom/resources/"
apple_icon = dir + "macos-update.png";
xerox_icon = dir + "xerox.png";
window.onload=function() {
updateIcons();
console.log("RSC custom onload running");
}
function updateIcons() {
updateIcon("^macOS(.*)Update$", apple_icon);
updateIcon("^Fuji Xerox Printer Software Update", xerox_icon);
}
function updateIcon(regex, icon) {
artwork = document.getElementsByClassName("artwork");
for (x=0;x<artwork.length;x++) {
if (artwork[x].tagName == "IMG") {
name = artwork[x].alt;
re = new RegExp(regex);
if (re.test(name)) {
document.getElementsByClassName("artwork")[x].src = icon;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment