Port inline style stripping changes from master

This commit is contained in:
Nate Weaver 2020-02-28 08:15:06 -06:00
parent 85bd20ca80
commit 65b508ffaa
1 changed files with 7 additions and 1 deletions

View File

@ -324,6 +324,12 @@ private extension ArticleRenderer {
s += """
<script type="text/javascript">
function stripStylesFromElement(element, propertiesToStrip) {
for (name of propertiesToStrip) {
element.style.removeProperty(name);
}
}
var init = {
wrapFrames: function () {
document.querySelectorAll("iframe").forEach(element => {
@ -335,7 +341,7 @@ private extension ArticleRenderer {
},
stripStyles: function() {
document.getElementsByTagName("body")[0].querySelectorAll("style, link[rel=stylesheet]").forEach(element => element.remove());
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => stripStylesFromElement(element, ["color", "background", "font"]));
},
linkHover: function() {
var anchors = document.getElementsByTagName("a");