Add javascript to remove styling from articles. Issues ##499, #999, and #947

This commit is contained in:
Maurice Parker 2019-09-17 14:32:18 -05:00
parent 66d9333999
commit 8a8dcde387
1 changed files with 17 additions and 1 deletions

View File

@ -333,6 +333,9 @@ private extension ArticleRenderer {
anchors[i].addEventListener("mouseenter", function() { mouseDidEnterLink(this) });
anchors[i].addEventListener("mouseleave", function() { mouseDidExitLink(this) });
}
document.getElementsByTagName("body")[0].querySelectorAll("style, link[rel=stylesheet]").forEach(element => element.remove());
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
}
function mouseDidEnterLink(anchor) {
@ -367,7 +370,20 @@ private extension ArticleRenderer {
s += "<meta name=\"viewport\" content=\"width=device-width\">\n"
s += title.htmlBySurroundingWithTag("title")
s += styleString().htmlBySurroundingWithTag("style")
s += "\n\n</head><body>\n\n"
s += """
<script type="text/javascript">
function startup() {
document.getElementsByTagName("body")[0].querySelectorAll("style, link[rel=stylesheet]").forEach(element => element.remove());
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
}
</script>
"""
s += "\n\n</head><body onload='startup()'>\n\n"
s += body
s += "\n\n</body></html>"