Added ability to hide info and delete button.

This commit is contained in:
Ajay Ramachandran
2019-07-29 21:40:13 -04:00
parent ff6234bffe
commit e205447968
3 changed files with 148 additions and 7 deletions

View File

@@ -31,6 +31,8 @@ var showingStartSponsor = true;
//should the video controls buttons be added //should the video controls buttons be added
var hideVideoPlayerControls = false; var hideVideoPlayerControls = false;
var hideInfoButtonPlayerControls = false;
var hideDeleteButtonPlayerControls = false;
//becomes true when isInfoFound is called //becomes true when isInfoFound is called
//this is used to close the popup on YouTube when the other popup opens //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") { if (request.message == "changeVideoPlayerControlsVisibility") {
hideVideoPlayerControls = request.value; hideVideoPlayerControls = request.value;
updateVisibilityOfPlayerControlsButton();
} else if (request.message == "changeInfoButtonPlayerControlsVisibility") {
hideInfoButtonPlayerControls = request.value;
updateVisibilityOfPlayerControlsButton();
} else if (request.message == "changeDeleteButtonPlayerControlsVisibility") {
hideDeleteButtonPlayerControls = request.value;
updateVisibilityOfPlayerControlsButton(); 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) { chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
if (result.hideVideoPlayerControls != undefined) { if (result.hideVideoPlayerControls != undefined) {
hideVideoPlayerControls = result.hideVideoPlayerControls; hideVideoPlayerControls = result.hideVideoPlayerControls;
@@ -173,6 +183,21 @@ function videoIDChange(id) {
updateVisibilityOfPlayerControlsButton(); 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) { function sponsorsLookup(id) {
@@ -301,6 +326,12 @@ function updateVisibilityOfPlayerControlsButton() {
if (hideVideoPlayerControls) { if (hideVideoPlayerControls) {
removePlayerControlsButton(); removePlayerControlsButton();
} }
if (hideInfoButtonPlayerControls) {
document.getElementById("infoButton").style.display = "none";
}
if (hideDeleteButtonPlayerControls) {
document.getElementById("deleteButton").style.display = "none";
}
} }
function startSponsorClicked() { function startSponsorClicked() {
@@ -319,7 +350,7 @@ function startSponsorClicked() {
function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) { function changeStartSponsorButton(showStartSponsor, uploadButtonVisible) {
//if it isn't visible, there is no data //if it isn't visible, there is no data
if (uploadButtonVisible) { if (uploadButtonVisible && !hideDeleteButtonPlayerControls) {
document.getElementById("deleteButton").style.display = "unset"; document.getElementById("deleteButton").style.display = "unset";
} else { } else {
document.getElementById("deleteButton").style.display = "none"; 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("startSponsorImage").src = chrome.extension.getURL("icons/PlayerStartIconSponsorBlocker256px.png");
document.getElementById("startSponsorButton").setAttribute("title", "Sponsor Starts Now"); 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"; document.getElementById("submitButton").style.display = "unset";
} else if (!uploadButtonVisible) { } else if (!uploadButtonVisible) {
//disable submit button //disable submit button

View File

@@ -126,11 +126,11 @@
<h3>Options</h3> <h3>Options</h3>
<button id="hideVideoPlayerControls" class="warningButton">Hide Button On YouTube Player</button> <button id="hideVideoPlayerControls" class="warningButton">Hide Buttons On YouTube Player</button>
<button id="showVideoPlayerControls" style="display: none" class="warningButton">Show Button On YouTube Player</button> <button id="showVideoPlayerControls" style="display: none" class="warningButton">Show Buttons On YouTube Player</button>
<br/> <br/>
<sub> <sub>
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, 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 use the button that appears on the notice saying "Don't show this again". You can always enable these settings again
later. later.
@@ -139,6 +139,26 @@
<br/> <br/>
<br/> <br/>
<button id="hideInfoButtonPlayerControls" class="warningButton">Hide Info Button On YouTube Player</button>
<button id="showInfoButtonPlayerControls" style="display: none" class="warningButton">Show Info Button On YouTube Player</button>
<br/>
<sub>
This is the button that opens up a popup in the YouTube page.
</sub>
<br/>
<br/>
<button id="hideDeleteButtonPlayerControls" class="warningButton">Hide Delete Button On YouTube Player</button>
<button id="showDeleteButtonPlayerControls" style="display: none" class="warningButton">Show Delete Button On YouTube Player</button>
<br/>
<sub>
This is the button that allows you to clear all sponsors on the YouTube player.
</sub>
<br/>
<br/>
<button id="disableSponsorViewTracking" class="warningButton">Disable Sponsor View Tracking</button> <button id="disableSponsorViewTracking" class="warningButton">Disable Sponsor View Tracking</button>
<button id="enableSponsorViewTracking" style="display: none" class="warningButton">Enable Sponsor View Tracking</button> <button id="enableSponsorViewTracking" style="display: none" class="warningButton">Enable Sponsor View Tracking</button>
<br/> <br/>

View File

@@ -8,6 +8,10 @@ SB.submitTimes = document.getElementById("submitTimes");
SB.showNoticeAgain = document.getElementById("showNoticeAgain"); SB.showNoticeAgain = document.getElementById("showNoticeAgain");
SB.hideVideoPlayerControls = document.getElementById("hideVideoPlayerControls"); SB.hideVideoPlayerControls = document.getElementById("hideVideoPlayerControls");
SB.showVideoPlayerControls = document.getElementById("showVideoPlayerControls"); 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.disableSponsorViewTracking = document.getElementById("disableSponsorViewTracking");
SB.enableSponsorViewTracking = document.getElementById("enableSponsorViewTracking"); SB.enableSponsorViewTracking = document.getElementById("enableSponsorViewTracking");
SB.optionsButton = document.getElementById("optionsButton"); SB.optionsButton = document.getElementById("optionsButton");
@@ -31,6 +35,10 @@ SB.submitTimes.addEventListener("click", submitTimes);
SB.showNoticeAgain.addEventListener("click", showNoticeAgain); SB.showNoticeAgain.addEventListener("click", showNoticeAgain);
SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls); SB.hideVideoPlayerControls.addEventListener("click", hideVideoPlayerControls);
SB.showVideoPlayerControls.addEventListener("click", showVideoPlayerControls); 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.disableSponsorViewTracking.addEventListener("click", disableSponsorViewTracking);
SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking); SB.enableSponsorViewTracking.addEventListener("click", enableSponsorViewTracking);
SB.optionsButton.addEventListener("click", openOptions); 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) { chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
let hideVideoPlayerControls = result.hideVideoPlayerControls; let hideVideoPlayerControls = result.hideVideoPlayerControls;
if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) { if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) {
@@ -87,6 +95,20 @@ chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
SB.showVideoPlayerControls.style.display = "unset"; 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 //show proper tracking option
chrome.storage.sync.get(["trackViewCount"], function(result) { chrome.storage.sync.get(["trackViewCount"], function(result) {
@@ -648,6 +670,74 @@ function showVideoPlayerControls() {
SB.showVideoPlayerControls.style.display = "none"; 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() { function disableSponsorViewTracking() {
chrome.storage.sync.set({"trackViewCount": false}); chrome.storage.sync.set({"trackViewCount": false});