Преглед изворни кода

added hidden option "insertMetaNoIndex"

Gildas пре 5 година
родитељ
комит
ec028c7a73
2 измењених фајлова са 13 додато и 1 уклоњено
  1. 2 1
      extension/core/bg/config.js
  2. 11 0
      lib/single-file/single-file-core.js

+ 2 - 1
extension/core/bg/config.js

@@ -95,7 +95,8 @@ singlefile.extension.core.bg.config = (() => {
 		saveFavicon: true,
 		includeBOM: false,
 		warnUnsavedPage: true,
-		autoSaveExternalSave: false
+		autoSaveExternalSave: false,
+		insertMetaNoIndex: false
 	};
 
 	let configStorage;

+ 11 - 0
lib/single-file/single-file-core.js

@@ -479,6 +479,15 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					canonicalLink.href = this.options.saveUrl;
 				}
 			}
+			if (this.options.insertMetaNoIndex) {
+				let metaElement = this.doc.querySelector("meta[name=robots][content*=noindex]");
+				if (!metaElement) {
+					metaElement = this.doc.createElement("meta");
+					metaElement.setAttribute("name", "robots");
+					metaElement.setAttribute("content", "noindex");
+					this.doc.head.appendChild(metaElement);
+				}
+			}
 			let size;
 			if (this.options.displayStats) {
 				size = util.getContentSize(this.doc.documentElement.outerHTML);
@@ -986,6 +995,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			async function initializeProcessor(frameData, frameElement, frameWindowId, batchRequest, options) {
 				options.insertSingleFileComment = false;
 				options.insertCanonicalLink = false;
+				options.insertMetaNoIndex = false;
 				options.saveFavicon = false;
 				options.url = frameData.baseURI;
 				options.windowId = frameWindowId;
@@ -1072,6 +1082,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				const options = Object.create(this.options);
 				options.insertSingleFileComment = false;
 				options.insertCanonicalLink = false;
+				options.insertMetaNoIndex = false;
 				options.saveFavicon = false;
 				options.removeUnusedStyles = false;
 				options.removeAlternativeMedias = false;