Skip to content

Instantly share code, notes, and snippets.

@betodealmeida
Created June 12, 2024 20:26
Show Gist options
  • Save betodealmeida/af4c4d07be826233789c63ca44a70463 to your computer and use it in GitHub Desktop.
Save betodealmeida/af4c4d07be826233789c63ca44a70463 to your computer and use it in GitHub Desktop.
<script>
<![CDATA[
/*
* Firefox doesn't support `disable-output-escaping="yes"`,
* so we need to unescape the HTML content manually.
*
* See this bug ticket from 2001 (!): https://bugzilla.mozilla.org/show_bug.cgi?id=98168
*/
function isFirefox() {
return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
}
function unescapeHTML(escapedHTML) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = escapedHTML;
return tempDiv.textContent || tempDiv.innerText || "";
}
addEventListener("DOMContentLoaded", function() {
if (isFirefox()) {
const divElements = document.querySelectorAll('div.e-content');
divElements.forEach(div => {
const escapedHTML = div.innerHTML;
const unescapedHTML = unescapeHTML(escapedHTML);
div.innerHTML = unescapedHTML;
});
}
});
]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment