aboutsummaryrefslogtreecommitdiffhomepage
path: root/content.js
diff options
context:
space:
mode:
Diffstat (limited to 'content.js')
-rw-r--r--content.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/content.js b/content.js
index c7ef2575..a15885ae 100644
--- a/content.js
+++ b/content.js
@@ -27,6 +27,9 @@ var lastSponsorTimeSkipped = null;
//if showing the start sponsor button or the end sponsor button on the player
var showingStartSponsor = true;
+//should the video controls buttons be added
+var hideVideoPlayerControls = false;
+
//if the notice should not be shown
//happens when the user click's the "Don't show notice again" button
var dontShowNotice = false;
@@ -70,6 +73,12 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes
if (request.message == "toggleStartSponsorButton") {
toggleStartSponsorButton();
}
+
+ if (request.message == "changeVideoPlayerControlsVisibility") {
+ hideVideoPlayerControls = request.value;
+
+ updateVisibilityOfPlayerControlsButton();
+ }
});
function videoIDChange(id) {
@@ -89,6 +98,15 @@ function videoIDChange(id) {
}
}
});
+
+ //see if video control buttons should be added
+ chrome.storage.local.get(["hideVideoPlayerControls"], function(result) {
+ if (result.hideVideoPlayerControls != undefined) {
+ hideVideoPlayerControls = result.hideVideoPlayerControls;
+ }
+
+ updateVisibilityOfPlayerControlsButton();
+ });
}
function sponsorsLookup(id) {
@@ -149,6 +167,7 @@ function goBackToPreviousTime() {
//Adds a sponsorship starts button to the player controls
function addPlayerControlsButton() {
let startSponsorButton = document.createElement("button");
+ startSponsorButton.id = "startSponsorButton";
startSponsorButton.className = "ytp-button";
startSponsorButton.setAttribute("title", "Sponsor Starts Now");
startSponsorButton.addEventListener("click", startSponsorClicked);
@@ -170,7 +189,18 @@ function addPlayerControlsButton() {
referenceNode.prepend(startSponsorButton);
}
-addPlayerControlsButton();
+function removePlayerControlsButton() {
+ document.getElementById("startSponsorButton").style.display = "none";
+}
+
+//adds or removes the player controls button to what it should be
+function updateVisibilityOfPlayerControlsButton() {
+ if (hideVideoPlayerControls) {
+ removePlayerControlsButton();
+ } else {
+ addPlayerControlsButton();
+ }
+}
function startSponsorClicked() {
toggleStartSponsorButton();