|
|
@@ -41,6 +41,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
|
|
|
const INPUT_VALUE_ATTRIBUTE_NAME = "data-single-file-input-value";
|
|
|
const LAZY_SRC_ATTRIBUTE_NAME = "data-single-file-lazy-loaded-src";
|
|
|
const STYLESHEET_ATTRIBUTE_NAME = "data-single-file-stylesheet";
|
|
|
+ const DISABLED_NOSCRIPT_ATTRIBUTE_NAME = "data-single-file-disabled-noscript";
|
|
|
const SELECTED_CONTENT_ATTRIBUTE_NAME = "data-single-file-selected-content";
|
|
|
const IGNORED_REMOVED_TAG_NAMES = ["NOSCRIPT", "DISABLED-NOSCRIPT", "META", "LINK", "STYLE", "TITLE", "TEMPLATE", "SOURCE", "OBJECT", "SCRIPT", "HEAD"];
|
|
|
const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
|
|
|
@@ -90,10 +91,10 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
|
|
|
|
|
|
function preProcessDoc(doc, win, options) {
|
|
|
doc.querySelectorAll("script").forEach(element => element.textContent = element.textContent.replace(/<\/script>/gi, "<\\/script>"));
|
|
|
- doc.querySelectorAll("body noscript").forEach(element => {
|
|
|
- const disabledNoscriptElement = doc.createElement("disabled-noscript");
|
|
|
- Array.from(element.childNodes).forEach(node => disabledNoscriptElement.appendChild(node));
|
|
|
- disabledNoscriptElement.hidden = true;
|
|
|
+ doc.querySelectorAll("noscript").forEach(element => {
|
|
|
+ const disabledNoscriptElement = doc.createElement("template");
|
|
|
+ disabledNoscriptElement.setAttribute(DISABLED_NOSCRIPT_ATTRIBUTE_NAME, "");
|
|
|
+ disabledNoscriptElement.innerHTML = element.textContent;
|
|
|
element.parentElement.replaceChild(disabledNoscriptElement, element);
|
|
|
});
|
|
|
initDoc(doc);
|
|
|
@@ -309,9 +310,9 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
|
|
|
}
|
|
|
|
|
|
function postProcessDoc(doc, markedElements) {
|
|
|
- doc.querySelectorAll("disabled-noscript").forEach(element => {
|
|
|
+ doc.querySelectorAll("[" + DISABLED_NOSCRIPT_ATTRIBUTE_NAME + "]").forEach(element => {
|
|
|
const noscriptElement = doc.createElement("noscript");
|
|
|
- Array.from(element.childNodes).forEach(node => noscriptElement.appendChild(node));
|
|
|
+ noscriptElement.textContent = element.innerHTML;
|
|
|
element.parentElement.replaceChild(noscriptElement, element);
|
|
|
});
|
|
|
doc.querySelectorAll("meta[disabled-http-equiv]").forEach(element => {
|