Fixed some issues with detecting player size changes (esp. on youtube), where switching from normal player to full screen player wouldn't be handled correctly.

This commit is contained in:
Tamius Han 2018-03-14 23:51:13 +01:00
parent dcd430d05e
commit 61a3b07c6b
5 changed files with 50 additions and 8 deletions

View File

@ -1,6 +1,6 @@
// Set prod to true when releasing
_prod = true;
// _prod = false;
_prod = false;
Debug = {
debug: true,

View File

@ -104,14 +104,16 @@ var _pd_getPlayerDimensions = function(startElement){
dims = {
width: window.innerWidth,
height: window.innerHeight,
element: "fullscreen"
element: null,
fullscreen: true
}
}
else{
dims = {
width: candidate_width,
height: candidate_height,
element: playerCandidateNode
element: playerCandidateNode,
fullscreen: isFullScreen
};
}
@ -121,15 +123,30 @@ var _pd_getPlayerDimensions = function(startElement){
// returns 'true' if there was a change.
var _pd_checkPlayerSizeChange = function(){
if(Debug.debug){
if(GlobalVars.playerDimensions.element == undefined)
console.log("[PlayerDetect] player size changed. reason: player element undefined");
if(GlobalVars.playerDimensions.fullscreen){
if(! _pd_isFullScreen()){
console.log("[PlayerDetect] player size changed. reason: exited fullscreen");
}
}
if(GlobalVars.playerDimensions.width != GlobalVars.playerDimensions.element.offsetWidth || GlobalVars.playerDimensions.height != GlobalVars.playerDimensions.element.offsetHeight ){
console.log("[PlayerDetect] player size changed. reason: dimension change");
}
}
if(GlobalVars.playerDimensions.element == undefined)
return true;
if(GlobalVars.playerDimensions.element === "fullscreen"){
return ! isFullScreen();
if(GlobalVars.playerDimensions.fullscreen){
return ! _pd_isFullScreen();
}
if(GlobalVars.playerDimensions.width != GlobalVars.playerDimensions.element.offsetWidth || GlobalVars.playerDimensions.height != GlobalVars.playerDimensions.element.offsetHeight ){
return true;
}

View File

@ -106,7 +106,7 @@ var _res_setAr = function(ar){
if(Debug.debug)
console.log("[Resizer::_res_setAr] video:",vid,"width:", vid.videoWidth, "height:", vid.videoHeight);
// Dejansko razmerje stranic datoteke/<video> značke
// // Dejansko razmerje stranic datoteke/<video> značke
// Actual aspect ratio of the file/<video> tag
var fileAr = vid.videoWidth / vid.videoHeight;

View File

@ -125,6 +125,12 @@ function ghettoOnChange(){
}
if(PlayerDetect.checkPlayerSizeChange()){
if(Debug.debug){
console.log("[uw::ghettoOnChange] change detected");
}
GlobalVars.playerDimensions = PlayerDetect.getPlayerDimensions( GlobalVars.video );
if(GlobalVars.playerDimensions == undefined){
@ -134,6 +140,25 @@ function ghettoOnChange(){
Resizer.restore();
}
// sometimes, checkPlayerSizeChange might not detect a change to fullscreen. This means we need to
// trick it into doing that
if(GlobalVars.playerDimensions.fullscreen != PlayerDetect.isFullScreen()){
if(Debug.debug){
console.log("[uw::ghettoOnChange] fullscreen switch detected");
}
GlobalVars.playerDimensions = PlayerDetect.getPlayerDimensions(GlobalVars.video);
if(GlobalVars.playerDimensions == undefined){
GlobalVars.playerDimensions = null;
return;
}
Resizer.restore();
}
}
function ghettoUrlWatcher(){

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Ultrawidify",
"version": "2.2.1",
"version": "2.2.2",
"icons": {
"32":"res/icons/uw-32.png",