Fix: observer is unavailable?

This commit is contained in:
eight 2018-10-06 18:10:47 +08:00
parent 1c635b5bc1
commit e7ef4948cd
3 changed files with 13 additions and 4 deletions

View File

@ -382,12 +382,17 @@
if (next === newElement.nextElementSibling) { if (next === newElement.nextElementSibling) {
return; return;
} }
docRootObserver.evade(() => { const insert = () => {
ROOT.insertBefore(newElement, next || null); ROOT.insertBefore(newElement, next || null);
if (disableAll) { if (disableAll) {
newElement.disabled = true; newElement.disabled = true;
} }
}); };
if (docRootObserver) {
docRootObserver.evade(insert);
} else {
insert();
}
} }
function replaceAll(newStyles) { function replaceAll(newStyles) {

View File

@ -32,7 +32,7 @@ const msg = (() => {
sendBg, sendBg,
broadcast, broadcast,
broadcastTab, broadcastTab,
broadcastExtension: send, // alias of send broadcastExtension,
on, on,
onTab, onTab,
onExtension, onExtension,
@ -122,6 +122,10 @@ const msg = (() => {
}); });
} }
function broadcastExtension(...args) {
return send(...args).catch(console.warn);
}
function on(fn) { function on(fn) {
initHandler(); initHandler();
handler.both.push(fn); handler.both.push(fn);

View File

@ -323,7 +323,7 @@ function createStyleElement({
if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) { if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) {
config.href = style.url; config.href = style.url;
} else { } else {
config.href = ''; config.removeAttribute('href');
} }
config.style.display = config.style.display =
!style.usercssData && config.href || !style.usercssData && config.href ||