diff --git a/edit/applies-to-line-widget.js b/edit/applies-to-line-widget.js index 5fcccb0d..1003554e 100644 --- a/edit/applies-to-line-widget.js +++ b/edit/applies-to-line-widget.js @@ -130,7 +130,7 @@ function createAppliesToLineWidget(cm) { chrome.runtime.onMessage.addListener(onRuntimeMessage); - updateWidgetStyle(); + requestAnimationFrame(updateWidgetStyle); update(); } diff --git a/edit/codemirror-editing-hooks.js b/edit/codemirror-editing-hooks.js index 996a8a92..e6925b70 100644 --- a/edit/codemirror-editing-hooks.js +++ b/edit/codemirror-editing-hooks.js @@ -48,16 +48,22 @@ onDOMscriptReady('/codemirror.js').then(() => { // cm.state.search for last used 'find' let searchState; - onDOMready().then(() => { + new MutationObserver((mutations, observer) => { + if (!$('#sections')) { + return; + } + observer.disconnect(); + prefs.subscribe(['editor.keyMap'], showKeyInSaveButtonTooltip); showKeyInSaveButtonTooltip(); // N.B. the event listener should be registered before setupLivePrefs() $('#options').addEventListener('change', onOptionElementChanged); buildOptionsElements(); + setupLivePrefs(); rerouteHotkeys(true); - }); + }).observe(document, {childList: true, subtree: true}); return; diff --git a/edit/edit.js b/edit/edit.js index d0e1519b..78082854 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -32,8 +32,6 @@ Promise.all([ onDOMready(), ]) .then(([style]) => { - setupLivePrefs(); - const usercss = isUsercss(style); $('#heading').textContent = t(styleId ? 'editStyleHeading' : 'addStyleTitle'); $('#name').placeholder = t(usercss ? 'usercssEditorNamePlaceholder' : 'styleMissingName');