Requested changes

This commit is contained in:
Official Noob 2019-08-21 19:10:49 +01:00 committed by GitHub
parent bfb876af8b
commit 47d0d340d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -219,11 +219,12 @@ function videoIDChange(id) {
// ID has not changed return // ID has not changed return
if (sponsorVideoID === id) return if (sponsorVideoID === id) return
// Global ID // Global ID
sponsorVideoID = id; sponsorVideoID = id;
resetValues(); resetValues();
// ID is not valid // ID is not valid
if (id === false) return; if (id === false) return;
if (previewBar == null) { if (previewBar == null) {
//create it //create it
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0]; let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
@ -256,7 +257,7 @@ function videoIDChange(id) {
//close popup //close popup
closeInfoMenu(); closeInfoMenu();
addButtons(); addButtons();
//see if there is a video start time //see if there is a video start time
youtubeVideoStartTime = sponsorVideoID; youtubeVideoStartTime = sponsorVideoID;
@ -531,22 +532,23 @@ function reskipSponsorTime(UUID) {
} }
function removePlayerControlsButton() { function removePlayerControlsButton() {
if (!sponsorVideoID) return; if (!sponsorVideoID) return;
document.getElementById("changeStartSponsor").style.display = "none"; document.getElementById("changeStartSponsor").style.display = "none";
document.getElementById("submitButton").style.display = "none"; document.getElementById("submitButton").style.display = "none";
} }
function createButton(baseid, title, callback, imageName) { function createButton(baseID, title, callback, imageName) {
if (document.getElementById(baseid+"Button") != null) return; if (document.getElementById(baseID+"Button") != null) return;
// Button HTML // Button HTML
let newButton = document.createElement("button"); let newButton = document.createElement("button");
newButton.id = baseid+"Button"; newButton.id = baseID+"Button";
newButton.className = "ytp-button playerButton"; newButton.className = "ytp-button playerButton";
newButton.setAttribute("title", chrome.i18n.getMessage(baseid)); newButton.setAttribute("title", chrome.i18n.getMessage(baseID));
newButton.addEventListener("click", callback); newButton.addEventListener("click", callback);
// Image HTML // Image HTML
let newButtonImage = document.createElement("img"); let newButtonImage = document.createElement("img");
newButtonImage.id = baseid+"Image"; newButtonImage.id = baseID+"Image";
newButtonImage.className = "playerButtonImage"; newButtonImage.className = "playerButtonImage";
newButtonImage.src = chrome.extension.getURL("icons/"+imageName); newButtonImage.src = chrome.extension.getURL("icons/"+imageName);
// Append image to button // Append image to button
@ -564,12 +566,11 @@ function getControls() {
function addButtons() { function addButtons() {
wait(getControls).then(result => { wait(getControls).then(result => {
controls = result; // Global controls = result; // Global
// Add button if does not already exist in html // Add button if does not already exist in html
createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png"); createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png");
createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png") createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png")
createButton("delete", "clearTimes", clearSponsorTimes, "PlayerDeleteIconSponsorBlocker256px.png"); createButton("delete", "clearTimes", clearSponsorTimes, "PlayerDeleteIconSponsorBlocker256px.png");
createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker256px.png"); createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker256px.png");
}); });
} }
//adds or removes the player controls button to what it should be //adds or removes the player controls button to what it should be