Skip to content

Instantly share code, notes, and snippets.

@TheophileWalter
Created October 2, 2016 17:03
Show Gist options
  • Save TheophileWalter/6e25e212d6f59635c1ae4b3ea76e6059 to your computer and use it in GitHub Desktop.
Save TheophileWalter/6e25e212d6f59635c1ae4b3ea76e6059 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Comic Sans Killer
// @namespace tw.walter.comicsanskiller
// @version 1
// @grant none
// ==/UserScript==
/*
* Comic Sans Killer
* by Théophile Walter
* https://walter.tw
*/
removeComicSans(document.body, true);
function removeComicSans(d, mark) {
// Browse child nodes
var child = d.childNodes;
for (var i = 0; i < child.length; i++) {
// If Comic Sans
if (typeof child[i].tagName != 'undefined' && isComicSans(child[i])) {
// Remove and mark it
child[i].style.fontFamily = 'Arial';
if (mark && child[i].innerHTML != '') child[i].innerHTML += '&nbsp;<img src="https://walter.tw/cloud/file/fcb0e47daebe2a89a4bcc166e1f07792/cskilled.png" alt="[CSKilled]" style="width:1em;height:1em;display:inline;" />';
// Browse child's child without mark (ovoid double marking for child)
removeComicSans(child[i], false);
} else {
// Browse child's child with mark
removeComicSans(child[i], true);
}
}
}
function isComicSans(el) {
return css(el, 'font-family').toLowerCase().indexOf('comic sans') != - 1;
}
function css(element, property) {
return window.getComputedStyle(element, null).getPropertyValue(property);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment