diff --git a/js/conf/Keybinds.js b/js/conf/Keybinds.js index 438155d..1dd072d 100644 --- a/js/conf/Keybinds.js +++ b/js/conf/Keybinds.js @@ -137,16 +137,14 @@ var _kbd_process = function (event) { // Tukaj ugotovimo, katero tipko } } - -var _kbd_setup = async function() { - +var _kbd_load = async function() { if(Debug.debug) console.log("[Keybinds::_kbd_setup_init] Setting up keybinds"); var ret = await StorageManager.getopt_async("keybinds"); var keybinds = ret.keybinds; - + if(Array.isArray(keybinds)){ StorageManager.delopt("keybinds"); keybinds = DEFAULT_KEYBINDINGS; @@ -165,11 +163,24 @@ var _kbd_setup = async function() { } _kbd_keybinds = keybinds; +} +var _kbd_setup = async function() { + await _kbd_load(); + $(document).keydown(_kbd_process); } +var _kbd_fetch = async function(){ + if($.isEmptyObject(_kbd_keybinds)){ + await _kbd_load(); + } + + return _kbd_keybinds; +} var Keybinds = { - init: _kbd_setup + init: _kbd_setup, + fetch: _kbd_fetch, + mods: _kbd_ModKeys } diff --git a/js/uw.js b/js/uw.js index 185c290..202e091 100644 --- a/js/uw.js +++ b/js/uw.js @@ -51,8 +51,8 @@ async function main(){ - - ArDetect.arSetup(); + if(Settings.arDetect.enable == "global") + ArDetect.arSetup(); document.addEventListener("mozfullscreenchange", function( event ) { if(Debug.debug){ diff --git a/manifest.json b/manifest.json index f65e378..48c8161 100644 --- a/manifest.json +++ b/manifest.json @@ -77,7 +77,7 @@ ], "options_ui" : { - "page": "res/settings.html", + "page": "res/settings/settings.html", "open_in_tab": true } } diff --git a/res/popup/js/popup.js b/res/popup/js/popup.js index 658944a..fff1997 100644 --- a/res/popup/js/popup.js +++ b/res/popup/js/popup.js @@ -33,7 +33,7 @@ var hasVideos = false; var _config; -function check4videos(){ +async function check4videos(){ var command = {}; command.cmd = "has-videos"; command.sender = "popup"; @@ -57,7 +57,7 @@ function check4videos(){ }); } -function check4conf(){ +async function check4conf(){ var command = {}; command.cmd = "get-config"; command.sender = "popup"; diff --git a/res/popup/popup.html b/res/popup/popup.html index a75848c..5936fdf 100644 --- a/res/popup/popup.html +++ b/res/popup/popup.html @@ -80,7 +80,9 @@ .suboption { display: block; padding-left: 15px; + padding-right: 15px; padding-top: 5px; + padding-bottom: 20px; min-height: 250px; } @@ -112,8 +114,12 @@ } #no-videos-display { height: 100%; - padding-top: 120px; + padding-top: 50px; +/* text-align: center; */ + } + .center{ text-align: center; + width: 100%; } @@ -137,7 +143,10 @@
- No videos have been found on this page.
NOTE: iframes are not detected by this popup. You need a keyboard / to enable automatic aspect ratio detection to fix aspect ratio in embedded players.
Embedded players must also be in full screen.
+

No videos have been found on this page.

If there is a video on this page, then you're seeing this message for one of these reasons:

+
-
General settings
-
Site options
-
Shortcuts
+ + +
Shortcuts
About
@@ -234,7 +234,7 @@ -
+
Enable automatic aspect ratio detection
@@ -265,101 +265,76 @@
-
-

Guess which thing doesn't do shit at the moment either?

-

If you guessed this page ... well.

+
+

Keyboard shortcuts

+
+ + +
+
Autodetect aspect ratio
+ Ctrl + + Shift + + Alt + + +
+
Fit to width
- Ctrl + - Shift + - Alt + - + Ctrl + + Shift + + Alt + +
Fit to height
- Ctrl + - Shift + - Alt + - + Ctrl + + Shift + + Alt + +
Reset
- Ctrl + - Shift + - Alt + - -
- - -
-
Zoom
- Ctrl + - Shift + - Alt + - -
- - -
-
Unzoom
- Ctrl + - Shift + - Alt + - + Ctrl + + Shift + + Alt + +
Force 21:9
- Ctrl + - Shift + - Alt + - + Ctrl + + Shift + + Alt + + +
+ + +
+
Force 2:1 (18:9)
+ Ctrl + + Shift + + Alt + +
Force 16:9
- Ctrl + - Shift + - Alt + - + Ctrl + + Shift + + Alt + +
- -
-
Force 16:10
- Ctrl + - Shift + - Alt + - -
- - -
-
Force 4:3
- Ctrl + - Shift + - Alt + - -
- - -
-
Autodetect aspect ratio (Netflix only)
- Ctrl + - Shift + - Alt + - -
Cancel
Save
@@ -382,7 +357,7 @@

this is the future lol. (at least as far as autodetection goes, keybinds need to make a comeback)

Acknowledgements

This extension uses font Oxygen.

-

Special thanks to CD Project Red (The Witcher 2), Anet (Guild Wars 2), and Valve (CS:GO), which made it possible for me to untrigger myself after seeing so many improperly encoded videos.

+

Special thanks to CD Project Red (The Witcher 2), Cyanide Studios (Styx, Of Orcs and Men), and Valve (CS:GO), which made it possible for me to untrigger myself after seeing so many improperly encoded videos.

More or less.

Special one-finger salute to all incompetent people who don't know how to properly encode videos and upload them to youtube (to word it most nicely).

@@ -391,6 +366,14 @@
+ + + + + + + + diff --git a/res/settings/settings.js b/res/settings/settings.js new file mode 100644 index 0000000..164c394 --- /dev/null +++ b/res/settings/settings.js @@ -0,0 +1,134 @@ +function showAbout(){ + clearPage(); + + document.getElementById("about").classList.remove("hide"); + document.getElementById("tab_about").classList.add("tab-selected"); +} +function showShortcuts(){ + clearPage(); + + document.getElementById("uw_shortcuts").classList.remove("hide"); + document.getElementById("tab_shortcuts").classList.add("tab-selected"); +} +function showGeneralSettings(){ + clearPage(); + + document.getElementById("general_settings").classList.remove("hide"); + document.getElementById("tab_general_settings").classList.add("tab-selected"); +} + +function showSites(){ + clearPage(); + document.getElementById("uw_sites").classList.remove("hide"); + document.getElementById("tab_sites").classList.add("tab-selected"); +} + +function clearPage(){ + // Hide you sections + document.getElementById("uw_shortcuts").classList.add("hide"); + document.getElementById("about").classList.add("hide"); + document.getElementById("general_settings").classList.add("hide"); + document.getElementById("uw_sites").classList.add("hide"); + + // Hide you tabs + document.getElementById("tab_shortcuts").classList.remove("tab-selected"); + document.getElementById("tab_about").classList.remove("tab-selected"); + document.getElementById("tab_general_settings").classList.remove("tab-selected"); + document.getElementById("tab_sites").classList.remove("tab-selected"); + +} + + + +async function loadKeybinds(){ + // load showShortcuts + var keybinds = await Keybinds.fetch(); + + for(var key in keybinds){ + if(Debug.debug) + console.log("[settings.js::loadKeybinds] we're looking at this key:", key, "it splits like this:", key.toLowerCase().split("_")); + + var keypressArr = key.split("_"); + var opts = keybinds[key]; + + var query = "_kbd_" + opts.action + "_"; + if(opts.action == "char"){ + if(opts.targetAr == 2.39) + query += ("219_"); + else if(opts.targetAr == 2.0) + query += ("189_"); + else if(opts.targetAr == 1.78) + query += ("169_"); + } + + var q2; + for(var modKey of Keybinds.mods){ + q2 = "#" + query + modKey; + document.querySelector(q2).checked = keypressArr.indexOf(modKey) != -1; + } + q2 = "#" + query + "lettr"; + document.querySelector(q2).value = keypressArr[keypressArr.length - 1].toLowerCase(); + } +} + +async function saveKeybinds(){ + + var actions = [ "autoar", "fitw", "fith", "reset", "char_219", "char_189", "char_169" ]; + + var savedShortcuts = {}; + + for(var action of actions){ + var queryBase = "#_kbd_" + action; + var letter = document.querySelector(queryBase + "_lettr").value.trim(); + + if(letter === "" || letter === undefined) + continue; // we don't make a shortcut for this action + + var shortcutKeypress = ""; + + for(mod of Keybinds.mods) + if(document.querySelector(queryBase + "_" + mod).checked) + shortcutKeypress += (mod + "_"); + + shortcutKeypress += letter; + + savedShortcuts[shortcutKeypress] = {}; + + if(action.startsWith("char_")){ + savedShortcuts[shortcutKeypress].action = "char"; + + if(action == "char_219") + savedShortcuts[shortcutKeypress].targetAr = 2.39; + else if(action == "char_189") + savedShortcuts[shortcutKeypress].targetAr = 2.0; + else if(action == "char_169") + savedShortcuts[shortcutKeypress].targetAr = 1.78; + } + else{ + savedShortcuts[shortcutKeypress].action = action; + } + } + + // out with the old + await StorageManager.delopt("keybinds"); + //in with the new + StorageManager.setopt({"keybinds":savedShortcuts}); +} + + +// page init +// document.addEventListener("DOMContentLoaded", loadopts); + +document.querySelector("#tab_shortcuts").addEventListener("click", showShortcuts); +document.querySelector("#tab_about").addEventListener("click", showAbout); +// document.querySelector("#tab_general_settings").addEventListener("click",showGeneralSettings); +// document.querySelector("#tab_sites").addEventListener("click", showSites); + +document.querySelector("#kb_save").addEventListener("click", saveKeybinds); +document.querySelector("#kb_cancel").addEventListener("click", loadKeybinds); + +// document.querySelector("#enable_autoar").addEventListener("click",saveAutoar); +// document.querySelector("#enable_ui").addEventListener("click", saveUI); +// document.querySelector("#enable_ui_compact").addEventListener("click", saveUI); + +loadKeybinds(); diff --git a/res/settings.js b/res/settings/settings.js.old similarity index 100% rename from res/settings.js rename to res/settings/settings.js.old