mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Added option to hide the video player controls button in the popup.
This commit is contained in:
32
content.js
32
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();
|
||||
|
||||
Reference in New Issue
Block a user