Fixed the issue where fullscreen videos wouldn't be entirely fullscreen on youtube.

This commit is contained in:
Tamius Han 2018-03-10 12:30:38 +01:00
parent 2849bf5d85
commit a5422abfcd
2 changed files with 59 additions and 21 deletions

View File

@ -57,9 +57,9 @@ Manually triggering aspect ratio change will suspend automatic aspect ratio dete
### Permanent install / stable ### Permanent install / stable
[v2.1.0 — Regular version — 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/)
[v2.1.0 — Regular version — 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)
### Installing the current, github version ### Installing the current, github version
@ -75,12 +75,28 @@ Manually triggering aspect ratio change will suspend automatic aspect ratio dete
## Plans for the future ## Plans for the future
* Edge port 0. Memory leak bugfix (soon™)
* Improvements to autodetection 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.)
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 (see: vimeo, which is disable)
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.
## Changelog ## Changelog
### v2.2.0a1 (Git - unstable)
Various improvements to automatic aspect ratio detection:
* **Fixed the issues with insane memory usage (#25, #32) and lag that appeared in certain cases after the extension has been running for a while**
* Improved accuracy of automatic detection. This should fix the issue of rapid switching in dark videos or videos with otherwise uneven edges (#12 - [video](https://www.youtube.com/watch?v=NaTGwlfRB_c); #24 - [video](https://www.youtube.com/watch?v=xvZqHgFz51I) (see the car at the beginning))
Improved accuracy has increased the base RAM usage. Expect 30-300 MB (in some cases up to 500 MB) per video that's currently playing. (Videos that aren't playing (e.g. videos that are paused or ended) do (should) ***not*** use any meaningful amount of RAM).
* Overpass font is now bundled with this extension, meaning the popup should appear the way it was meant to appear™.
### v2.1.4 (FF/AMO) ### v2.1.4 (FF/AMO)
* Extension has been disabled on imgur (it was breaking gifs) * Extension has been disabled on imgur (it was breaking gifs)

View File

@ -32,8 +32,9 @@ var _pd_isFullScreen = function(){
var _pd_getPlayerDimensions = function(element){ var _pd_getPlayerDimensions = function(startElement){
var element = startElement;
if(element == null || element == undefined){ if(element == null || element == undefined){
if(Debug.debug) if(Debug.debug)
@ -42,6 +43,7 @@ var _pd_getPlayerDimensions = function(element){
return; return;
} }
var isFullScreen = _pd_isFullScreen();
var trustCandidateAfterGrows = 2; // if candidate_width or candidate_height increases in either dimensions this many var trustCandidateAfterGrows = 2; // if candidate_width or candidate_height increases in either dimensions this many
// times, we say we found our player. (This number ignores weird elements) // times, we say we found our player. (This number ignores weird elements)
@ -49,7 +51,7 @@ var _pd_getPlayerDimensions = function(element){
// if site is coded properly, player can't be wider than that // if site is coded properly, player can't be wider than that
var candidate_width = Math.max(element.offsetWidth, window.innerWidth); var candidate_width = Math.max(element.offsetWidth, window.innerWidth);
var candidate_height = Math.max(element.offsetHeight, window.innerHeight); var candidate_height = Math.max(element.offsetHeight, window.innerHeight);
var playerCandidateNode = element; var playerCandidateNode = startElement;
// <video> can't be root in a document, so we can do this // <video> can't be root in a document, so we can do this
element = element.parentNode; element = element.parentNode;
@ -67,15 +69,19 @@ var _pd_getPlayerDimensions = function(element){
if ( element.offsetHeight <= candidate_height && if ( element.offsetHeight <= candidate_height &&
element.offsetWidth <= candidate_width ){ element.offsetWidth <= candidate_width ){
playerCandidateNode = element; // if we're in fullscreen, we only consider elements that are exactly as big as the monitor.
candidate_width = element.offsetWidth; if( ! isFullScreen ||
candidate_height = element.offsetHeight; (element.offsetWidth == window.innerWidth && element.offsetHeight == window.innerHeight) ){
playerCandidateNode = element;
candidate_width = element.offsetWidth;
candidate_height = element.offsetHeight;
grows = trustCandidateAfterGrows; grows = trustCandidateAfterGrows;
if(Debug.debug){ if(Debug.debug){
console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height, "node:", playerCandidateNode); console.log("Found new candidate for player. Dimensions: w:", candidate_width, "h:",candidate_height, "node:", playerCandidateNode);
}
} }
} }
else if(grows --<= 0){ else if(grows --<= 0){
@ -92,11 +98,22 @@ var _pd_getPlayerDimensions = function(element){
catch(e){ catch(e){
console.log("pdeeee,",e); console.log("pdeeee,",e);
} }
var dims = { var dims;
width: candidate_width,
height: candidate_height, if(isFullScreen && playerCandidateNode == startElement){
element: playerCandidateNode dims = {
}; width: window.innerWidth,
height: window.innerHeight,
element: "fullscreen"
}
}
else{
dims = {
width: candidate_width,
height: candidate_height,
element: playerCandidateNode
};
}
return dims; return dims;
} }
@ -107,7 +124,12 @@ var _pd_checkPlayerSizeChange = function(){
if(GlobalVars.playerDimensions.element == undefined) if(GlobalVars.playerDimensions.element == undefined)
return true; return true;
if(GlobalVars.playerDimensions.element === "fullscreen"){
return ! isFullScreen();
}
if(GlobalVars.playerDimensions.width != GlobalVars.playerDimensions.element.offsetWidth || GlobalVars.playerDimensions.height != GlobalVars.playerDimensions.element.offsetHeight ){ if(GlobalVars.playerDimensions.width != GlobalVars.playerDimensions.element.offsetWidth || GlobalVars.playerDimensions.height != GlobalVars.playerDimensions.element.offsetHeight ){
return true; return true;
} }