diff --git a/.gitignore b/.gitignore index 3a101a7..606fb8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ ultrawidify.zip +ultrawidify-git.zip old/ +build/ diff --git a/README.md b/README.md index 475f0c1..ba0f199 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,50 @@ If you own an ultrawide monitor, you have probably noticed that sometimes videos ![Demo](img-demo/example-httyd2.png "Should these black bars be here? No [...] But an ultrawide user never forgets.") -Works (tested!) on Youtube and Netflix, but you can try your luck with other sites as well. Available for [Firefox](https://addons.mozilla.org/en/firefox/addon/ultrawidify/) and [Chrome](https://chrome.google.com/webstore/detail/ultrawidify/dndehlekllfkaijdlokmmicgnlanfjbi). Should support theater mode on youtube, iframes only supported on fullscreen. +### Limitations -Youtube demo of autodetection stuff can be found [here](https://www.youtube.com/watch?v=j2xn1WpbtCQ). +* Unclear how extension handles sites with more than one video per page. +* Autodetection is only correct 95% of the time, most of the time. +* That new stretching mode wasn't thoroughly tested yet. Issues may be present. +* Enabling extension everywhere (as opposed to whitelisted sites) could break some websites. -## Beggathon +### Features + +* **Can be enabled or disabled on per-site basis** +* **Crop video to fit screen** (no stretching. Supported aspect ratios: 21/9 (1:2.39), 16:9, 16:10, _one (1) custom aspect ratio_) +* **Automatic aspect ratio detection** (can be enabled/disabled entirely or on a per-site basis, separately of the extension. Autodetection in action: [youtube](https://www.youtube.com/watch?v=j2xn1WpbtCQ)) +* **[NEW in v3!] Stretch video to fit the screen** (4 different approaches) +* **Supports Youtube theater mode** + +### Officially supported sites + +* Youtube +* Netflix + +### Other sites + +I am not actively testing extension on other sites. You can try your luck and enable extension for any unsupported site you stumble across via extension popup (in the _Setting for this site_ menu), but I make no guarantees it will work everywhere. + +### Installing this extension + +You can download this extension from Firefox' and Chrome's extension stores: + +* [Firefox](https://addons.mozilla.org/en/firefox/addon/ultrawidify/) (v3.0.0) +* [Chrome](https://chrome.google.com/webstore/detail/ultrawidify/dndehlekllfkaijdlokmmicgnlanfjbi) (v2.2.5-ish) + +### Beggathon Working on this extension takes time, coffee and motivation. If you want to buy me a beer or something, you can [use this link to send me motivation](https://www.paypal.me/tamius). **Any donations are well appreciated.** -## The long version +  + +  + +  + +  + +# The long version The technology has been here for a while, but plenty of people don't know how to properly encode a video (despite the fact [youtube has an article that explains aspect ratios](https://support.google.com/youtube/answer/6375112)). Plenty of people surprisingly includes major Holywood studios, such as [Marvel](https://www.youtube.com/watch?v=Ke1Y3P9D0Bc), [Disney](https://www.youtube.com/watch?v=yCOPJi0Urq4), [Dreamworks](https://www.youtube.com/watch?v=oKiYuIsPxYk), [Warner Brothers](https://www.youtube.com/watch?v=VYZ3U1inHA4), [Sony](https://www.youtube.com/watch?v=7BWWWQzTpNU), et cetera. You'd think that this is the one thing Holywood studios and people who make [music videos for a living](https://www.youtube.com/watch?v=c6Mx2mxpaCY) would know how to do right, but they don't. This extension is here to fix that. @@ -22,15 +57,6 @@ The technology has been here for a while, but plenty of people don't know how to ## Features -(Note: this readme is being written ahead of time, so not all features described here are available in the store version of the extension. Firefox users can expect these features by, at latest, 1st of August. Chrome version may take a little longer.) - -TL;DR: - -* **Can be enabled or disabled on per-site basis** -* **Crop video to fit screen** (no stretching. Supported aspect ratios: 21/9 (1:2.39), 16:9, 16:10, _one custom aspect ratio_) -* **Automatic aspect ratio detection** (can be enabled/disabled entirely or on a per-site basis, separately of the extension) -* **[NEW in v3!] Stretch video to fit the screen** (4 different approaches) - Most settings are self-explanatory, but we'll get into details anyway. ### Limitations: @@ -56,8 +82,7 @@ In the **Options for this site** section, there's some sidenotes to be had: ### Automatic aspect ratio detection -There's a few caveats to automatic aspect ratio detection. Namely, it only works on HTML5 videos (but who doesn't use HTML5 these days?). If videos on the site are DRM-protected (e.g. Netflix), autodetection will not work unless you're using Firefox (and even then, no guarantees). - +There's a few caveats to automatic aspect ratio detection. Namely, it only works on HTML5 videos (but who doesn't use HTML5 these days?). If videos on the site are DRM-protected (e.g. Netflix), autodetection will not work unless you're using Firefox (and even then, no guarantees). Video demonstration of autodetection can be found [here](https://www.youtube.com/watch?v=j2xn1WpbtCQ). ![Demo](img-demo/ui/popup/autoar.png) @@ -134,9 +159,9 @@ They still aren't rebindable. ### Permanent install / stable -[Latest stable for Firefox — download from AMO](https://addons.mozilla.org/en/firefox/addon/ultrawidify/) +[Latest stable for Firefox — download from AMO](https://addons.mozilla.org/en/firefox/addon/ultrawidify/) (v3.0.0) -[Latest stafle for Chrome — download from Chrome store](https://chrome.google.com/webstore/detail/ultrawidify/dndehlekllfkaijdlokmmicgnlanfjbi) +[Latest stafle for Chrome — download from Chrome store](https://chrome.google.com/webstore/detail/ultrawidify/dndehlekllfkaijdlokmmicgnlanfjbi) (v2.2.5) ### Installing the current, github version @@ -153,13 +178,13 @@ They still aren't rebindable. ## Plans for the future -~~1. Handle porting of extension settings between versions. (Some people had some issues where extension broke until reinstalled, and corrupted settings seemed to be the problem.)~~ seems to work for me? -2. Reintroduce gradual zoom on z and u and provide a way to 'scroll' the zoomed in video up/down left/right -reintroduce settings page (rebindable keys, blacklist/whitelist management, some settings for automatic aspect ratio detection) -3. site-specific options for sites that require additional CSS classes or other hacks -4. figure the best way to do GUI (injecting buttons into the player bar is not a good way. Been there, done that, each site has its own way and some appear to be impossible). Might get bumped to be released alongside #2 -~~5. Stretch mode, because some people are very salty and toxic about the fact that this extension is here to solve a problem that's different than the one they want. More salty than me rn.~~ done -6. Improvements to automatic aspect ratio detection +1. ~~Handle porting of extension settings between versions. (Some people had some issues where extension broke until reinstalled, and corrupted settings seemed to be the problem.)~~ seems to work for me? +2. Reintroduce gradual zoom on z and u and provide a way to 'scroll' the zoomed in video up/down left/right. +3. reintroduce settings page (rebindable keys, blacklist/whitelist management, some settings for automatic aspect ratio detection) +4. site-specific options for sites that require additional CSS classes or other hacks +5. figure the best way to do GUI (injecting buttons into the player bar is not a good way. Been there, done that, each site has its own way and some appear to be impossible). Might get bumped to be released alongside #2 +6. ~~Stretch mode, because some people are very salty and toxic about the fact that this extension is here to solve a problem that's different than the one they want. More salty than me rn.~~ done +7. Improvements to automatic aspect ratio detection ## Changelog diff --git a/js/conf/Debug.js b/js/conf/Debug.js index 28d7ecf..efd99fe 100644 --- a/js/conf/Debug.js +++ b/js/conf/Debug.js @@ -7,8 +7,8 @@ Debug = { keyboard: true, debugResizer: true, debugArDetect: true, - debugStorage: true, - comms: true, + debugStorage: false, + comms: false, // showArDetectCanvas: true, flushStoredSettings: false, playerDetectDebug: true, diff --git a/js/conf/ExtensionConf.js b/js/conf/ExtensionConf.js index e9fd5cb..fd8ac87 100644 --- a/js/conf/ExtensionConf.js +++ b/js/conf/ExtensionConf.js @@ -31,7 +31,7 @@ var ExtensionConf = { vSamples: 360, // samplingInterval: 10, // we sample at columns at (width/this) * [ 1 .. this - 1] blackLevel_default: 10, // everything darker than 10/255 across all RGB components is considered black by - // default. GlobalVars.blackLevel can decrease if we detect darker black. + // default. blackLevel can decrease if we detect darker black. blackbarTreshold: 16, // if pixel is darker than blackLevel + blackbarTreshold, we count it as black // on 0-255. Needs to be fairly high (8 might not cut it) due to compression // artifacts in the video itself @@ -194,13 +194,15 @@ var ExtensionConf = { status: "enabled", // should extension work on this site? arStatus: "default", // should we enable autodetection statusEmbedded: "enabled", // should extension work for this site when embedded on other sites? - override: true // ignore value localStorage in favour of this + override: false, // ignore value localStorage in favour of this + type: 'official' // is officially supported? (Alternatives are 'community' and 'user-defined') }, "www.netflix.com" : { status: "enabled", arStatus: BrowserDetect.firefox ? "default" : "disabled", statusEmbedded: "enabled", - override: true + override: false, + type: 'official' }, } } diff --git a/js/conf/Keybinds.js b/js/conf/Keybinds.js index dd90121..e27bf2e 100644 --- a/js/conf/Keybinds.js +++ b/js/conf/Keybinds.js @@ -4,6 +4,7 @@ if(Debug.debug) class Keybinds { constructor(pageInfo){ this.pageInfo = pageInfo; + this.settings = pageInfo.settings; this.inputs = ['input','select','button','textarea']; } @@ -36,7 +37,7 @@ class Keybinds { // building modifiers list: var modlist = ""; - for(var mod of ExtensionConf.keyboard.modKeys){ + for(var mod of this.settings.active.keyboard.modKeys){ if(event[mod]) modlist += (mod + "_") } @@ -52,8 +53,8 @@ class Keybinds { console.log("[Keybinds::_kbd_process] our full keypress is this", keypress ); - if(ExtensionConf.keyboard.shortcuts[keypress]){ - var conf = ExtensionConf.keyboard.shortcuts[keypress]; + if(this.settings.active.keyboard.shortcuts[keypress]){ + var conf = this.settings.active.keyboard.shortcuts[keypress]; if(Debug.debug && Debug.keyboard) console.log("[Keybinds::_kbd_process] there's an action associated with this keypress. conf:", conf); diff --git a/js/conf/Settings.js b/js/conf/Settings.js deleted file mode 100644 index 2f1625a..0000000 --- a/js/conf/Settings.js +++ /dev/null @@ -1,169 +0,0 @@ -// This file handles saving and loading of settings. -// Actual settings are in ExtensionConf - -if(Debug.debug) - console.log("Loading: Settings.js"); - -var _se_init = async function(isSlave){ - - if(Debug.debug) - console.log("[Settings::_se_init()] -------- starting init! ---------"); - - if(isSlave === undefined) - isSlave = false; - - if(isSlave){ - // request settings from background script. Yes, this is supposed to be global. - var res = await Comms.sendToBackgroundScript({cmd: "gib-settings"}); - - ExtensionConf = res.response; - - if(Debug.debug){ - console.log("[Settings::_se_init()] received settings from the background script. ExtensionConf:",ExtensionConf,"response message was this:",res); - } - - return; - } - - - var newSettings = await StorageManager.getopt_async("uw-settings"); - var uwVersion = browser.runtime.getManifest().version; - - if (Debug.debug) - console.log("[Settings::_se_init()] settings saved in localstorage are:", newSettings, " - if that's empty, it's gonna be replaced by this:", ExtensionConf, ")"); - - if ((Object.keys(newSettings).length === 0 && newSettings.constructor === Object)){ - if(Debug.debug) - console.log("[Settings::_se_init()] no saved settings, saving default"); - StorageManager.setopt({"uw-settings": ExtensionConf}); - } - else{ - var actualSettings = newSettings["uw-settings"]; - if(actualSettings.version === undefined || actualSettings.version != uwVersion){ - ExtensionConf['version'] = uwVersion; - - if(Debug.debug) - console.log("[Settings::_se_init()] extension was updated, replacing settings", ExtensionConf); - - StorageManager.setopt({"uw-settings": ExtensionConf}); - } - else{ - _se_patchUserSettings(actualSettings, ExtensionConf); - } - if(Debug.debug) - console.log("[Settings::_se_init()] parsed settings:", actualSettings, "were they copied to ExtensionConf?",ExtensionConf); - - } - - if(Debug.debug) - console.log("[Settings::_se_init] settings have been loaded/reloaded. Current state: ", ExtensionConf); - -} - -var _se_patchUserSettings = function(saved, extDefaults){ - for(var k in extDefaults){ - if(extDefaults[k] != null && typeof extDefaults[k] === 'object' && extDefaults[k].constructor === Object){ - if(typeof saved[k] !== 'object' || saved[k].constructor !== Object || extDefaults[k].override === true) - continue; // if user's settings are wrong or if override flag is set, we keep value in extDefaults - - _se_patchUserSettings(saved[k], extDefaults[k]); - } - else{ - extDefaults[k] = saved[k]; - } - } -} - -var _se_save = function(settings){ - StorageManager.delopt("uw-settings"); - - if(settings !== undefined){ - StorageManager.setopt({"uw-settings": settings}); - } - else{ - StorageManager.setopt({"uw-settings": ExtensionConf}); - } - - if (Debug.debug) - console.log("[Settings::_se_save()] saving settings:", settings); -} - -var _se_reload = function(){ - this.init(true); -} - -var _se_isBlacklisted = function(site){ - return this.blacklist.indexOf(site) > -1; -} - -var _se_isWhitelisted = function(site){ - return this.whitelist.indexOf(site) > -1; -} - -var Settings = { - init: _se_init, - save: _se_save, - reload: _se_reload, -} - - -// ----------------------------------------- -// Nastavitve za posamezno stran -// Config for a given page: -// -// : { -// status: