Răsfoiți Sursa

renamed common.js to docHelper.js

Gildas 7 ani în urmă
părinte
comite
be56406310

+ 2 - 2
extension/core/content/content-frame.js

@@ -18,14 +18,14 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-/* global browser, window, top, document, common */
+/* global browser, window, top, document, docHelper */
 
 
 this.singlefile.frame = this.singlefile.frame || (() => {
 this.singlefile.frame = this.singlefile.frame || (() => {
 
 
 	if (window != top) {
 	if (window != top) {
 		browser.runtime.onMessage.addListener(async message => {
 		browser.runtime.onMessage.addListener(async message => {
 			if (message.processStart) {
 			if (message.processStart) {
-				message.options.content = common.getDoctype(document) + document.documentElement.outerHTML;
+				message.options.content = docHelper.getDoctype(document) + document.documentElement.outerHTML;
 				message.options.frameId = null;
 				message.options.frameId = null;
 				message.options.url = document.location.href;
 				message.options.url = document.location.href;
 				top.postMessage("__SingleFile__::" + JSON.stringify(message), "*");
 				top.postMessage("__SingleFile__::" + JSON.stringify(message), "*");

+ 1 - 1
lib/single-file/common.js → lib/single-file/docHelper.js

@@ -18,7 +18,7 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-this.common = this.common || (() => {
+this.docHelper = this.docHelper || (() => {
 
 
 	const REMOVED_CONTENT_ATTRIBUTE_NAME = "data-single-file-removed-content";
 	const REMOVED_CONTENT_ATTRIBUTE_NAME = "data-single-file-removed-content";
 	const PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME = "data-single-file-preserved-space-element";
 	const PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME = "data-single-file-preserved-space-element";

+ 11 - 11
lib/single-file/frame-tree/content/frame-tree.js

@@ -18,7 +18,7 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-/* global browser, window, top, document, HTMLHtmlElement, addEventListener, common */
+/* global browser, window, top, document, HTMLHtmlElement, addEventListener, docHelper */
 
 
 this.FrameTree = this.FrameTree || (() => {
 this.FrameTree = this.FrameTree || (() => {
 
 
@@ -44,18 +44,18 @@ this.FrameTree = this.FrameTree || (() => {
 	}
 	}
 	browser.runtime.onMessage.addListener(message => {
 	browser.runtime.onMessage.addListener(message => {
 		if (message.method == "FrameTree.getDataRequest" && FrameTree.windowId == message.windowId) {
 		if (message.method == "FrameTree.getDataRequest" && FrameTree.windowId == message.windowId) {
-			common.preProcessDoc(document, window, message.options);
+			docHelper.preProcessDoc(document, window, message.options);
 			browser.runtime.sendMessage({
 			browser.runtime.sendMessage({
 				method: "FrameTree.getDataResponse",
 				method: "FrameTree.getDataResponse",
 				windowId: message.windowId,
 				windowId: message.windowId,
 				tabId: message.tabId,
 				tabId: message.tabId,
-				content: common.getDoctype(document) + document.documentElement.outerHTML,
-				emptyStyleRulesText: common.getEmptyStyleRulesText(document),
-				canvasData: common.getCanvasData(document),
+				content: docHelper.getDoctype(document) + document.documentElement.outerHTML,
+				emptyStyleRulesText: docHelper.getEmptyStyleRulesText(document),
+				canvasData: docHelper.getCanvasData(document),
 				baseURI: document.baseURI,
 				baseURI: document.baseURI,
 				title: document.title
 				title: document.title
 			}).catch(() => {/* ignored */ });
 			}).catch(() => {/* ignored */ });
-			common.postProcessDoc(document, message.options);
+			docHelper.postProcessDoc(document, message.options);
 		}
 		}
 	});
 	});
 	addEventListener("message", event => {
 	addEventListener("message", event => {
@@ -163,12 +163,12 @@ this.FrameTree = this.FrameTree || (() => {
 					const message = JSON.parse(event.data.substring(MESSAGE_PREFIX.length + 2));
 					const message = JSON.parse(event.data.substring(MESSAGE_PREFIX.length + 2));
 					if (message.method == "getDataRequest" && message.windowId == frameWinId) {
 					if (message.method == "getDataRequest" && message.windowId == frameWinId) {
 						topWindow.removeEventListener("message", onMessage, false);
 						topWindow.removeEventListener("message", onMessage, false);
-						common.preProcessDoc(frameDoc, frameWindow, message.options);
-						const content = common.getDoctype(frameDoc) + frameDoc.documentElement.outerHTML;
-						const emptyStyleRulesText = common.getEmptyStyleRulesText(frameDoc);
-						const canvasData = common.getCanvasData(frameDoc);
+						docHelper.preProcessDoc(frameDoc, frameWindow, message.options);
+						const content = docHelper.getDoctype(frameDoc) + frameDoc.documentElement.outerHTML;
+						const emptyStyleRulesText = docHelper.getEmptyStyleRulesText(frameDoc);
+						const canvasData = docHelper.getCanvasData(frameDoc);
 						top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "getDataResponse", windowId: message.windowId, content, baseURI: frameDoc.baseURI, title: document.title, emptyStyleRulesText, canvasData }), "*");
 						top.postMessage(MESSAGE_PREFIX + "::" + JSON.stringify({ method: "getDataResponse", windowId: message.windowId, content, baseURI: frameDoc.baseURI, title: document.title, emptyStyleRulesText, canvasData }), "*");
-						common.postProcessDoc(frameDoc, frameWindow, message.options);
+						docHelper.postProcessDoc(frameDoc, frameWindow, message.options);
 					}
 					}
 				}
 				}
 			}
 			}

+ 5 - 5
lib/single-file/single-file-browser.js

@@ -18,7 +18,7 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-/* global SingleFileCore, base64, DOMParser, TextDecoder, fetch, superFetch, parseSrcset, uglifycss, htmlmini, rulesMinifier, lazyLoader, serializer, common */
+/* global SingleFileCore, base64, DOMParser, TextDecoder, fetch, superFetch, parseSrcset, uglifycss, htmlmini, rulesMinifier, lazyLoader, serializer, docHelper */
 
 
 this.SingleFile = this.SingleFile || (() => {
 this.SingleFile = this.SingleFile || (() => {
 
 
@@ -135,19 +135,19 @@ this.SingleFile = this.SingleFile || (() => {
 		}
 		}
 
 
 		static preProcessDoc(doc, win, options) {
 		static preProcessDoc(doc, win, options) {
-			common.preProcessDoc(doc, win, options);
+			docHelper.preProcessDoc(doc, win, options);
 		}
 		}
 
 
 		static postProcessDoc(doc, options) {
 		static postProcessDoc(doc, options) {
-			common.postProcessDoc(doc, options);
+			docHelper.postProcessDoc(doc, options);
 		}
 		}
 
 
 		static getEmptyStyleRulesText(doc) {
 		static getEmptyStyleRulesText(doc) {
-			return common.getEmptyStyleRulesText(doc);
+			return docHelper.getEmptyStyleRulesText(doc);
 		}
 		}
 
 
 		static getCanvasData(doc) {
 		static getCanvasData(doc) {
-			return common.getCanvasData(doc);
+			return docHelper.getCanvasData(doc);
 		}
 		}
 	}
 	}
 
 

+ 1 - 1
manifest.json

@@ -18,7 +18,7 @@
                 "lib/browser-polyfill/custom-browser-polyfill.js",
                 "lib/browser-polyfill/custom-browser-polyfill.js",
                 "extension/index.js",
                 "extension/index.js",
                 "extension/ui/content/infobar.js",
                 "extension/ui/content/infobar.js",
-                "lib/single-file/common.js",
+                "lib/single-file/docHelper.js",
                 "lib/single-file/frame-tree/content/frame-tree.js",
                 "lib/single-file/frame-tree/content/frame-tree.js",
                 "extension/core/content/content-frame.js"
                 "extension/core/content/content-frame.js"
             ],
             ],