Fixes communication issue with US.o on Firefox browser

This commit is contained in:
Jeremy Schomery 2017-05-15 16:32:59 +04:30
parent 449f86e5ef
commit 6119a406da

View File

@ -1,7 +1,9 @@
'use strict'; 'use strict';
document.addEventListener('stylishUpdateChrome', onUpdateClicked); const FIREFOX = /Firefox/.test(navigator.userAgent);
document.addEventListener('stylishInstallChrome', onInstallClicked);
document.addEventListener("stylishUpdate" + (FIREFOX ? "" : "Chrome"), onUpdateClicked);
document.addEventListener("stylishInstall" + (FIREFOX ? "" : "Chrome"), onInstallClicked);
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// orphaned content script check // orphaned content script check
@ -52,6 +54,9 @@ function checkUpdatability([installedStyle]) {
function sendEvent(type, detail = null) { function sendEvent(type, detail = null) {
if (FIREFOX) {
type = type.replace('Chrome', '');
}
detail = {detail}; detail = {detail};
if (typeof cloneInto != 'undefined') { if (typeof cloneInto != 'undefined') {
// Firefox requires explicit cloning, however USO can't process our messages anyway // Firefox requires explicit cloning, however USO can't process our messages anyway