From fa2b6f07cecda7e75038e729fd85192cce43499a Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 2 Mar 2018 18:08:25 +0300 Subject: [PATCH] send style status to USO even more insistently see #354 --- content/install-hook-userstyles.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/install-hook-userstyles.js b/content/install-hook-userstyles.js index d3b2ffbb..f25ba3d0 100644 --- a/content/install-hook-userstyles.js +++ b/content/install-hook-userstyles.js @@ -16,7 +16,13 @@ chrome.runtime.onMessage.addListener(onMessage); let gotBody = false; - new MutationObserver(function _(mutations, observer) { + new MutationObserver(observeDOM).observe(document.documentElement, { + childList: true, + subtree: true, + }); + observeDOM(); + + function observeDOM() { if (!gotBody) { if (!document.body) return; gotBody = true; @@ -26,22 +32,16 @@ method: 'getStyles', md5Url: getMeta('stylish-md5-url') || location.href }, checkUpdatability); - return; } if (document.getElementById('install_button')) { - if (observer) observer.disconnect(); onDOMready().then(() => { requestAnimationFrame(() => { sendEvent(sendEvent.lastEvent); }); - setTimeout(_); }); return; } - }).observe(document.documentElement, { - childList: true, - subtree: true, - }); + } function onMessage(msg, sender, sendResponse) { switch (msg.method) {