Browse Source

Add workaround .innerHTML stripping <script> tags

master
Carlos Mogas da Silva 5 months ago
parent
commit
f708d7ff7e
  1. 16
      hugo_enc/decoder_script.js

16
hugo_enc/decoder_script.js

@ -64,7 +64,23 @@ window.onload = () => {
let parent = elements[index];
let encrypted = parent.querySelector(".hugo-enc-cipher-text").innerText.trim();
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;
// 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…
Cancel
Save