Procházet zdrojové kódy

remove useless devtools page (fix #1801)

Gildas před 3 měsíci
rodič
revize
f4e9619713

+ 0 - 1
manifest.json

@@ -114,7 +114,6 @@
 		},
 		"gecko_android": {}
 	},
-	"devtools_page": "src/core/devtools/devtools.html",
 	"incognito": "spanning",
 	"manifest_version": 2,
 	"default_locale": "en"

+ 0 - 1
src/core/bg/autosave.js

@@ -143,7 +143,6 @@ async function saveContent(message, tab) {
 		options.usedFonts = message.usedFonts;
 		options.shadowRoots = message.shadowRoots;
 		options.referrer = message.referrer;
-		options.updatedResources = message.updatedResources;
 		options.worklets = message.worklets;
 		options.adoptedStyleSheets = message.adoptedStyleSheets;
 		options.visitDate = new Date(message.visitDate);

+ 0 - 4
src/core/bg/index.js

@@ -28,7 +28,6 @@ import * as bootstrap from "./bootstrap.js";
 import * as autosave from "./autosave.js";
 import * as bookmarks from "./bookmarks.js";
 import * as companion from "./companion.js";
-import * as devtools from "./devtools.js";
 import * as downloads from "./downloads.js";
 import * as editor from "./editor.js";
 import * as requests from "./requests.js";
@@ -57,9 +56,6 @@ browser.runtime.onMessage.addListener((message, sender) => {
 	if (message.method.startsWith("tabsData.")) {
 		return tabsData.onMessage(message, sender);
 	}
-	if (message.method.startsWith("devtools.")) {
-		return devtools.onMessage(message, sender);
-	}
 	if (message.method.startsWith("editor.")) {
 		return editor.onMessage(message, sender);
 	}

+ 0 - 9
src/core/content/content-bootstrap.js

@@ -30,7 +30,6 @@ const pendingResponses = new Map();
 
 let unloadListenerAdded, optionsAutoSave, tabId, tabIndex, autoSaveEnabled, autoSaveTimeout, autoSavingPage, pageAutoSaved, previousLocationHref, savedPageDetected, compressContent, extractDataFromPageTags, insertTextBody, insertMetaCSP;
 singlefile.pageInfo = {
-	updatedResources: {},
 	visitDate: new Date()
 };
 browser.runtime.sendMessage({ method: "bootstrap.init" }).then(message => {
@@ -58,7 +57,6 @@ browser.runtime.onMessage.addListener(message => {
 		message.method == "content.maybeInit" ||
 		message.method == "content.init" ||
 		message.method == "content.openEditor" ||
-		message.method == "devtools.resourceCommitted" ||
 		message.method == "singlefile.fetchResponse") {
 		return onMessage(message);
 	}
@@ -137,10 +135,6 @@ async function onMessage(message) {
 		}
 		return {};
 	}
-	if (message.method == "devtools.resourceCommitted") {
-		singlefile.pageInfo.updatedResources[message.url] = { content: message.content, type: message.type, encoding: message.encoding };
-		return {};
-	}
 	if (message.method == "singlefile.fetchResponse") {
 		return await onFetchResponse(message);
 	}
@@ -279,9 +273,7 @@ function autoSaveUnloadedPage({ autoSaveUnload, autoSaveDiscard, autoSaveRemove
 
 function savePage(docData, frames, { autoSaveUnload, autoSaveDiscard, autoSaveRemove } = {}) {
 	const helper = singlefile.helper;
-	const updatedResources = singlefile.pageInfo.updatedResources;
 	const visitDate = singlefile.pageInfo.visitDate.getTime();
-	Object.keys(updatedResources).forEach(url => updatedResources[url].retrieved = false);
 	browser.runtime.sendMessage({
 		method: "autosave.save",
 		tabId,
@@ -301,7 +293,6 @@ function savePage(docData, frames, { autoSaveUnload, autoSaveDiscard, autoSaveRe
 		worklets: docData.worklets,
 		frames: frames,
 		url: location.href,
-		updatedResources,
 		visitDate,
 		autoSaveUnload,
 		autoSaveDiscard,

+ 0 - 2
src/core/content/content.js

@@ -157,9 +157,7 @@ async function savePage(message) {
 		selectionFound = await ui.markSelection(options.optionallySelected);
 	}
 	if (!processing && (!bootstrap || !bootstrap.pageInfo.processing)) {
-		options.updatedResources = bootstrap ? bootstrap.pageInfo.updatedResources : {};
 		options.visitDate = bootstrap ? bootstrap.pageInfo.visitDate : new Date();
-		Object.keys(options.updatedResources).forEach(url => options.updatedResources[url].retrieved = false);
 		if (options.optionallySelected && selectionFound) {
 			options.selected = true;
 		}

+ 0 - 13
src/core/devtools/devtools.html

@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html>
-
-<head>
-    <title>DevTools page</title>
-</head>
-
-<body>
-    <script src="/lib/chrome-browser-polyfill.js"></script>
-    <script type="module" src="devtools.js"></script>
-</body>
-
-</html>

+ 0 - 39
src/core/devtools/devtools.js

@@ -1,39 +0,0 @@
-/*
- * Copyright 2010-2020 Gildas Lormeau
- * contact : gildas.lormeau <at> gmail.com
- * 
- * This file is part of SingleFile.
- *
- *   The code in this file is free software: you can redistribute it and/or 
- *   modify it under the terms of the GNU Affero General Public License 
- *   (GNU AGPL) as published by the Free Software Foundation, either version 3
- *   of the License, or (at your option) any later version.
- * 
- *   The code in this file is distributed in the hope that it will be useful, 
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero 
- *   General Public License for more details.
- *
- *   As additional permission under GNU AGPL version 3 section 7, you may 
- *   distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU 
- *   AGPL normally required by section 4, provided you include this license 
- *   notice and a URL through which recipients can access the Corresponding 
- *   Source.
- */
-
-/* global browser */
-
-if (browser.devtools.inspectedWindow && browser.devtools.inspectedWindow.onResourceContentCommitted) {
-	browser.devtools.inspectedWindow.onResourceContentCommitted.addListener(resource => {
-		resource.getContent((content, encoding) => {
-			browser.runtime.sendMessage({
-				method: "devtools.resourceCommitted",
-				tabId: browser.devtools.inspectedWindow.tabId,
-				url: resource.url,
-				content,
-				encoding,
-				type: resource.type
-			});
-		});
-	});
-}

+ 0 - 10
src/lib/single-file/browser-polyfill/chrome-browser-polyfill.js

@@ -534,16 +534,6 @@ if (typeof globalThis == "undefined") {
 					});
 				})
 			},
-			devtools: nativeAPI.devtools && {
-				inspectedWindow: nativeAPI.devtools.inspectedWindow && {
-					onResourceContentCommitted: nativeAPI.devtools.inspectedWindow.onResourceContentCommitted && {
-						addListener: listener => nativeAPI.devtools.inspectedWindow.onResourceContentCommitted.addListener(listener)
-					},
-					get tabId() {
-						return nativeAPI.devtools.inspectedWindow.tabId;
-					}
-				}
-			},
 			webRequest: {
 				onBeforeSendHeaders: {
 					addListener: (listener, filters, extraInfoSpec) => nativeAPI.webRequest.onBeforeSendHeaders.addListener(listener, filters, extraInfoSpec),

+ 1 - 11
src/ui/bg/ui-editor.js

@@ -271,8 +271,6 @@ function toolbarOnTouchEnd(event) {
 	toolbarMoving = false;
 }
 
-let updatedResources = {};
-
 addEventListener("resize", viewportSizeChange);
 addEventListener("message", async event => {
 	const message = JSON.parse(event.data);
@@ -399,8 +397,7 @@ addEventListener("message", async event => {
 });
 
 browser.runtime.onMessage.addListener(message => {
-	if (message.method == "devtools.resourceCommitted" ||
-		message.method == "content.save" ||
+	if (message.method == "content.save" ||
 		message.method == "editor.setTabData" ||
 		message.method == "options.refresh" ||
 		message.method == "content.error" ||
@@ -421,10 +418,6 @@ addEventListener("beforeunload", event => {
 });
 
 async function onMessage(message) {
-	if (message.method == "devtools.resourceCommitted") {
-		updatedResources[message.url] = { content: message.content, type: message.type, encoding: message.encoding };
-		return {};
-	}
 	if (message.method == "content.save") {
 		tabData.options = message.options;
 		savePage();
@@ -536,7 +529,6 @@ function enableEditPage() {
 
 function formatPage() {
 	formatPageButton.classList.remove("format-disabled");
-	updatedResources = {};
 	editorElement.contentWindow.postMessage(JSON.stringify({
 		method: "formatPage",
 		applySystemTheme: tabData.options.applySystemTheme,
@@ -546,7 +538,6 @@ function formatPage() {
 
 function cancelFormatPage() {
 	formatPageButton.classList.add("format-disabled");
-	updatedResources = {};
 	editorElement.contentWindow.postMessage(JSON.stringify({ method: "cancelFormatPage" }), "*");
 }
 
@@ -578,7 +569,6 @@ function savePage() {
 		infobarPositionLeft: tabData.options.infobarPositionLeft,
 		infobarPositionRight: tabData.options.infobarPositionRight,
 		backgroundSave: tabData.options.backgroundSave,
-		updatedResources,
 		filename: tabData.filename,
 		foregroundSave: FOREGROUND_SAVE,
 		sharePage: tabData.options.sharePage,

+ 3 - 9
src/ui/content/content-ui-editor-web.js

@@ -172,7 +172,7 @@ import { downloadPageForeground } from "../../core/common/download.js";
 				infobarPositionBottom = message.infobarPositionBottom;
 				infobarPositionLeft = message.infobarPositionLeft;
 				infobarPositionRight = message.infobarPositionRight;
-				let content = getContent(message.compressHTML, message.updatedResources);
+				let content = getContent(message.compressHTML);
 				if (initScriptContent) {
 					content = content.replace(/<script data-template-shadow-root src.*?<\/script>/g, initScriptContent);
 				}
@@ -1091,7 +1091,7 @@ import { downloadPageForeground } from "../../core/common/download.js";
 			previousContent = document.documentElement.cloneNode(true);
 			deserializeShadowRoots(document);
 		} else {
-			previousContent = getContent(false, []);
+			previousContent = getContent(false);
 		}
 		const shadowRoots = {};
 		const classesToPreserve = ["single-file-highlight", "single-file-highlight-yellow", "single-file-highlight-green", "single-file-highlight-pink", "single-file-highlight-blue"];
@@ -1198,7 +1198,7 @@ import { downloadPageForeground } from "../../core/common/download.js";
 		}
 	}
 
-	function getContent(compressHTML, updatedResources) {
+	function getContent(compressHTML) {
 		unhighlightCutElement();
 		serializeShadowRoots(document);
 		const doc = document.cloneNode(true);
@@ -1239,12 +1239,6 @@ import { downloadPageForeground } from "../../core/common/download.js";
 			element.style.removeProperty("-sf-" + pointerEvents);
 		});
 		doc.body.removeAttribute("contentEditable");
-		const newResources = Object.keys(updatedResources).filter(url => updatedResources[url].type == "stylesheet").map(url => updatedResources[url]);
-		newResources.forEach(resource => {
-			const element = doc.createElement("style");
-			doc.body.appendChild(element);
-			element.textContent = resource.content;
-		});
 		if (pageCompressContent) {
 			const pageFilename = pageResources
 				.filter(resource => resource.filename.endsWith("index.html"))