Fixed floating container, added ranged loop, removed old code.
This commit is contained in:
parent
e4133ffa3a
commit
0f215bb645
|
@ -4,6 +4,7 @@ Better YouTube + works to improve the YouTube experience by providing quick acce
|
||||||
<br/>
|
<br/>
|
||||||
* It allows quick thumbnail access of the video.
|
* It allows quick thumbnail access of the video.
|
||||||
* It allows setting the loop mode easily.
|
* It allows setting the loop mode easily.
|
||||||
|
* It allows setting the loop mode to a ranged set.
|
||||||
* It allows the video to be toggled to fixed or floating with drag functionality.
|
* It allows the video to be toggled to fixed or floating with drag functionality.
|
||||||
* It allows volume control through the mouse-wheel when hovering over the player.
|
* It allows volume control through the mouse-wheel when hovering over the player.
|
||||||
* It allows for quick access to the YouTube video slug.
|
* It allows for quick access to the YouTube video slug.
|
||||||
|
@ -11,5 +12,7 @@ Better YouTube + works to improve the YouTube experience by providing quick acce
|
||||||
# Download
|
# Download
|
||||||
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/
|
https://addons.mozilla.org/en-US/firefox/addon/better-youtube-plus/
|
||||||
|
|
||||||
# Version: 1.3.0
|
# Version: 1.3.5
|
||||||
Fixed video player in full-screen being behind controls.
|
Added ranged loop feature.
|
||||||
|
Fixed finally floating video issues.
|
||||||
|
Removed non-working image onerror signals.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Better Youtube +",
|
"name": "Better Youtube +",
|
||||||
"version": "1.3.0",
|
"version": "1.3.5",
|
||||||
"description": "Enhancements for Youtube to have a better experience.",
|
"description": "Enhancements for Youtube to have a better experience.",
|
||||||
|
|
||||||
"applications": {
|
"applications": {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const betterYoutubePlus = () => {
|
(function() {
|
||||||
|
|
||||||
// Declare variables
|
// Declare variables
|
||||||
let slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems
|
let slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems
|
||||||
|
@ -7,15 +7,31 @@ const betterYoutubePlus = () => {
|
||||||
|
|
||||||
let mastHead, mainContentArea, playerWindow; // Youtube Player container
|
let mastHead, mainContentArea, playerWindow; // Youtube Player container
|
||||||
let video, containerOfPlyrWndow, poppedContainer; // Video accessor
|
let video, containerOfPlyrWndow, poppedContainer; // Video accessor
|
||||||
let vdoPlyrAtts; // Player attributes
|
|
||||||
let part, videoSlug, temp; // Image part
|
let part, videoSlug, temp; // Image part
|
||||||
|
let videoTimeLength, videoTimeCurent, ytRangeStart, ytRangeEnd,
|
||||||
|
ytdVideoIntervalLoop;
|
||||||
|
let loopingInterval = false;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
const preSetupProc = () => {
|
const preSetupProc = () => {
|
||||||
video = document.getElementsByTagName("video")[0]; // Video Controler
|
video = document.getElementsByTagName("video")[0]; // Video Controler
|
||||||
slugInputTag = document.createElement("INPUT");
|
slugInputTag = document.createElement("INPUT");
|
||||||
|
ytRangeEnd = document.createElement("INPUT");
|
||||||
|
|
||||||
slugInputTag.id = "slugCopyZone";
|
slugInputTag.id = "slugCopyZone";
|
||||||
|
ytRangeEnd.id = "rangeEndID";
|
||||||
slugInputTag.type = "text";
|
slugInputTag.type = "text";
|
||||||
|
ytRangeEnd.type = "text";
|
||||||
|
|
||||||
|
// We need to wait for info to load before getting full duration
|
||||||
|
setTimeout(function () {
|
||||||
|
videoTimeLength = document.getElementsByClassName("ytp-time-duration")[0].innerHTML;
|
||||||
|
if (!document.getElementById("rangeEndID")) {
|
||||||
|
} else {
|
||||||
|
ytRangeEnd = document.getElementById("rangeEndID");
|
||||||
|
}
|
||||||
|
ytRangeEnd.value = videoTimeLength;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
if (!document.getElementById("slugCopyZone")) {
|
if (!document.getElementById("slugCopyZone")) {
|
||||||
document.body.appendChild(slugInputTag);
|
document.body.appendChild(slugInputTag);
|
||||||
|
@ -23,8 +39,7 @@ const betterYoutubePlus = () => {
|
||||||
slugInputTag = document.getElementById("slugCopyZone");
|
slugInputTag = document.getElementById("slugCopyZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
vdoPlyrAtts = video.baseURI; // Used for setting up thumbnails
|
slugInputTag.value = video.baseURI.slice(32, 32+11);
|
||||||
slugInputTag.value = vdoPlyrAtts.slice(32, 32+11);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setupProc = () => {
|
const setupProc = () => {
|
||||||
|
@ -42,6 +57,11 @@ const betterYoutubePlus = () => {
|
||||||
ytAHqDefaultImg = document.createElement("A");
|
ytAHqDefaultImg = document.createElement("A");
|
||||||
ytAMedDefaultImg = document.createElement("A");
|
ytAMedDefaultImg = document.createElement("A");
|
||||||
ytASdDefaultImg = document.createElement("A");
|
ytASdDefaultImg = document.createElement("A");
|
||||||
|
ytIfrm = document.createElement("IFRAME");
|
||||||
|
|
||||||
|
// Loop range controls
|
||||||
|
ytRangeSection = document.createElement("SECTION");
|
||||||
|
ytRangeStart = document.createElement("INPUT");
|
||||||
|
|
||||||
// Get nodes for page work
|
// 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
|
||||||
|
@ -51,12 +71,18 @@ const betterYoutubePlus = () => {
|
||||||
ytThumbnailBttn.title = "Video Thumbnails...";
|
ytThumbnailBttn.title = "Video Thumbnails...";
|
||||||
ytLoopBttn.title = "Start Loop...";
|
ytLoopBttn.title = "Start Loop...";
|
||||||
ytFloatBttn.title = "Float Video Container";
|
ytFloatBttn.title = "Float Video Container";
|
||||||
|
ytRangeStart.title = "Loop Range Start";
|
||||||
ytEnhancerMenu.appendChild(ytThumbnailBttn);
|
ytRangeEnd.title = "Loop Range End";
|
||||||
ytEnhancerMenu.appendChild(ytLoopBttn);
|
ytRangeStart.type = "text";
|
||||||
ytEnhancerMenu.appendChild(ytFloatBttn);
|
ytRangeStart.value = "0:00";
|
||||||
|
|
||||||
// Insert
|
// Insert
|
||||||
|
ytEnhancerMenu.appendChild(ytThumbnailBttn);
|
||||||
|
ytEnhancerMenu.appendChild(ytLoopBttn);
|
||||||
|
ytEnhancerMenu.appendChild(ytRangeSection);
|
||||||
|
ytEnhancerMenu.appendChild(ytFloatBttn);
|
||||||
|
ytRangeSection.append(ytRangeStart);
|
||||||
|
ytRangeSection.append(ytRangeEnd);
|
||||||
document.body.appendChild(poppedContainer);
|
document.body.appendChild(poppedContainer);
|
||||||
document.body.appendChild(ytThumbImgMenu);
|
document.body.appendChild(ytThumbImgMenu);
|
||||||
document.body.appendChild(ytEnhancerMenu);
|
document.body.appendChild(ytEnhancerMenu);
|
||||||
|
@ -68,6 +94,7 @@ const betterYoutubePlus = () => {
|
||||||
ytThumbImgMenu.appendChild(ytAHqDefaultImg);
|
ytThumbImgMenu.appendChild(ytAHqDefaultImg);
|
||||||
ytThumbImgMenu.appendChild(ytAMedDefaultImg);
|
ytThumbImgMenu.appendChild(ytAMedDefaultImg);
|
||||||
ytThumbImgMenu.appendChild(ytASdDefaultImg);
|
ytThumbImgMenu.appendChild(ytASdDefaultImg);
|
||||||
|
poppedContainer.appendChild(ytIfrm);
|
||||||
|
|
||||||
// Set onclick actions
|
// Set onclick actions
|
||||||
ytThumbnailBttn.addEventListener("click", showThumbImageVew);
|
ytThumbnailBttn.addEventListener("click", showThumbImageVew);
|
||||||
|
@ -100,7 +127,16 @@ const betterYoutubePlus = () => {
|
||||||
ytFloatBttn.className = "imageStyle";
|
ytFloatBttn.className = "imageStyle";
|
||||||
ytEnhancerMenu.id = "enhancerMenuIDRef";
|
ytEnhancerMenu.id = "enhancerMenuIDRef";
|
||||||
poppedContainer.id = "draggable";
|
poppedContainer.id = "draggable";
|
||||||
|
ytRangeStart.id = "rangeStartID";
|
||||||
|
ytRangeEnd.id = "rangeEndID";
|
||||||
poppedContainer.style.display = "none";
|
poppedContainer.style.display = "none";
|
||||||
|
|
||||||
|
ytIfrm.setAttribute("allow", "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture");
|
||||||
|
ytIfrm.setAttribute("frameborder", "0");
|
||||||
|
ytIfrm.setAttribute("autoplay", "");
|
||||||
|
ytIfrm.setAttribute("allowfullscreen", "true");
|
||||||
|
ytIfrm.setAttribute("width", "650px");
|
||||||
|
ytIfrm.setAttribute("height", "400px");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
@ -124,11 +160,6 @@ const betterYoutubePlus = () => {
|
||||||
ytMqDefaultImg.title = "Medium Quality Default";
|
ytMqDefaultImg.title = "Medium Quality Default";
|
||||||
ytSdDefaultImg.title = "Standard Quality Default";
|
ytSdDefaultImg.title = "Standard Quality Default";
|
||||||
|
|
||||||
ytMaxDefaultImg.onerror = function() { ytMaxDefaultImg.src = "/icons/missing.png"; }
|
|
||||||
ytHqDefaultImg.onerror = function() { ytHqDefaultImg.src = "/icons/missing.png"; }
|
|
||||||
ytAMedDefaultImg.onerror = function() { ytAMedDefaultImg.src = "/icons/missing.png"; }
|
|
||||||
ytASdDefaultImg.onerror = function() { ytASdDefaultImg.src = "/icons/missing.png"; }
|
|
||||||
|
|
||||||
ytThumbnailBttn.src = browser.extension.getURL("/icons/thumbnailOn.png");
|
ytThumbnailBttn.src = browser.extension.getURL("/icons/thumbnailOn.png");
|
||||||
ytThumbImgMenu.style.display = "block";
|
ytThumbImgMenu.style.display = "block";
|
||||||
}
|
}
|
||||||
|
@ -136,31 +167,93 @@ const betterYoutubePlus = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const setLoop = (e) => {
|
const setLoop = (e) => {
|
||||||
|
let start = ytRangeStart.value.trim();
|
||||||
|
let end = ytRangeEnd.value.trim();
|
||||||
|
|
||||||
|
if (loopingInterval) {
|
||||||
|
console.log("Unsetting interval for loop check...");
|
||||||
|
clearInterval(ytdVideoIntervalLoop);
|
||||||
|
loopingInterval = false;
|
||||||
|
ytLoopBttn.title = "Start Loop...";
|
||||||
|
ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start.includes("0:00") && end.includes(videoTimeLength)) {
|
||||||
if (video.loop == false) {
|
if (video.loop == false) {
|
||||||
|
console.log("Setting default loop marker...");
|
||||||
video.loop = true;
|
video.loop = true;
|
||||||
ytLoopBttn.title = "Stop Loop...";
|
ytLoopBttn.title = "Stop Loop...";
|
||||||
ytLoopBttn.src = browser.extension.getURL("/icons/loopTrue.png");
|
ytLoopBttn.src = browser.extension.getURL("/icons/loopTrue.png");
|
||||||
} else {
|
} else {
|
||||||
ytLoopBttn.title = "Start Loop...";
|
console.log("Unsetting default loop marker...");
|
||||||
video.loop = false;
|
video.loop = false;
|
||||||
|
ytLoopBttn.title = "Start Loop...";
|
||||||
ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png");
|
ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png");
|
||||||
}
|
}
|
||||||
return ;
|
return ;
|
||||||
|
} else {
|
||||||
|
const getTotalSize = (array) => {
|
||||||
|
let size = 0.0;
|
||||||
|
let hours = 0.0;
|
||||||
|
let minutes = 0.0;
|
||||||
|
let seconds = 0.0;
|
||||||
|
|
||||||
|
if (array.length === 2) {
|
||||||
|
minutes = parseFloat(array[0]) * 60.0;
|
||||||
|
seconds = parseFloat(array[1]);
|
||||||
|
size = minutes + seconds;
|
||||||
|
} else if (array.length === 3) {
|
||||||
|
hours = parseFloat(array[0]) * 3600.0;
|
||||||
|
minutes = parseFloat(array[1]) * 60.0;
|
||||||
|
seconds = parseFloat(array[2]);
|
||||||
|
size = hours + minutes + seconds;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkLoopStuff = () => {
|
||||||
|
videoTimeCurent = video.currentTime;
|
||||||
|
if (videoTimeCurent > totalEnd ||
|
||||||
|
videoTimeCurent < totalStart) {
|
||||||
|
video.currentTime = totalStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Make sure start and end are proper
|
||||||
|
let totalStart = getTotalSize(start.split(":"));
|
||||||
|
let totalEnd = getTotalSize(end.split(":"));
|
||||||
|
if (totalStart < 0.0 || totalStart > video.duration) { return ; }
|
||||||
|
if (totalEnd < 0.0 || totalEnd > video.duration) { return ; }
|
||||||
|
|
||||||
|
// Setup interval check for 1 sec and compare value of current pos to end
|
||||||
|
ytLoopBttn.title = "Stop Loop...";
|
||||||
|
ytLoopBttn.src = browser.extension.getURL("/icons/loopTrue.png");
|
||||||
|
loopingInterval = true;
|
||||||
|
|
||||||
|
console.log("Setting interval for loop check...");
|
||||||
|
ytdVideoIntervalLoop = setInterval(checkLoopStuff, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleFloat = () => {
|
const toggleFloat = () => {
|
||||||
let playerWindow = document.getElementById("movie_player"); // Actual player
|
let mainPlayer = document.getElementById("player-container-outer");
|
||||||
|
var ifrmBody = (ytIfrm.contentWindow || ytIfrm.contentDocument);
|
||||||
|
if (ifrmBody.document) ifrmBody = ifrmBody.document;
|
||||||
|
|
||||||
if (poppedContainer.style.display == "none"){
|
if (poppedContainer.style.display == "none"){
|
||||||
setVideoStyle("auto", "auto", "50%");
|
video.pause();
|
||||||
poppedContainer.appendChild(playerWindow);
|
mainPlayer.style.display = "none";
|
||||||
|
ytIfrm.src = "https://www.youtube.com/embed/" + video.baseURI.slice(32, 32+11) +
|
||||||
|
"?autoplay=1&start=" + Math.floor(video.currentTime);
|
||||||
poppedContainer.style.display = "block";
|
poppedContainer.style.display = "block";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setVideoStyle(containerOfPlyrWndow.offsetWidth + "px",
|
video.currentTime = ifrmBody.getElementsByTagName("video")[0].currentTime;
|
||||||
containerOfPlyrWndow.offsetHeight + "px", "");
|
|
||||||
containerOfPlyrWndow.append(playerWindow);
|
|
||||||
poppedContainer.style.display = "none";
|
poppedContainer.style.display = "none";
|
||||||
|
mainPlayer.style.display = "";
|
||||||
|
ytIfrm.src = "";
|
||||||
|
video.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +343,4 @@ const betterYoutubePlus = () => {
|
||||||
|
|
||||||
// Start init
|
// Start init
|
||||||
checkPg();
|
checkPg();
|
||||||
}
|
}());
|
||||||
|
|
||||||
betterYoutubePlus();
|
|
||||||
|
|
|
@ -56,7 +56,10 @@
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
width: 650px;
|
width: 650px;
|
||||||
height: 400px;
|
height: 400px;
|
||||||
background: black;
|
padding-top: 50px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: rgba(0, 232, 255, 0.64);
|
||||||
|
background: rgba(64, 64, 64, 0.64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue