From 89d8552ccb16d89ea48784d1e8e45485df078ed8 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 23 Feb 2018 18:45:00 +0100 Subject: [PATCH] Simplify and improve the icon-overlay.css stylesheet # Changes: - Change the Min Vid button container into a flex box - Share CSS values between the top and bottom container - Use CSS variables to ease customisation of the button container - Extract icon SVGs from `data:` URIs into files - Prevent websites from restyling the Min Vid button container --- bin/package-addon.sh | 2 +- package.json | 2 +- webextension/background.js | 1 + webextension/content-scripts/icon-add.svg | 6 + webextension/content-scripts/icon-overlay.css | 108 ++++++++++-------- webextension/content-scripts/icon-play.svg | 7 ++ 6 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 webextension/content-scripts/icon-add.svg create mode 100644 webextension/content-scripts/icon-play.svg diff --git a/bin/package-addon.sh b/bin/package-addon.sh index ca60eaa..9414905 100755 --- a/bin/package-addon.sh +++ b/bin/package-addon.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env node +//#!/usr/bin/env node /* * This Source Code is subject to the terms of the Mozilla Public License * version 2.0 (the 'License'). You can obtain a copy of the License at diff --git a/package.json b/package.json index b2981bd..428e7ec 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "watch-script": "onchange '**/*.js' -w -e 'webextension/dist/**/*.js' -- npm run package", "copy:locales": "node ./bin/locales", "dev": "npm run copy:locales && npm run watch-script", - "package": "webpack && ./bin/package-addon.sh", + "package": "webpack && node ./bin/package-addon.sh", "prepackage": "npm run copy:locales && npm run lint", "postpackage": "addons-linter addon.xpi -o text", "prepush": "npm run package", diff --git a/webextension/background.js b/webextension/background.js index 1e19c79..1ad7869 100644 --- a/webextension/background.js +++ b/webextension/background.js @@ -79,6 +79,7 @@ function onLaunch(opts, sender) { else if (title === 'inject-style') { if ('tab' in sender) { browser.tabs.insertCSS(sender.tab.id, { + cssOrigin: 'author', file: '/content-scripts/icon-overlay.css', frameId: opts.frameId, runAt: 'document_start' diff --git a/webextension/content-scripts/icon-add.svg b/webextension/content-scripts/icon-add.svg new file mode 100644 index 0000000..8632db8 --- /dev/null +++ b/webextension/content-scripts/icon-add.svg @@ -0,0 +1,6 @@ + + Min Vid – Add + + + + diff --git a/webextension/content-scripts/icon-overlay.css b/webextension/content-scripts/icon-overlay.css index f333a20..b738fd2 100644 --- a/webextension/content-scripts/icon-overlay.css +++ b/webextension/content-scripts/icon-overlay.css @@ -1,80 +1,90 @@ +.minvid__overlay__container, .minvid__overlay__bottom_container { - align-items: center; - background-color: rgba(0,0,0,0.8); - opacity: 0; - border-radius: 0 0 4px 4px; - height: 100%; - justify-content: center; - left: 4%; - max-height: 80px; - max-width: 36px; - padding: 2px 2px 4px; - position: absolute; - bottom: 0; - width: 100%; - z-index: 1000; + --min-vid--button-gutter: 5px !important; + --min-vid--button-size: 32px !important; + --min-vid--container-border-size: 4px !important; + --min-vid--container-border-radius: var(--min-vid--container-border-size) !important; + + display: flex !important; + align-items: center !important; + background-color: rgba(0,0,0,0.8) !important; + height: 100% !important; + opacity: 0 !important; + left: 4% !important; + max-height: 80px !important; + max-width: calc(var(--min-vid--button-size) + var(--min-vid--container-border-size)) !important; + padding: var(--min-vid--container-border-size) calc(var(--min-vid--container-border-size) / 2) !important; + position: absolute !important; + width: 100% !important; + z-index: 1000 !important; } .minvid__overlay__container { - align-items: center; - background-color: rgba(0,0,0,0.8); - opacity: 0; - border-radius: 0 0 4px 4px; - height: 100%; - justify-content: center; - left: 4%; - max-height: 80px; - max-width: 36px; - padding: 2px 2px 4px; - position: absolute; - top: 0; - width: 100%; - z-index: 1000; + flex-direction: column !important; + border-radius: 0 0 var(--min-vid--container-border-radius) var(--min-vid--container-border-radius) !important; + top: 0 !important; +} + +.minvid__overlay__bottom_container { + flex-direction: column-reverse !important; + border-radius: var(--min-vid--container-border-radius) var(--min-vid--container-border-radius) 0 0 !important; + bottom: 0 !important; } .minvid__overlay__container:hover, .minvid__overlay__bottom_container:hover { - background: rgba(0,0,0,0.9); + background: rgba(0,0,0,0.9) !important; } .minvid__overlay__icon { - display: block; - cursor: pointer; - height: 40%; - opacity: 0.7; - width: 100%; + box-sizing: border-box !important; + padding: 0 calc(var(--min-vid--container-border-size) / 2) !important; + display: block !important; + cursor: pointer !important; + height: var(--min-vid--button-size) !important; + opacity: 0.7 !important; + width: 100% !important; +} + +.minvid__overlay__container .minvid__overlay__icon:not(:first-child), +.minvid__overlay__bottom_container .minvid__overlay__icon:not(:last-child) { + margin-top: calc(var(--min-vid--button-gutter) / 2) !important; +} + +.minvid__overlay__container .minvid__overlay__icon:not(:last-child), +.minvid__overlay__bottom_container .minvid__overlay__icon:not(:first-child) { + margin-bottom: calc(var(--min-vid--button-gutter) / 2) !important; } #minvid__overlay__icon__play { - background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iNzQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iY29udGV4dC1maWxsICNGRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHBhdGggZD0iTTAgOC4wMDdDMCAzLjU4NSAzLjU4OCAwIDggMGg4MGM0LjQxOSAwIDggMy41ODIgOCA4LjAwN3Y1Ny45ODZDOTYgNzAuNDE1IDkyLjQxMiA3NCA4OCA3NEg4Yy00LjQxOSAwLTgtMy41ODItOC04LjAwN1Y4LjAwN3pNNyAyNmE1IDUgMCAwIDEgNS4wMDYtNWg3MS45ODhBNSA1IDAgMCAxIDg5IDI2djM2YTUgNSAwIDAgMS01LjAwNiA1SDEyLjAwNkE1IDUgMCAwIDEgNyA2MlYyNnoiLz48cGF0aCBkPSJNMTIgMzcuOTk3QTMuOTkzIDMuOTkzIDAgMCAxIDE1Ljk5OCAzNGgyNy4wMDRBNCA0IDAgMCAxIDQ3IDM3Ljk5N3YyMC4wMDZBMy45OTMgMy45OTMgMCAwIDEgNDMuMDAyIDYySDE1Ljk5OEE0IDQgMCAwIDEgMTIgNTguMDAzVjM3Ljk5N3ptMTEuNSA0LjM3YzAtLjMwOS4yMjItLjQ1LjQ5OS0uMzE2bDEyLjc5NCA2LjIwN2MuMjc1LjEzNC4yNzcuMzUgMCAuNDg0TDIzLjk5OSA1NC45NWMtLjI3Ni4xMzMtLjQ5OS0uMDA4LS40OTktLjMxNlY0Mi4zNjd6Ii8+PC9nPjwvc3ZnPg==") no-repeat; - background-position: center bottom; - background-size: 32px auto; + background: url("icon-play.svg") no-repeat !important; + background-position: center bottom !important; + background-size: 32px auto !important; } #minvid__overlay__icon__add { - background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTguNCA1LjZWMEg1LjZ2NS42SDB2Mi44aDUuNlYxNGgyLjhWOC40SDE0VjUuNnoiIGZpbGw9ImNvbnRleHQtZmlsbCAjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=") no-repeat; - background-position: center bottom; - background-size: 25px auto; - margin-top: 5px; + background: url("icon-add.svg") no-repeat !important; + background-position: center bottom !important; + background-size: 25px auto !important; } .minvid__overlay__wrapper:hover .minvid__overlay__container, .minvid__overlay__wrapper:hover .minvid__overlay__bottom_container { - opacity: 1; - /*background-color: rgba(0, 0, 0, .8);*/ - /*animation-name: fade; - animation-duration: 4s; - animation-iteration-count: initial; - animation-fill-mode: forwards;*/ + opacity: 1 !important; + /*background-color: rgba(0, 0, 0, .8) !important;*/ + /*animation-name: fade !important; + animation-duration: 4s !important; + animation-iteration-count: initial !important; + animation-fill-mode: forwards !important;*/ } #minvid__overlay__icon__play:hover, #minvid__overlay__icon__add:hover { - opacity: 1; + opacity: 1 !important; } .minvid__overlay__container.fullscreen { - display: none; + display: none !important; } @keyframes fade { diff --git a/webextension/content-scripts/icon-play.svg b/webextension/content-scripts/icon-play.svg new file mode 100644 index 0000000..69c0aa3 --- /dev/null +++ b/webextension/content-scripts/icon-play.svg @@ -0,0 +1,7 @@ + + Min Vid – Play + + + + +