From a95fd1a9ecb26e7b87a842048d03523d175266bd Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Sat, 22 Sep 2018 00:57:46 -0500 Subject: [PATCH] Fixed floating player issue. --- src/manifest.json | 2 +- src/scripts/betterYoutube.js | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index 507eddd..25e2a61 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Better Youtube +", - "version": "1.2.8", + "version": "1.2.9", "description": "Enhancements for Youtube to have a better experience.", "applications": { diff --git a/src/scripts/betterYoutube.js b/src/scripts/betterYoutube.js index 806144c..c5575ed 100644 --- a/src/scripts/betterYoutube.js +++ b/src/scripts/betterYoutube.js @@ -12,7 +12,7 @@ function betterYoutubePlus() { var count = 0; function preSetupProc() { - video = document.getElementsByTagName("video")[0]; // Video Controler + video = document.getElementsByTagName("video")[0]; // Video Controler slugInputTag = document.createElement("INPUT"); slugInputTag.id = "slugCopyZone"; slugInputTag.type = "text"; @@ -44,7 +44,7 @@ function betterYoutubePlus() { ytASdDefaultImg = document.createElement("A"); // Get nodes for page work - containerOfPlyrWndow = document.getElementById("player-container"); // Container of actual player - Used for floating window + containerOfPlyrWndow = document.getElementById("player-container"); // Container of actual player - Used for floating window part = "https://img.youtube.com/vi/"; // Append to nodes as required @@ -149,17 +149,30 @@ function betterYoutubePlus() { } function toggleFloat() { - playerWindow = document.getElementById("player-container").children[1]; // Actual player + var playerWindow = document.getElementById("movie_player"); // Actual player if(poppedContainer.style.display == "none"){ + setVideoStyle("auto", "auto", "50%"); poppedContainer.appendChild(playerWindow); poppedContainer.style.display = "block"; + } else { + setVideoStyle(containerOfPlyrWndow.offsetWidth + "px", + containerOfPlyrWndow.offsetHeight + "px", ""); containerOfPlyrWndow.append(playerWindow); poppedContainer.style.display = "none"; } } + function setVideoStyle(w, h, pr) { + var elm = document.getElementsByClassName("ytp-right-controls")[0]; + video.style.width = w; + video.style.height = h; + elm.style.paddingRight = pr; + console.log("W: " + w + "\nH: " + h + "\npr: " + pr); + console.log(video.style); + } + function manageVolume(e) { var delta; e.preventDefault(); // Keep page from scrolling while in video area