diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-16 13:37:03 -0500 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-16 21:45:30 -0500 | 
| commit | d3aefdc4e3f78b87b99bff576137f530ac7ac163 (patch) | |
| tree | 7f14d99f0061127a7131fe88cc549490776cc1ad | |
| parent | b6a50e234cf4fc6179725082f9f53ddd7325ba01 (diff) | |
Override setCustomOuterCss instead of Popup.injectOuterStylesheet
| -rw-r--r-- | ext/bg/js/settings/popup-preview-frame.js | 19 | 
1 files changed, 10 insertions, 9 deletions
| diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index a7863b3a..8c354bf7 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -22,7 +22,8 @@ class SettingsPopupPreview {      constructor() {          this.frontend = null;          this.apiOptionsGetOld = apiOptionsGet; -        this.popupInjectOuterStylesheetOld = Popup.injectOuterStylesheet; +        this.popup = null; +        this.popupSetCustomOuterCssOld = null;          this.popupShown = false;          this.themeChangeTimeout = null;          this.textSource = null; @@ -50,19 +51,19 @@ class SettingsPopupPreview {          const popupHost = new PopupProxyHost();          await popupHost.prepare(); -        const popup = popupHost.getOrCreatePopup(); -        popup.setChildrenSupported(false); +        this.popup = popupHost.getOrCreatePopup(); +        this.popup.setChildrenSupported(false); -        this.frontend = new Frontend(popup); +        this.popupSetCustomOuterCssOld = this.popup.setCustomOuterCss; +        this.popup.setCustomOuterCss = (...args) => this.popupSetCustomOuterCss(...args); + +        this.frontend = new Frontend(this.popup);          this.frontend.setEnabled = function () {};          this.frontend.searchClear = function () {};          await this.frontend.prepare(); -        // Overwrite popup -        Popup.injectOuterStylesheet = (...args) => this.popupInjectOuterStylesheet(...args); -          // Update search          this.updateSearch();      } @@ -83,9 +84,9 @@ class SettingsPopupPreview {          return options;      } -    popupInjectOuterStylesheet(...args) { +    async popupSetCustomOuterCss(...args) {          // This simulates the stylesheet priorities when injecting using the web extension API. -        const result = this.popupInjectOuterStylesheetOld(...args); +        const result = await this.popupSetCustomOuterCssOld.call(this.popup, ...args);          const outerStylesheet = Popup.outerStylesheet;          const node = document.querySelector('#client-css'); |