From f0e1979aabd0de673228030469e6004557074fbc Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 23 Aug 2019 21:03:43 -0400 Subject: [PATCH] Renamed addButtons and defined controls. --- content.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/content.js b/content.js index 153f14ea..0951ab29 100644 --- a/content.js +++ b/content.js @@ -30,6 +30,9 @@ var channelWhitelisted = false; // create preview bar var previewBar = null; +//the player controls on the YouTube player +var controls = null; + // Direct Links videoIDChange(getYouTubeVideoID(document.URL)); @@ -552,7 +555,6 @@ function removePlayerControlsButton() { } function createButton(baseID, title, callback, imageName, isDraggable=false) { - if (document.getElementById(baseID + "Button") != null) return; // Button HTML @@ -582,10 +584,12 @@ function getControls() { return (!controls || controls.length === 0) ? false : controls[controls.length - 1] }; -//adds the player controls buttons -function addButtons() { +//adds all the player controls buttons +function createButtons() { wait(getControls).then(result => { - controls = result; // Global + //set global controls variable + controls = result; + // Add button if does not already exist in html createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png"); createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png") @@ -598,7 +602,7 @@ function updateVisibilityOfPlayerControlsButton() { //not on a proper video yet if (!sponsorVideoID) return; - addButtons(); + createButtons(); if (hideVideoPlayerControls) { removePlayerControlsButton();