From 6119a406da314f0485b4ae9844f4454c90bad5f1 Mon Sep 17 00:00:00 2001 From: Jeremy Schomery Date: Mon, 15 May 2017 16:32:59 +0430 Subject: [PATCH] Fixes communication issue with US.o on Firefox browser --- install.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/install.js b/install.js index 61d031c5..bdccb6cd 100644 --- a/install.js +++ b/install.js @@ -1,7 +1,9 @@ 'use strict'; -document.addEventListener('stylishUpdateChrome', onUpdateClicked); -document.addEventListener('stylishInstallChrome', onInstallClicked); +const FIREFOX = /Firefox/.test(navigator.userAgent); + +document.addEventListener("stylishUpdate" + (FIREFOX ? "" : "Chrome"), onUpdateClicked); +document.addEventListener("stylishInstall" + (FIREFOX ? "" : "Chrome"), onInstallClicked); chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { // orphaned content script check @@ -52,6 +54,9 @@ function checkUpdatability([installedStyle]) { function sendEvent(type, detail = null) { + if (FIREFOX) { + type = type.replace('Chrome', ''); + } detail = {detail}; if (typeof cloneInto != 'undefined') { // Firefox requires explicit cloning, however USO can't process our messages anyway