Fixes communication issue with US.o on Vivaldi browser

This commit is contained in:
Jeremy Schomery 2017-05-15 17:16:09 +04:30
parent 1706f380f2
commit c5081a0747

View File

@ -1,9 +1,16 @@
'use strict';
const FIREFOX = /Firefox/.test(navigator.userAgent);
const VIVALDI = /Vivaldi/.test(navigator.userAgent);
const OPERA = /OPR/.test(navigator.userAgent);
document.addEventListener("stylishUpdate" + (FIREFOX ? "" : "Chrome"), onUpdateClicked);
document.addEventListener("stylishInstall" + (FIREFOX ? "" : "Chrome"), onInstallClicked);
document.addEventListener("stylishUpdate", onUpdateClicked);
document.addEventListener("stylishUpdateChrome", onUpdateClicked);
document.addEventListener("stylishUpdateOpera", onUpdateClicked);
document.addEventListener("stylishInstall", onInstallClicked);
document.addEventListener("stylishInstallChrome", onInstallClicked);
document.addEventListener("stylishInstallOpera", onInstallClicked);
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// orphaned content script check
@ -57,6 +64,9 @@ function sendEvent(type, detail = null) {
if (FIREFOX) {
type = type.replace('Chrome', '');
}
else if (OPERA || VIVALDI) {
type = type.replace('Chrome', 'Opera');
}
detail = {detail};
if (typeof cloneInto != 'undefined') {
// Firefox requires explicit cloning, however USO can't process our messages anyway