diff --git a/content.js b/content.js
index b8b09c0e..7a9a78de 100644
--- a/content.js
+++ b/content.js
@@ -26,21 +26,31 @@ var lastTime;
//used for the go back button
var lastSponsorTimeSkipped = null;
+//if the notice should not be shown
+//happens when the user click's the "Don't show notice again" button
+var dontShowNotice = false;
+chrome.storage.local.get(["dontShowNoticeAgain"], function(result) {
+ let dontShowNoticeAgain = result.dontShowNoticeAgain;
+ if (dontShowNoticeAgain != undefined) {
+ dontShowNotice = dontShowNoticeAgain;
+ }
+});
+
chrome.runtime.onMessage.addListener( // Detect URL Changes
function(request, sender, sendResponse) {
//message from background script
- if (request.message === 'ytvideoid') {
+ if (request.message == "ytvideoid") {
//reset sponsor data found check
sponsorDataFound = false;
sponsorsLookup(request.id);
}
//messages from popup script
- if (request.message === 'sponsorStart') {
+ if (request.message == "sponsorStart") {
sponsorMessageStarted();
}
- if (request.message === 'isInfoFound') {
+ if (request.message == "isInfoFound") {
//send the sponsor times along with if it's found
sendResponse({
found: sponsorDataFound,
@@ -48,11 +58,15 @@ chrome.runtime.onMessage.addListener( // Detect URL Changes
})
}
- if (request.message === 'getVideoID') {
+ if (request.message == "getVideoID") {
sendResponse({
videoID: getYouTubeVideoID(document.URL)
})
}
+
+ if (request.message == "showNoticeAgain") {
+ dontShowNotice = false;
+ }
});
function sponsorsLookup(id) {
@@ -112,6 +126,11 @@ function goBackToPreviousTime() {
//Opens the notice that tells the user that a sponsor was just skipped
function openSkipNotice(){
+ if (dontShowNotice) {
+ //don't show, return
+ return;
+ }
+
var noticeElement = document.createElement("div");
noticeElement.id = 'sponsorSkipNotice'
@@ -146,8 +165,16 @@ function openSkipNotice(){
hideButton.style.marginTop = "5px";
hideButton.addEventListener("click", closeSkipNotice);
+ var dontShowAgainButton = document.createElement("button");
+ dontShowAgainButton.innerText = "Don't Show This Again";
+ dontShowAgainButton.style.fontSize = "13px";
+ dontShowAgainButton.style.color = "#000000";
+ dontShowAgainButton.style.marginTop = "5px";
+ dontShowAgainButton.addEventListener("click", dontShowNoticeAgain);
+
buttonContainer.appendChild(goBackButton);
buttonContainer.appendChild(hideButton);
+ buttonContainer.appendChild(dontShowAgainButton);
noticeElement.appendChild(noticeMessage);
noticeElement.appendChild(buttonContainer);
@@ -168,6 +195,14 @@ function closeSkipNotice(){
}
}
+function dontShowNoticeAgain() {
+ chrome.storage.local.set({"dontShowNoticeAgain": true});
+
+ dontShowNotice = true;
+
+ closeSkipNotice();
+}
+
function sponsorMessageStarted() {
let v = document.querySelector('video');
diff --git a/popup.html b/popup.html
index 4659f7c6..bbcd41c3 100644
--- a/popup.html
+++ b/popup.html
@@ -40,6 +40,10 @@
+
+
+
+
diff --git a/popup.js b/popup.js
index 6c6ccaf2..64af7d50 100644
--- a/popup.js
+++ b/popup.js
@@ -1,6 +1,8 @@
+//setup click listeners
document.getElementById("sponsorStart").addEventListener("click", sendSponsorStartMessage);
document.getElementById("clearTimes").addEventListener("click", clearTimes);
document.getElementById("submitTimes").addEventListener("click", submitTimes);
+document.getElementById("showNoticeAgain").addEventListener("click", showNoticeAgain);
//if true, the button now selects the end time
var startTimeChosen = false;
@@ -14,6 +16,15 @@ var currentVideoID = null;
//is this a YouTube tab?
var isYouTubeTab = false;
+//if the don't show notice again variable is true, an option to
+// disable should be available
+chrome.storage.local.get(["dontShowNoticeAgain"], function(result) {
+ let dontShowNoticeAgain = result.dontShowNoticeAgain;
+ if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) {
+ document.getElementById("showNoticeAgain").style.display = "unset";
+ }
+});
+
//if no response comes by this point, give up
setTimeout(function() {
if (!isYouTubeTab) {
@@ -51,7 +62,7 @@ function loadTabData(tabs) {
//check if this video's sponsors are known
chrome.tabs.sendMessage(
tabs[0].id,
- {from: 'popup', message: 'isInfoFound'},
+ {message: 'isInfoFound'},
infoFound
);
}
@@ -180,6 +191,21 @@ function submitTimes() {
}
}
+function showNoticeAgain() {
+ chrome.storage.local.set({"dontShowNoticeAgain": false});
+
+ chrome.tabs.query({
+ active: true,
+ currentWindow: true
+ }, function(tabs) {
+ chrome.tabs.sendMessage(tabs[0].id, {
+ message: "showNoticeAgain"
+ });
+ });
+
+ document.getElementById("showNoticeAgain").style.display = "none";
+}
+
//converts time in seconds to minutes:seconds
function getFormattedTime(seconds) {
let minutes = Math.floor(seconds / 60);