diff --git a/content.js b/content.js index b4f9fbdb..53347e07 100644 --- a/content.js +++ b/content.js @@ -31,6 +31,8 @@ var showingStartSponsor = true; //should the video controls buttons be added var hideVideoPlayerControls = false; +var hideInfoButtonPlayerControls = false; +var hideDeleteButtonPlayerControls = false; //becomes true when isInfoFound is called //this is used to close the popup on YouTube when the other popup opens @@ -102,6 +104,14 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes if (request.message == "changeVideoPlayerControlsVisibility") { hideVideoPlayerControls = request.value; + updateVisibilityOfPlayerControlsButton(); + } else if (request.message == "changeInfoButtonPlayerControlsVisibility") { + hideInfoButtonPlayerControls = request.value; + + updateVisibilityOfPlayerControlsButton(); + } else if (request.message == "changeDeleteButtonPlayerControlsVisibility") { + hideDeleteButtonPlayerControls = request.value; + updateVisibilityOfPlayerControlsButton(); } @@ -165,7 +175,7 @@ function videoIDChange(id) { } }); - //see if video control buttons should be added + //see if video controls buttons should be added chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) { if (result.hideVideoPlayerControls != undefined) { hideVideoPlayerControls = result.hideVideoPlayerControls; @@ -173,6 +183,21 @@ function videoIDChange(id) { updateVisibilityOfPlayerControlsButton(); }); + chrome.storage.sync.get(["hideInfoButtonPlayerControls"], function(result) { + if (result.hideInfoButtonPlayerControls != undefined) { + hideInfoButtonPlayerControls = result.hideInfoButtonPlayerControls; + } + + updateVisibilityOfPlayerControlsButton(); + }); + chrome.storage.sync.get(["hideDeleteButtonPlayerControls"], function(result) { + if (result.hideDeleteButtonPlayerControls != undefined) { + hideDeleteButtonPlayerControls = result.hideDeleteButtonPlayerControls; + } + + updateVisibilityOfPlayerControlsButton(); + }); + } function sponsorsLookup(id) { @@ -301,6 +326,12 @@ function updateVisibilityOfPlayerControlsButton() { if (hideVideoPlayerControls) { removePlayerControlsButton(); } + if (hideInfoButtonPlayerControls) { + document.getElementById("infoButton").style.display = "none"; + } + if (hideDeleteButtonPlayerControls) { + document.getElementById("deleteButton").style.display = "none"; + } } function startSponsorClicked() { @@ -319,7 +350,7 @@ function startSponsorClicked() { function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { //if it isn't visible, there is no data - if (uploadButtonVisible) { + if (uploadButtonVisible && !hideDeleteButtonPlayerControls) { document.getElementById("deleteButton").style.display = "unset"; } else { document.getElementById("deleteButton").style.display = "none"; @@ -330,7 +361,7 @@ function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { document.getElementById("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png"); document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Starts Now"); - if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible) { + if (document.getElementById("startSponsorImage").style.display != "none" && uploadButtonVisible && !hideInfoButtonPlayerControls) { document.getElementById("submitButton").style.display = "unset"; } else if (!uploadButtonVisible) { //disable submit button diff --git a/popup.html b/popup.html index b4e5c9b3..db0a1cdb 100644 --- a/popup.html +++ b/popup.html @@ -126,11 +126,11 @@

Options

- - + +
- This hides the button that appears on the YouTube player to submit sponsors. I can see this being annoying for some + This hides the buttons that appear on the YouTube player to submit sponsors. I can see this being annoying for some people. Instead of using the button there, this popup can be used to submit sponsors. To hide the notice that appears, use the button that appears on the notice saying "Don't show this again". You can always enable these settings again later. @@ -139,6 +139,26 @@

+ + +
+ + This is the button that opens up a popup in the YouTube page. + + +
+
+ + + +
+ + This is the button that allows you to clear all sponsors on the YouTube player. + + +
+
+
diff --git a/popup.js b/popup.js index 567a49a0..2e75f971 100644 --- a/popup.js +++ b/popup.js @@ -8,6 +8,10 @@ SB.submitTimes = document.getElementById("submitTimes"); SB.showNoticeAgain = document.getElementById("showNoticeAgain"); SB.hideVideoPlayerControls = document.getElementById("hideVideoPlayerControls"); SB.showVideoPlayerControls = document.getElementById("showVideoPlayerControls"); +SB.hideInfoButtonPlayerControls = document.getElementById("hideInfoButtonPlayerControls"); +SB.showInfoButtonPlayerControls = document.getElementById("showInfoButtonPlayerControls"); +SB.hideDeleteButtonPlayerControls = document.getElementById("hideDeleteButtonPlayerControls"); +SB.showDeleteButtonPlayerControls = document.getElementById("showDeleteButtonPlayerControls"); SB.disableSponsorViewTracking = document.getElementById("disableSponsorViewTracking"); SB.enableSponsorViewTracking = document.getElementById("enableSponsorViewTracking"); SB.optionsButton = document.getElementById("optionsButton"); @@ -31,6 +35,10 @@ SB.submitTimes.addEventListener("click", submitTimes); SB.showNoticeAgain.addEventListener("click", showNoticeAgain); SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls); SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls); +SB.hideInfoButtonPlayerControls.addEventListener("click", hideInfoButtonPlayerControls); +SB.showInfoButtonPlayerControls.addEventListener("click", showInfoButtonPlayerControls); +SB.hideDeleteButtonPlayerControls.addEventListener("click", hideDeleteButtonPlayerControls); +SB.showDeleteButtonPlayerControls.addEventListener("click", showDeleteButtonPlayerControls); SB.disableSponsorViewTracking.addEventListener("click", disableSponsorViewTracking); SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking); SB.optionsButton.addEventListener("click", openOptions); @@ -79,7 +87,7 @@ chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { } }); -//show proper video player controls option +//show proper video player controls options chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) { let hideVideoPlayerControls = result.hideVideoPlayerControls; if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) { @@ -87,6 +95,20 @@ chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) { SB.showVideoPlayerControls.style.display = "unset"; } }); +chrome.storage.sync.get(["hideInfoButtonPlayerControls"], function(result) { + let hideInfoButtonPlayerControls = result.hideInfoButtonPlayerControls; + if (hideInfoButtonPlayerControls != undefined && hideInfoButtonPlayerControls) { + SB.hideInfoButtonPlayerControls.style.display = "none"; + SB.showInfoButtonPlayerControls.style.display = "unset"; + } +}); +chrome.storage.sync.get(["hideDeleteButtonPlayerControls"], function(result) { + let hideDeleteButtonPlayerControls = result.hideDeleteButtonPlayerControls; + if (hideDeleteButtonPlayerControls != undefined && hideDeleteButtonPlayerControls) { + SB.hideDeleteButtonPlayerControls.style.display = "none"; + SB.showDeleteButtonPlayerControls.style.display = "unset"; + } +}); //show proper tracking option chrome.storage.sync.get(["trackViewCount"], function(result) { @@ -648,6 +670,74 @@ function showVideoPlayerControls() { SB.showVideoPlayerControls.style.display = "none"; } +function hideInfoButtonPlayerControls() { + chrome.storage.sync.set({"hideInfoButtonPlayerControls": true}); + + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + message: "changeInfoButtonPlayerControlsVisibility", + value: true + }); + }); + + SB.hideInfoButtonPlayerControls.style.display = "none"; + SB.showInfoButtonPlayerControls.style.display = "unset"; +} + +function showInfoButtonPlayerControls() { + chrome.storage.sync.set({"hideInfoButtonPlayerControls": false}); + + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + message: "changeVideoPlayerCochangeInfoButtonPlayerControlsVisibilityntrolsVisibility", + value: false + }); + }); + + SB.hideInfoButtonPlayerControls.style.display = "unset"; + SB.showInfoButtonPlayerControls.style.display = "none"; +} + +function hideDeleteButtonPlayerControls() { + chrome.storage.sync.set({"hideDeleteButtonPlayerControls": true}); + + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + message: "changeDeleteButtonPlayerControlsVisibility", + value: true + }); + }); + + SB.hideDeleteButtonPlayerControls.style.display = "none"; + SB.showDeleteButtonPlayerControls.style.display = "unset"; +} + +function showDeleteButtonPlayerControls() { + chrome.storage.sync.set({"hideDeleteButtonPlayerControls": false}); + + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + message: "changeVideoPlayerCochangeDeleteButtonPlayerControlsVisibilityntrolsVisibility", + value: false + }); + }); + + SB.hideDeleteButtonPlayerControls.style.display = "unset"; + SB.showDeleteButtonPlayerControls.style.display = "none"; +} + function disableSponsorViewTracking() { chrome.storage.sync.set({"trackViewCount": false});