Update content.js

This commit is contained in:
Official Noob
2019-08-20 23:11:18 +01:00
committed by GitHub
parent 2b5d56942a
commit 05765682a5

View File

@@ -546,14 +546,13 @@ function createButton(baseID, title, callback, imageName) {
function getControls() {
let controls = document.getElementsByClassName("ytp-right-controls");
return (controls === undefined) ? false : controls[controls.length - 1];
return (!controls || controls.length === 0) ? false : controls[controls.length - 1]
};
//adds the player controls buttons
function addButtons() {
wait(getControls).then(result => {
controls = result; // Global
// Add button if does not already exist in html
createButton("startSponsor", "sponsorStart", startSponsorClicked, "PlayerStartIconSponsorBlocker256px.png");
createButton("infoButton", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker256px.png")