fixed some stuff with thumbnail loading

This commit is contained in:
Maxim Stewart 2018-06-03 22:53:28 -05:00
parent 2d4710070b
commit 47349f2246
3 changed files with 220 additions and 218 deletions

View File

@ -12,5 +12,5 @@ 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.2.5 # Version: 1.2.6
Added quick access to the Youtube video slug. Added quick access to the Youtube video slug.

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Better Youtube +", "name": "Better Youtube +",
"version": "1.2.5", "version": "1.2.6",
"description": "Enhancements for Youtube to have a better experience.", "description": "Enhancements for Youtube to have a better experience.",
"applications": { "applications": {

View File

@ -1,16 +1,17 @@
// Declare variables function betterYoutubePlus() {
var slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems
var ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images // Declare variables
var slugInputTag, ytThumbImgMenu, ytEnhancerMenu; // Menu systems
var ytThumbnailBttn, ytMaxDefaultImg, ytHqDefaultImg, // Buttons & Images
ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg; ytLoopBttn, ytFloatBttn, ytAMaxDefaultImg, ytAHqDefaultImg;
var mastHead, mainContentArea, playerWindow; // Youtube Player container var mastHead, mainContentArea, playerWindow; // Youtube Player container
var video, containerOfPlyrWndow, poppedContainer; // Video accessor var video, containerOfPlyrWndow, poppedContainer; // Video accessor
var vdoPlyrAtts; // Player attributes var vdoPlyrAtts; // Player attributes
var part, videoSlug, temp; // Image part var part, videoSlug, temp; // Image part
var count = 0; var count = 0;
function preSetupProc() { function preSetupProc() {
console.log("Weee");
video = document.getElementsByTagName("video")[0]; // Video Controler video = document.getElementsByTagName("video")[0]; // Video Controler
slugInputTag = document.createElement("INPUT"); slugInputTag = document.createElement("INPUT");
slugInputTag.id = "slugCopyZone"; slugInputTag.id = "slugCopyZone";
@ -23,13 +24,10 @@ function preSetupProc() {
} }
vdoPlyrAtts = video.baseURI; // Used for setting up thumbnails vdoPlyrAtts = video.baseURI; // Used for setting up thumbnails
vdoPlyrAtts = vdoPlyrAtts.slice(32, 32+11); slugInputTag.value = vdoPlyrAtts.slice(32, 32+11);
slugInputTag.value = vdoPlyrAtts; }
function setupProc() {
}
function setupProc() {
poppedContainer = document.createElement("DIV"); poppedContainer = document.createElement("DIV");
ytThumbImgMenu = document.createElement("DIV"); ytThumbImgMenu = document.createElement("DIV");
ytEnhancerMenu = document.createElement("DIV"); ytEnhancerMenu = document.createElement("DIV");
@ -50,7 +48,7 @@ function setupProc() {
.getElementsByClassName("style-scope ytd-masthead")[3]; // Search bar area .getElementsByClassName("style-scope ytd-masthead")[3]; // Search bar area
mainContentArea = document.getElementsByTagName("ytd-watch")[0]; // BT control insert area and bg color setup mainContentArea = document.getElementsByTagName("ytd-watch")[0]; // BT control insert area and bg color setup
containerOfPlyrWndow = document.getElementById("top").children[0]; // 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/"; part = "https://img.youtube.com/vi/";
// Append to nodes as required // Append to nodes as required
@ -109,11 +107,12 @@ function setupProc() {
poppedContainer.style.display = "none"; poppedContainer.style.display = "none";
mastHead.style = "background: #868686;"; mastHead.style = "background: #868686;";
mainContentArea.style = "background: #868686;"; mainContentArea.style = "background: #868686;";
} }
// Functions
function showThumbImageVew(e) {
videoSlug = video.baseURI.slice(32, 32+11); // Used for setting up thumbnails
// Functions
function showThumbImageVew(e) {
videoSlug = vdoPlyrAtts;
if (ytThumbImgMenu.style.display == "block") { if (ytThumbImgMenu.style.display == "block") {
ytThumbImgMenu.style.display = "none"; ytThumbImgMenu.style.display = "none";
ytThumbnailBttn.src = browser.extension.getURL("/icons/thumbnailOff.png"); ytThumbnailBttn.src = browser.extension.getURL("/icons/thumbnailOff.png");
@ -140,9 +139,9 @@ function showThumbImageVew(e) {
ytThumbImgMenu.style.display = "block"; ytThumbImgMenu.style.display = "block";
} }
return; return;
} }
function setLoop(e) { function setLoop(e) {
if (video.loop == false) { if (video.loop == false) {
video.loop = true; video.loop = true;
ytLoopBttn.title = "Stop Loop..."; ytLoopBttn.title = "Stop Loop...";
@ -153,21 +152,21 @@ function setLoop(e) {
ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png"); ytLoopBttn.src = browser.extension.getURL("/icons/loopFalse.png");
} }
return; return;
} }
function toggleFloat() { function toggleFloat() {
playerWindow = document.getElementById("player-container"); // Actual player playerWindow = document.getElementById("player-container").children[1]; // Actual player
if(poppedContainer.style.display == "none"){ if(poppedContainer.style.display == "none"){
poppedContainer.appendChild(playerWindow); poppedContainer.appendChild(playerWindow);
poppedContainer.style.display = "block"; poppedContainer.style.display = "block";
} else { } else {
containerOfPlyrWndow.insertBefore(playerWindow, containerOfPlyrWndow.firstChild); containerOfPlyrWndow.append(playerWindow);
poppedContainer.style.display = "none"; poppedContainer.style.display = "none";
} }
} }
function manageVolume(e) { function manageVolume(e) {
var delta; var delta;
e.preventDefault(); // Keep page from scrolling while in video area e.preventDefault(); // Keep page from scrolling while in video area
@ -175,9 +174,9 @@ function manageVolume(e) {
if (e.wheelDelta) delta = e.wheelDelta; else delta = -1 * e.deltaY; if (e.wheelDelta) delta = e.wheelDelta; else delta = -1 * e.deltaY;
// Vol UP || Vol DOWN // Vol UP || Vol DOWN
if (delta > 0) video.volume += 0.05; else if (delta < 0) video.volume -= 0.05; if (delta > 0) video.volume += 0.05; else if (delta < 0) video.volume -= 0.05;
} }
function dragVideo(elmnt) { function dragVideo(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
elmnt.onmousedown = dragMouseDown; elmnt.onmousedown = dragMouseDown;
@ -218,9 +217,9 @@ function dragVideo(elmnt) {
e.returnValue = false; e.returnValue = false;
return false; return false;
} }
} }
function checkPg() { function checkPg() {
if (!document.getElementById("enhancerMenuIDRef")) { if (!document.getElementById("enhancerMenuIDRef")) {
var existCondition = setInterval(function() { var existCondition = setInterval(function() {
if (document.getElementById("masthead-container")) { if (document.getElementById("masthead-container")) {
@ -240,7 +239,10 @@ function checkPg() {
} else { } else {
preSetupProc(); preSetupProc();
} }
}
// Start init
checkPg();
} }
// Start init betterYoutubePlus();
checkPg();