From b34ff7ebe9004d85140cced007c67ca2c9f59396 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Oct 2019 11:57:40 -0400 Subject: Change #yomichan-float to .yomichan-float Since there can be more than one popup, using a class makes more sense than an ID. --- ext/bg/settings-popup-preview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/bg/settings-popup-preview.html') diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index 3d426f7a..bfe4550c 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -24,7 +24,7 @@ font-family: "Helvetica Neue", Helvetica, Arial ,sans-serif; font-size: 14px; } - iframe#yomichan-float { + iframe.yomichan-float { resize: none; } .vertical-align-outer { -- cgit v1.2.3 From 1b96e69ea2bfe26ded82e2f058d30500290e9d2d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Oct 2019 12:10:00 -0400 Subject: Placeholder and improve consistency of stylesheet rule priorities --- ext/bg/js/settings-popup-preview.js | 17 +++++++++++++++++ ext/bg/settings-popup-preview.html | 2 +- ext/bg/settings.html | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'ext/bg/settings-popup-preview.html') diff --git a/ext/bg/js/settings-popup-preview.js b/ext/bg/js/settings-popup-preview.js index 68655fc9..7ccdc7f3 100644 --- a/ext/bg/js/settings-popup-preview.js +++ b/ext/bg/js/settings-popup-preview.js @@ -21,6 +21,7 @@ class SettingsPopupPreview { constructor() { this.frontend = null; this.apiOptionsGetOld = apiOptionsGet; + this.popupInjectOuterStylesheetOld = Popup.injectOuterStylesheet; this.popupShown = false; this.themeChangeTimeout = null; } @@ -56,6 +57,9 @@ class SettingsPopupPreview { await this.frontend.isPrepared(); + // Overwrite popup + Popup.injectOuterStylesheet = (...args) => this.popupInjectOuterStylesheet(...args); + // Update search this.updateSearch(); } @@ -76,6 +80,19 @@ class SettingsPopupPreview { return options; } + popupInjectOuterStylesheet(...args) { + // This simulates the stylesheet priorities when injecting using the web extension API. + const result = this.popupInjectOuterStylesheetOld(...args); + + const outerStylesheet = Popup.outerStylesheet; + const node = document.querySelector('#client-css'); + if (node !== null && outerStylesheet !== null) { + node.parentNode.insertBefore(outerStylesheet, node); + } + + return result; + } + onWindowResize() { if (this.frontend === null) { return; } const textSource = this.frontend.textSourceLast; diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index bfe4550c..07caa271 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -4,7 +4,7 @@ Yomichan Popup Preview - +