aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 12:10:00 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 12:12:52 -0400
commit1b96e69ea2bfe26ded82e2f058d30500290e9d2d (patch)
tree437f8f97629ea735089a8f7195b2cea09eadb894
parentb34ff7ebe9004d85140cced007c67ca2c9f59396 (diff)
Placeholder and improve consistency of stylesheet rule priorities
-rw-r--r--ext/bg/js/settings-popup-preview.js17
-rw-r--r--ext/bg/settings-popup-preview.html2
-rw-r--r--ext/bg/settings.html2
3 files changed, 19 insertions, 2 deletions
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 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Yomichan Popup Preview</title>
- <link rel="stylesheet" type="text/css" href="/fg/css/client.css">
+ <link rel="stylesheet" type="text/css" href="/fg/css/client.css" id="client-css">
<style>
html {
transition: background-color 0.25s linear 0s, color 0.25s linear 0s;
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index cb223e72..ea3e8c18 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -259,7 +259,7 @@
</div>
<div class="col-xs-6">
<label for="custom-popup-outer-css">Custom popup outer CSS</label>
- <div><textarea autocomplete="off" spellcheck="false" wrap="soft" id="custom-popup-outer-css" class="form-control"></textarea></div>
+ <div><textarea autocomplete="off" spellcheck="false" wrap="soft" id="custom-popup-outer-css" class="form-control" placeholder="iframe.yomichan-float { /*styles*/ }"></textarea></div>
</div>
</div>
</div>