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) {
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) {

View File

@ -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);

View File

@ -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 ||