Last active
May 3, 2017 02:02
-
-
Save sijpkes/855b282317ef11acc74e4157fb6fcc45 to your computer and use it in GitHub Desktop.
script to clean the mess that Blackboard makes of CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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