Add workaround .innerHTML stripping <script> tags
This commit is contained in:
parent
e5ac232d3e
commit
f708d7ff7e
1 changed files with 16 additions and 0 deletions
|
@ -64,7 +64,23 @@ window.onload = () => {
|
||||||
let parent = elements[index];
|
let parent = elements[index];
|
||||||
let encrypted = parent.querySelector(".hugo-enc-cipher-text").innerText.trim();
|
let encrypted = parent.querySelector(".hugo-enc-cipher-text").innerText.trim();
|
||||||
let decrypted = _do_decrypt(encrypted, password);
|
let decrypted = _do_decrypt(encrypted, password);
|
||||||
|
|
||||||
|
// Workaround .innerHTML stripping <script> tags
|
||||||
|
// First we save all the script tags
|
||||||
|
re = /<script.*?<\/script>/;
|
||||||
|
script_tags = re.exec(decrypted);
|
||||||
|
|
||||||
elements[index].innerHTML = decrypted;
|
elements[index].innerHTML = decrypted;
|
||||||
|
|
||||||
|
// Now we add all script tags back into the html element
|
||||||
|
html_element = document.getElementsByTagName("html")[0];
|
||||||
|
range = document.createRange();
|
||||||
|
range.setStart(html_element, 0);
|
||||||
|
script_tags.forEach(tag => {
|
||||||
|
html_element.appendChild(range.createContextualFragment(tag));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue