You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.
There is a problem with access to window.* properties inside message listener's callback in Firefox with kango 1.8.0. This problem doesn't occur in kango 1.7.9.
Hello @emmabartner.
I have complex structure for my project and I build bundle with Webpack.
Webpack bundle approach
You can place it next to content script.
As this is CommonJS module. In content script you need to do const MessageListener = require('./MessageListener');
Then use webpack for bundle building and describe the resulting bundle file in extension_info.json file:
The simplest method
Delete the string module.exports = MessageListener; from code above and put it in the beginning of your content script. For example:
// ==UserScript==// @name Unnamed// @include http://*// @include https://*// @all-frames true// ==/UserScript=='use strict';functionMessageListener(){this.addedListeners=newMap();}MessageListener.prototype.add=function(message,callback){constisFirefox=typeofInstallTrigger!=='undefined';letadaptedCallback=callback;if(isFirefox){adaptedCallback=runAsync.bind(null,callback)}kango.addMessageListener(message,adaptedCallback)this.addedListeners.set(callback,adaptedCallback);};MessageListener.prototype.remove=function(message,callback){constadaptedCallback=this.addedListeners.get(callback);kango.removeMessageListener(message,adaptedCallback);this.addedListeners.delete(callback);};functionrunAsync(callback,event){newPromise(resolve=>{callback(event);resolve();}).catch(e=>console.log(e));}constlistener=newMessageListener();// use your listener...
There is a problem with access to window.* properties inside message listener's callback in Firefox with kango 1.8.0. This problem doesn't occur in kango 1.7.9.
For example, if I do in content-script:
and in background-script:
I'll get a message from Firefox:
I solved this problem by calling a callback in Promise:
The text was updated successfully, but these errors were encountered: