From ca785a6b0ab69e3d7087e1ae2c1b87034c12d738 Mon Sep 17 00:00:00 2001 From: Philip Strecker Date: Fri, 1 Dec 2017 13:16:43 +0100 Subject: [PATCH] Added addon for firefox --- README.md | 6 +++--- contentscript.js | 10 +++++----- icon16.png | Bin 0 -> 539 bytes icon32.png | Bin 0 -> 825 bytes icon48.png | Bin 0 -> 1377 bytes manifest.json | 11 ++++++++--- popup.html | 12 +++++------- popup.js | 26 +++++++++++++++----------- 8 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 icon16.png create mode 100644 icon32.png create mode 100644 icon48.png diff --git a/README.md b/README.md index 9baa402..4189e85 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# [Persistent Video Volume](https://chrome.google.com/webstore/detail/persistent-video-volume/ppoliijncpdcgddmfibmgnjhegceaadj) +# Persistent Video Volume -![Logo](pvv.png) +[![Google Chrome Webstore](https://developer.chrome.com/webstore/images/ChromeWebStore_Badge_v2_206x58.png)](https://chrome.google.com/webstore/detail/persistent-video-volume/ppoliijncpdcgddmfibmgnjhegceaadj)[![Firefox Addons](https://addons.cdn.mozilla.net/static/img/addons-buttons/AMO-button_1.png)](https://addons.mozilla.org/de/firefox/addon/persistent-video-volume/) ## Use cases @@ -9,4 +9,4 @@ # Credits -- Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/) \ No newline at end of file +- Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/) diff --git a/contentscript.js b/contentscript.js index bce9c44..e1c9449 100644 --- a/contentscript.js +++ b/contentscript.js @@ -2,10 +2,11 @@ const STORAGE_KEY = "video-volume"; const STATUS_KEY = "video-volume-status-per-website"; + let store = chrome.storage || window.storage; function setVolume() { let host = window.location.host; let key = STATUS_KEY + '_' + host; - chrome.storage.local.get(key, function(data) { + store.local.get(key, function(data) { if (key in data && !data[key]) { return; } @@ -14,14 +15,14 @@ return; } - chrome.storage.local.get(STORAGE_KEY, function(data) { + store.local.get(STORAGE_KEY, function(data) { if (!data || !(STORAGE_KEY in data)) { return; } for (var x = 0; x < videoTags.length; x++) { videoTags[x].volume = data[STORAGE_KEY] / 100; } - }); + }); }); } @@ -32,6 +33,5 @@ } setVolume(); - window.setInterval(setVolume, 1000); + window.setInterval(setVolume, 1000); })(); - diff --git a/icon16.png b/icon16.png new file mode 100644 index 0000000000000000000000000000000000000000..dd59ed1ac9b71782559b12ded4fe8b9bb4b36e73 GIT binary patch literal 539 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5s=4O z;1O92wCOqsGdgL^t^f+Mmw5WRvOnZuV(?8t*D?b5okAASfiLCF*Rx`Ac!c(FB7CgNj_6 zs|WACvsHh7XY%3wX(wi8C+hE5kr)=*;=0>yQbFWhiB(FGKD!M)6V4iNEeqMxZ0Ekt z=0?Fnr(l&!Z!|((gSO=)o%Fl4dD^tyEq9mC;^2=xNmw*NBpo#FA92~}U&Kt&9mu6{1-oD!Mk4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-GzZ+Rj;xUkjGiz z5m^kh={g8AI%&+V01C2~c>21sKjdNL)|2J9lJp&@iQUu1F~sBe)~UW8A%QYS>#gbn z7ESzVnD}^^rn})ppN*+6oI0E&G6N^9HhXl4>(&*$gIr3A2A8HjP;yMsa%ypLT%72( z@oJCH?j{KlA@@lidiRRGud0nVE)TLQFMe0~e$Maz_rLED|7X3bFKJzx;9QQ>neivj zC+&A&$yhioyFK!+mgX@{rb9d)TjwX_iQZ8?B3yNI>&x9e!b^>R-(ua9)-Gph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jSE|h z9bdr8&0Gq5HmmN1AZ{}UnxJX4AKK{A=|v~OQ#jJ7%ka?0E>?~~5Ad$JzW{vg(c6va zvmf{)rBD-iyomdSI`W!gF*=k*h$lV z7_EQ{i5Ytlcqx5%4Y-b##V8jVXlCw5T-}L2G*u{6M`el?mjf}V1CNuH>K`OrKr4+p%3SlnPv{>R z-)fd|U@eM^PsvL4qk(sqrci!`>ZmU2s?_CmV;raS%2FtQ)quy) zN}NUY%PJHaAxqU?p^Q^?KUEqD3b3>YyNl&~jjank2i!rp#ONHn=(&$Vw!9s!!W;^~ zR)RPhty0LoHle_qM_"], "icons": { + "48": "icon48.png", "128": "icon128.png" }, "content_scripts": [ @@ -15,7 +16,11 @@ } ], "browser_action": { - "default_popup": "popup.html" + "default_popup": "popup.html", + "default_icon": { + "16": "icon16.png", + "32": "icon32.png" + } } -} \ No newline at end of file +} diff --git a/popup.html b/popup.html index 1a675f1..69be994 100644 --- a/popup.html +++ b/popup.html @@ -16,7 +16,7 @@
- +
@@ -50,13 +50,11 @@
-
+
- + - - - + - \ No newline at end of file + diff --git a/popup.js b/popup.js index 3fa087c..ffa35eb 100644 --- a/popup.js +++ b/popup.js @@ -1,6 +1,11 @@ +// init material design components +window.mdc.autoInit(); + const STORAGE_KEY = "video-volume"; const STATUS_KEY = "video-volume-status-per-website"; +let store = chrome.storage || window.storage; +let tbs = chrome.tabs || window.tabs; document.addEventListener('DOMContentLoaded', function() { const slider = new mdc.slider.MDCSlider(document.querySelector('.mdc-slider')); @@ -10,41 +15,41 @@ document.addEventListener('DOMContentLoaded', function() { var text = document.getElementById("volume-value-label"); var setLabel = function(volume) { - text.innerHTML = volume + '%'; + text.innerHTML = escape(volume) + '%'; } slider.listen('MDCSlider:change', () => { var key = {}; key[STORAGE_KEY] = slider.value; - chrome.storage.local.set(key, function() { + store.local.set(key, function() { setLabel(slider.value); }); }); status.addEventListener('change', () => { let enabled = status.checked; slider.disabled = !enabled; - chrome.tabs.query({active: true}, function(tabs) { + tbs.query({active: true}, function(tabs) { let host = parseHostFromURL(tabs[0].url); let key = {}; key[STATUS_KEY + '_' + host] = enabled; - chrome.storage.local.set(key); + store.local.set(key); }); }); - - chrome.tabs.query({active: true}, function(tabs) { + + tbs.query({active: true}, function(tabs) { let host = parseHostFromURL(tabs[0].url); let key = STATUS_KEY + '_' + host; - chrome.storage.local.get(key, function(data) { + store.local.get(key, function(data) { if (key in data) { slider.disabled = !data[key]; status.checked = data[key]; } else { status.checked = true; } - }); + }); }); - - chrome.storage.local.get(STORAGE_KEY, function(data) { + + store.local.get(STORAGE_KEY, function(data) { var volume = data[STORAGE_KEY]; if (!volume) { volume = 0; @@ -60,4 +65,3 @@ document.addEventListener('DOMContentLoaded', function() { } }); -