Просмотр исходного кода

use "proxy" functions for window methods related to events

Gildas 5 лет назад
Родитель
Сommit
7883a47257

+ 3 - 3
extension/lib/single-file/fetch/content/content-fetch.js

@@ -27,9 +27,9 @@ this.singlefile.extension.lib.fetch.content.resources = this.singlefile.extensio
 
 	const FETCH_REQUEST_EVENT = "single-file-request-fetch";
 	const FETCH_RESPONSE_EVENT = "single-file-response-fetch";
-	const addEventListener = window.addEventListener;
-	const dispatchEvent = window.dispatchEvent;
-	const removeEventListener = window.removeEventListener;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const dispatchEvent = event => window.dispatchEvent(event);
+	const removeEventListener = (type, listener, options) => window.removeEventListener(type, listener, options);
 	const fetch = window.fetch;
 
 	browser.runtime.onMessage.addListener(message => {

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

@@ -42,7 +42,7 @@ this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.pr
 	const TOP_WINDOW = window == window.top;
 
 	const browser = this.browser;
-	const addEventListener = window.addEventListener;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
 	const top = window.top;
 	const MessageChannel = window.MessageChannel;
 	const document = window.document;

+ 2 - 2
lib/single-file/processors/hooks/content/content-hooks-frames-web.js

@@ -48,8 +48,8 @@
 		featureSettings: "font-feature-settings"
 	};
 
-	const addEventListener = window.addEventListener;
-	const dispatchEvent = window.dispatchEvent;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const dispatchEvent = event => window.dispatchEvent(event);
 	const CustomEvent = window.CustomEvent;
 	const document = window.document;
 	const screen = window.screen;

+ 2 - 2
lib/single-file/processors/hooks/content/content-hooks-frames.js

@@ -39,8 +39,8 @@ this.singlefile.lib.processors.hooks.content.frames = this.singlefile.lib.proces
 	const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
 
 	const browser = this.browser;
-	const addEventListener = window.addEventListener;
-	const dispatchEvent = window.dispatchEvent;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const dispatchEvent = event => window.dispatchEvent(event);
 	const CustomEvent = window.CustomEvent;
 	const document = window.document;
 	const HTMLDocument = window.HTMLDocument;

+ 2 - 2
lib/single-file/processors/hooks/content/content-hooks-web.js

@@ -28,10 +28,10 @@
 	const FETCH_REQUEST_EVENT = "single-file-request-fetch";
 	const FETCH_RESPONSE_EVENT = "single-file-response-fetch";
 
-	const dispatchEvent = window.dispatchEvent;
 	const CustomEvent = window.CustomEvent;
 	const fetch = window.fetch;
-	const addEventListener = window.addEventListener;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const dispatchEvent = event => window.dispatchEvent(event);	
 
 	addEventListener.call(window, FETCH_REQUEST_EVENT, async event => {
 		const url = event.detail;

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

@@ -34,8 +34,8 @@ this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.process
 	const MutationObserver = window.MutationObserver;
 	const setTimeout = window.setTimeout;
 	const clearTimeout = window.clearTimeout;
-	const addEventListener = window.addEventListener;
-	const removeEventListener = window.removeEventListener;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const removeEventListener = (type, listener, options) => window.removeEventListener(type, listener, options);
 
 	return {
 		process: async options => {

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

@@ -59,8 +59,8 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 	};
 	const COMMENT_HEADER = "Page saved with SingleFile";
 	const COMMENT_HEADER_LEGACY = "Archive processed by SingleFile";
-	const addEventListener = window.addEventListener;
-	const dispatchEvent = window.dispatchEvent;
+	const addEventListener = (type, listener, options) => window.addEventListener(type, listener, options);
+	const dispatchEvent = event => window.dispatchEvent(event);
 
 	addEventListener("single-file-user-script-init", () => singlefile.lib.helper.waitForUserScript = async eventPrefixName => {
 		const event = new CustomEvent(eventPrefixName + "-request", { cancelable: true });