From e7ef4948cd4426bf592230b1670ddc6c50e336ca Mon Sep 17 00:00:00 2001 From: eight Date: Sat, 6 Oct 2018 18:10:47 +0800 Subject: [PATCH] Fix: observer is unavailable? --- content/apply.js | 9 +++++++-- js/msg.js | 6 +++++- popup/popup.js | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/content/apply.js b/content/apply.js index 36dde7c7..88b605f9 100644 --- a/content/apply.js +++ b/content/apply.js @@ -382,12 +382,17 @@ if (next === newElement.nextElementSibling) { return; } - docRootObserver.evade(() => { + const insert = () => { ROOT.insertBefore(newElement, next || null); if (disableAll) { newElement.disabled = true; } - }); + }; + if (docRootObserver) { + docRootObserver.evade(insert); + } else { + insert(); + } } function replaceAll(newStyles) { diff --git a/js/msg.js b/js/msg.js index ca47ee52..f79e242b 100644 --- a/js/msg.js +++ b/js/msg.js @@ -32,7 +32,7 @@ const msg = (() => { sendBg, broadcast, broadcastTab, - broadcastExtension: send, // alias of send + broadcastExtension, on, onTab, onExtension, @@ -122,6 +122,10 @@ const msg = (() => { }); } + function broadcastExtension(...args) { + return send(...args).catch(console.warn); + } + function on(fn) { initHandler(); handler.both.push(fn); diff --git a/popup/popup.js b/popup/popup.js index 8321a072..4afedbbd 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -323,7 +323,7 @@ function createStyleElement({ if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) { config.href = style.url; } else { - config.href = ''; + config.removeAttribute('href'); } config.style.display = !style.usercssData && config.href ||