From 6d65d2a2b60d02a9667a3ba8f77f5ad097ebbf96 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 29 Apr 2017 02:36:10 +0300 Subject: [PATCH] Expose iframes via HTML[stylus-iframe] * convert actions to buttons --- _locales/en/messages.json | 17 +++++++++++---- apply.js | 24 +++++++++++++++++++- options/index.css | 17 +++++++++++++-- options/index.html | 46 ++++++++++++++++++++++++--------------- prefs.js | 6 ++++- storage.js | 13 ++++++----- 6 files changed, 92 insertions(+), 31 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 8cd0ccd7..f6f4ff42 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -655,7 +655,7 @@ "message": "Background color when disabled" }, "optionsPopupWidth": { - "message": "Width (in pixels)" + "message": "Popup width (in pixels)" }, "optionsUpdateInterval": { "message": "Automatically check for and install all available userstyle updates (in hrs)" @@ -675,6 +675,15 @@ "optionsCustomizeUpdate": { "message": "Updates" }, + "optionsAdvanced": { + "message": "Advanced" + }, + "optionsAdvancedExposeIframes": { + "message": "Expose iframes via HTML[stylus-iframe]" + }, + "optionsAdvancedExposeIframesNote": { + "message": "Enables writing iframe-specific CSS like 'html[stylus-iframe] h1 { display:none }'" + }, "optionsActions": { "message": "Actions" }, @@ -682,10 +691,10 @@ "message": "Reset the options to default values" }, "optionsResetButton": { - "message": "Reset" + "message": "Reset options" }, "optionsOpenManager": { - "message": "Open styles manager" + "message": "Manage styles" }, "optionsOpenManagerNote": { "message": "Define a keyboard shortcut" @@ -697,6 +706,6 @@ "message": "Open" }, "optionsCheck": { - "message": "Check" + "message": "Update styles" } } diff --git a/apply.js b/apply.js index a2f523b2..6fc05cbe 100644 --- a/apply.js +++ b/apply.js @@ -7,6 +7,7 @@ var ID_PREFIX = 'stylus-'; var ROOT = document.documentElement; var isOwnPage = location.href.startsWith('chrome-extension:'); var disableAll = false; +var exposeIframes = false; var styleElements = new Map(); var disabledElements = new Map(); var retiredStyleTimers = new Map(); @@ -94,6 +95,9 @@ function applyOnMessage(request, sender, sendResponse) { if ('disableAll' in request.prefs) { doDisableAll(request.prefs.disableAll); } + if ('exposeIframes' in request.prefs) { + doExposeIframes(request.prefs.exposeIframes); + } break; case 'ping': @@ -103,7 +107,7 @@ function applyOnMessage(request, sender, sendResponse) { } -function doDisableAll(disable) { +function doDisableAll(disable = disableAll) { if (!disable === !disableAll) { return; } @@ -117,6 +121,20 @@ function doDisableAll(disable) { } +function doExposeIframes(state = exposeIframes) { + if (state === exposeIframes || window == parent) { + return; + } + exposeIframes = state; + const attr = document.documentElement.getAttribute('stylus-iframe'); + if (state && attr != '') { + document.documentElement.setAttribute('stylus-iframe', ''); + } else if (!state && attr == '') { + document.documentElement.removeAttribute('stylus-iframe'); + } +} + + function applyStyleState({id, enabled}) { const inCache = disabledElements.get(id) || styleElements.get(id); const inDoc = document.getElementById(ID_PREFIX + id); @@ -169,6 +187,10 @@ function applyStyles(styles) { doDisableAll(styles.disableAll); delete styles.disableAll; } + if ('exposeIframes' in styles) { + doExposeIframes(styles.exposeIframes); + delete styles.exposeIframes; + } if (document.head && document.head.firstChild && document.head.firstChild.id == 'xml-viewer-style') { diff --git a/options/index.css b/options/index.css index bd649bbc..919d8541 100644 --- a/options/index.css +++ b/options/index.css @@ -37,7 +37,7 @@ body { .block:last-child { border-bottom: none; - padding-bottom: 4px; + padding-bottom: 0; } h1 { @@ -104,6 +104,14 @@ input[type="color"] { height: 2em; } +#actions { + justify-content: space-around; +} + +#actions button { + width: auto; +} + [data-cmd="check-updates"] button { position: relative; } @@ -126,7 +134,6 @@ input[type="color"] { #updates-installed { position: absolute; font-size: 85%; - right: 16px; margin-top: 1px; } @@ -171,6 +178,12 @@ input[type="color"] { margin-bottom: 1ex; } +sup { + vertical-align: baseline; + position: relative; + top: -0.4em; +} + @keyframes fadeinout { 0% { opacity: 0 } 10% { opacity: 1 } diff --git a/options/index.html b/options/index.html index f63b55f2..95919c47 100644 --- a/options/index.html +++ b/options/index.html @@ -12,9 +12,17 @@
+

+ -
+

@@ -48,6 +50,7 @@
+

@@ -57,21 +60,27 @@
+
-

+

- - +
+
+ +
+ + +
+
@@ -83,6 +92,7 @@

+