import Debug from '../../conf/Debug'; import BrowserDetect from '../../conf/BrowserDetect'; class Comms { static async sendMessage(message){ message = JSON.parse(JSON.stringify(message)); // vue quirk. We should really use vue store instead if(BrowserDetect.firefox){ return browser.runtime.sendMessage(message) } else { return new Promise((resolve, reject) => { try{ if(BrowserDetect.edge){ browser.runtime.sendMessage(message, function(response){ var r = response; resolve(r); }); } else { chrome.runtime.sendMessage(message, function(response){ // Chrome/js shittiness mitigation — remove this line and an empty array will be returned var r = response; resolve(r); }); } } catch(e){ reject(e); } }); } } } export default Comms;