parent
e6b486d25f
commit
fa2b6f07ce
|
@ -16,7 +16,13 @@
|
||||||
chrome.runtime.onMessage.addListener(onMessage);
|
chrome.runtime.onMessage.addListener(onMessage);
|
||||||
|
|
||||||
let gotBody = false;
|
let gotBody = false;
|
||||||
new MutationObserver(function _(mutations, observer) {
|
new MutationObserver(observeDOM).observe(document.documentElement, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
});
|
||||||
|
observeDOM();
|
||||||
|
|
||||||
|
function observeDOM() {
|
||||||
if (!gotBody) {
|
if (!gotBody) {
|
||||||
if (!document.body) return;
|
if (!document.body) return;
|
||||||
gotBody = true;
|
gotBody = true;
|
||||||
|
@ -26,22 +32,16 @@
|
||||||
method: 'getStyles',
|
method: 'getStyles',
|
||||||
md5Url: getMeta('stylish-md5-url') || location.href
|
md5Url: getMeta('stylish-md5-url') || location.href
|
||||||
}, checkUpdatability);
|
}, checkUpdatability);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (document.getElementById('install_button')) {
|
if (document.getElementById('install_button')) {
|
||||||
if (observer) observer.disconnect();
|
|
||||||
onDOMready().then(() => {
|
onDOMready().then(() => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
sendEvent(sendEvent.lastEvent);
|
sendEvent(sendEvent.lastEvent);
|
||||||
});
|
});
|
||||||
setTimeout(_);
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}).observe(document.documentElement, {
|
}
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
function onMessage(msg, sender, sendResponse) {
|
function onMessage(msg, sender, sendResponse) {
|
||||||
switch (msg.method) {
|
switch (msg.method) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user