Skip to content

Instantly share code, notes, and snippets.

@sijpkes
Last active May 3, 2017 02:02
Show Gist options
  • Save sijpkes/855b282317ef11acc74e4157fb6fcc45 to your computer and use it in GitHub Desktop.
Save sijpkes/855b282317ef11acc74e4157fb6fcc45 to your computer and use it in GitHub Desktop.
script to clean the mess that Blackboard makes of CSS
var squeaky = squeaky ||
{
filterNone: function () {
return NodeFilter.FILTER_ACCEPT;
},
getCSS: function (rootElem) {
var comments = [];
var iterator = document.createNodeIterator(rootElem, NodeFilter.SHOW_COMMENT, this.filterNone, false);
var curNode;
while (curNode = iterator.nextNode()) {
var comStr = curNode.textContent.trim();
var i = comStr.indexOf('squeaky CSS');
if(i > -1){
comStr = comStr.substr(i+10, comStr.length).trim();
return comStr;
}
}
return false;
}
};
squeaky.el = document.getElementById('squeaky');
var css= squeaky.getCSS(squeaky.el);
// run on load
(function() {
squeaky.style = document.createElement('style');
squeaky.style.type = 'text/css';
var text_node = document.createTextNode(css);
squeaky.style.appendChild(text_node);
squeaky.el.insertBefore(squeaky.style, squeaky.el.firstChild);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment