Kaynağa Gözat

removed unnecessary async keywords

Former-commit-id: ef8f05717e17f45cfc86be99815ecc738754b6da
Gildas 6 yıl önce
ebeveyn
işleme
3ec6bf0099

+ 2 - 6
extension/core/bg/bookmarks.js

@@ -25,7 +25,7 @@
 
 singlefile.extension.core.bg.bookmarks = (() => {
 
-	onInit();
+	enable();
 	return {
 		onMessage,
 		saveCreatedBookmarks: enable,
@@ -33,11 +33,7 @@ singlefile.extension.core.bg.bookmarks = (() => {
 		update: (id, changes) => browser.bookmarks.update(id, changes)
 	};
 
-	async function onInit() {
-		enable();
-	}
-
-	async function onMessage(message) {
+	function onMessage(message) {
 		if (message.method.endsWith(".saveCreatedBookmarks")) {
 			enable();
 			return {};

+ 2 - 2
extension/core/bg/business.js

@@ -154,12 +154,12 @@ singlefile.extension.core.bg.business = (() => {
 		const taskId = taskInfo.id;
 		return new Promise(async (resolve, reject) => {
 			taskInfo.status = "processing";
-			taskInfo.resolve = async () => {
+			taskInfo.resolve = () => {
 				tasks.splice(tasks.findIndex(taskInfo => taskInfo.id == taskId), 1);
 				resolve();
 				runTasks();
 			};
-			taskInfo.reject = async error => {
+			taskInfo.reject = error => {
 				tasks.splice(tasks.findIndex(taskInfo => taskInfo.id == taskId), 1);
 				reject(error);
 				runTasks();

+ 2 - 2
extension/core/bg/editor.js

@@ -46,11 +46,11 @@ singlefile.extension.core.bg.editor = (() => {
 		tabsData.set(tab.id, { content, filename, options });
 	}
 
-	async function onTabRemoved(tabId) {
+	function onTabRemoved(tabId) {
 		tabsData.delete(tabId);
 	}
 
-	async function onInit(tab) {
+	function onInit(tab) {
 		if (tab.url != EDITOR_URL) {
 			tabsData.delete(tab.id);
 		}

+ 1 - 1
extension/core/bg/tabs-data.js

@@ -35,7 +35,7 @@ singlefile.extension.core.bg.tabsData = (() => {
 		set: setPersistent
 	};
 
-	async function onMessage(message) {
+	function onMessage(message) {
 		if (message.method.endsWith(".get")) {
 			return getPersistent();
 		}

+ 1 - 1
extension/core/bg/tabs.js

@@ -59,7 +59,7 @@ singlefile.extension.core.bg.tabs = (() => {
 		remove: tabId => browser.tabs.remove(tabId),
 		promptValue: async promptMessage => {
 			const tabs = await browser.tabs.query({ currentWindow: true, active: true });
-			return new Promise(async (resolve, reject) => {
+			return new Promise((resolve, reject) => {
 				const selectedTabId = tabs[0].id;
 				browser.tabs.onRemoved.addListener(onTabRemoved);
 				pendingPrompts.set(selectedTabId, { resolve, reject });

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

@@ -23,7 +23,7 @@
 
 /* global browser, window, addEventListener, removeEventListener, document, location, setTimeout, prompt, Node */
 
-this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.core.content.bootstrap || (async () => {
+this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.core.content.bootstrap || (() => {
 
 	const singlefile = this.singlefile;
 
@@ -120,7 +120,7 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 		}
 	}
 
-	async function refresh() {
+	function refresh() {
 		if (autoSaveEnabled && options && (options.autoSaveUnload || options.autoSaveLoadOrUnload)) {
 			if (!unloadListenerAdded) {
 				addEventListener("unload", onUnload);

+ 2 - 2
extension/lib/single-file/fetch/bg/fetch.js

@@ -35,7 +35,7 @@
 		}
 	});
 
-	async function onRequest(message, sender) {
+	function onRequest(message, sender) {
 		if (message.method == "singlefile.fetch") {
 			return fetchResource(message.url);
 		} else if (message.method == "singlefile.fetchFrame") {
@@ -43,7 +43,7 @@
 		}
 	}
 
-	async function fetchResource(url) {
+	function fetchResource(url) {
 		return new Promise((resolve, reject) => {
 			const xhrRequest = new XMLHttpRequest();
 			xhrRequest.withCredentials = true;

+ 1 - 1
extension/ui/bg/ui-panel.js

@@ -23,7 +23,7 @@
 
 /* global browser, document */
 
-(async () => {
+(() => {
 
 	const optionsTab = document.getElementById("tab-options");
 	const pendingsTab = document.getElementById("tab-pendings");

+ 1 - 1
extension/ui/content/content-ui-editor-web.js

@@ -23,7 +23,7 @@
 
 /* global singlefile, window, document, fetch, DOMParser, getComputedStyle, setTimeout, clearTimeout, NodeFilter, Readability, isProbablyReaderable, matchMedia */
 
-(async () => {
+(() => {
 
 	const FORBIDDEN_TAG_NAMES = ["a", "area", "audio", "base", "br", "col", "command", "embed", "hr", "img", "iframe", "input", "keygen", "link", "meta", "param", "source", "track", "video", "wbr"];
 	const BUTTON_ANCHOR_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAHdElNRQfjCh0VAjZTpsLvAAAA1klEQVQoz3XQMS8EURQF4O9txN9QSCjoNYRiy01EomDb3UbnR+j8BpSKrbaaQvwAyTZ2Qyg0WiwJiZjmKmasmWTnvObe8849971DFSe+/TjVgL6wpyMczxcMXYIzV/9kqyIY27Vsyb5J05KREMa1sQoS3r2W1Vxkcrms6Tph6q3usFARBJJUVjPBgZ6Je49u5ELCog0r1qy7YFMI4RxMfZRZFOxOa/bn28oi8rK7K6hrITw48uVT37MQBn9vOcS2l9K0OE9W0atHsqWtIwxlRk1ZdHXrxC+ueUcydrdI6QAAAABJRU5ErkJggg==";

+ 1 - 1
lib/single-file/processors/frame-tree/content/content-frame-tree.js

@@ -93,7 +93,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
 		}
 	}, true);
 	return {
-		getAsync: async options => {
+		getAsync: options => {
 			const sessionId = options.sessionId || 0;
 			options = JSON.parse(JSON.stringify(options));
 			return new Promise(async resolve => {

+ 2 - 2
lib/single-file/processors/lazy/content/content-lazy-loader.js

@@ -38,7 +38,7 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 	const removeEventListener = window.removeEventListener;
 
 	return {
-		process: async options => {
+		process: options => {
 			const maxScrollY = Math.max(document.documentElement.scrollHeight - (document.documentElement.clientHeight * 1.5), 0);
 			const maxScrollX = Math.max(document.documentElement.scrollWidth - (document.documentElement.clientWidth * 1.5), 0);
 			if (scrollY <= maxScrollY && scrollX <= maxScrollX) {
@@ -116,7 +116,7 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 		return setAsyncTimeout(() => lazyLoadEnd(idleTimeoutId, observer, options, resolve), options.loadDeferredImagesMaxIdleTime);
 	}
 
-	async function deferForceLazyLoadEnd(timeoutId, idleTimeoutId, maxTimeoutId, observer, options, resolve) {
+	function deferForceLazyLoadEnd(timeoutId, idleTimeoutId, maxTimeoutId, observer, options, resolve) {
 		clearAsyncTimeout(maxTimeoutId);
 		return setAsyncTimeout(() => {
 			clearAsyncTimeout(timeoutId);

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

@@ -58,7 +58,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				this.runner.cancel();
 			}
 		}
-		async getPageData() {
+		getPageData() {
 			return this.runner.getPageData();
 		}
 	}
@@ -240,7 +240,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			return this.processor.stylesheets;
 		}
 
-		async getPageData() {
+		getPageData() {
 			if (this.root) {
 				this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url }));
 			}
@@ -311,7 +311,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			this.duplicates = new Map();
 		}
 
-		async addURL(resourceURL, asBinary, groupDuplicates) {
+		addURL(resourceURL, asBinary, groupDuplicates) {
 			return new Promise((resolve, reject) => {
 				const requestKey = JSON.stringify([resourceURL, asBinary]);
 				let resourceRequests = this.requests.get(requestKey);
@@ -336,7 +336,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			return this.requests.size;
 		}
 
-		async run(onloadListener, options) {
+		run(onloadListener, options) {
 			const resourceURLs = [...this.requests.keys()];
 			let indexResource = 0;
 			return Promise.all(resourceURLs.map(async requestKey => {
@@ -1293,7 +1293,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		replaceStyleAttributes() {
-			this.doc.querySelectorAll("[style]").forEach(async element => {
+			this.doc.querySelectorAll("[style]").forEach(element => {
 				const declarations = this.styles.get(element);
 				if (declarations) {
 					this.styles.delete(element);

+ 2 - 2
lib/single-file/single-file-util.js

@@ -129,7 +129,7 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
 				getContentSize(content) {
 					return new Blob([content]).size;
 				},
-				async truncateText(content, maxSize) {
+				truncateText(content, maxSize) {
 					const blob = new Blob([content]);
 					const reader = new FileReader();
 					reader.readAsText(blob.slice(0, maxSize));
@@ -183,7 +183,7 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
 				removeQuotes(string) {
 					return helper.removeQuotes(string);
 				},
-				async waitForUserScript(eventPrefixName) {
+				waitForUserScript(eventPrefixName) {
 					if (helper.waitForUserScript) {
 						return helper.waitForUserScript(eventPrefixName);
 					}