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
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.

View File

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

View File

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