Fixed feature to show the notice to users again.

This commit is contained in:
Ajay Ramachandran 2019-10-30 23:30:30 -04:00
parent 25b9edabf8
commit 4e4d50de82
4 changed files with 37 additions and 13 deletions

View file

@ -244,8 +244,12 @@
"description": "Used on Firefox Store Page" "description": "Used on Firefox Store Page"
}, },
"noticeUpdate": { "noticeUpdate": {
"message": "The notice has been upgraded! If you still don't like it, hit the never show button.", "message": "The notice has been upgraded!",
"description": "The message displayed after the notice was upgraded." "description": "The first line of the message displayed after the notice was upgraded."
},
"noticeUpdate2": {
"message": "If you still don't like it, hit the never show button.",
"description": "The second line of the message displayed after the notice was upgraded."
}, },
"setStartSponsorShortcut": { "setStartSponsorShortcut": {
"message": "Set key for start sponsor keybind" "message": "Set key for start sponsor keybind"

View file

@ -618,10 +618,11 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
if (dontShowNoticeOld) { if (dontShowNoticeOld) {
//show why this notice is showing //show why this notice is showing
skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate")); skipNotice.addNoticeInfoMessage(chrome.i18n.getMessage("noticeUpdate"), chrome.i18n.getMessage("noticeUpdate2"));
//disable this setting //remove this setting
chrome.storage.sync.set({"dontShowNoticeAgain": false}); chrome.storage.sync.remove(["dontShowNoticeAgain"]);
dontShowNoticeOld = false;
} }
//auto-upvote this sponsor //auto-upvote this sponsor

View file

@ -136,9 +136,9 @@ function runThePopup() {
//if the don't show notice again letiable is true, an option to //if the don't show notice again letiable is true, an option to
// disable should be available // disable should be available
chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["dontShowNotice"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain; let dontShowNotice = result.dontShowNotice;
if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) { if (dontShowNotice != undefined && dontShowNotice) {
SB.showNoticeAgain.style.display = "unset"; SB.showNoticeAgain.style.display = "unset";
} }
}); });
@ -828,7 +828,7 @@ function runThePopup() {
} }
function showNoticeAgain() { function showNoticeAgain() {
chrome.storage.sync.set({"dontShowNoticeAgain": false}); chrome.storage.sync.set({"dontShowNotice": false});
chrome.tabs.query({ chrome.tabs.query({
active: true, active: true,

View file

@ -294,21 +294,37 @@ class SkipNotice {
} }
} }
addNoticeInfoMessage(message) { addNoticeInfoMessage(message, message2) {
let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix); let previousInfoMessage = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix);
if (previousInfoMessage != null) { if (previousInfoMessage != null) {
//remove it //remove it
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage); document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage);
} }
let previousInfoMessage2 = document.getElementById("sponsorTimesInfoMessage" + this.idSuffix + "2");
if (previousInfoMessage2 != null) {
//remove it
document.getElementById("sponsorSkipNotice" + this.idSuffix).removeChild(previousInfoMessage2);
}
//add info //add info
let thanksForVotingText = document.createElement("p"); let thanksForVotingText = document.createElement("p");
thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix; thanksForVotingText.id = "sponsorTimesInfoMessage" + this.idSuffix;
thanksForVotingText.className = "sponsorTimesInfoMessage"; thanksForVotingText.className = "sponsorTimesInfoMessage";
thanksForVotingText.innerText = message; thanksForVotingText.innerText = message;
//add element to div //add element to div
document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix)); document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix));
if (message2 !== undefined) {
let thanksForVotingText2 = document.createElement("p");
thanksForVotingText2.id = "sponsorTimesInfoMessage" + this.idSuffix + "2";
thanksForVotingText2.className = "sponsorTimesInfoMessage";
thanksForVotingText2.innerText = message2;
//add element to div
document.getElementById("sponsorSkipNotice" + this.idSuffix).insertBefore(thanksForVotingText2, document.getElementById("sponsorSkipNoticeSpacer" + this.idSuffix));
}
} }
resetNoticeInfoMessage() { resetNoticeInfoMessage() {
@ -337,7 +353,7 @@ class SkipNotice {
thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix; thanksForVotingText.id = "sponsorTimesVoteButtonInfoMessage" + this.idSuffix;
thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage"; thanksForVotingText.className = "sponsorTimesInfoMessage sponsorTimesVoteButtonMessage";
thanksForVotingText.innerText = message; thanksForVotingText.innerText = message;
//add element to div //add element to div
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText); document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).prepend(thanksForVotingText);
} }
@ -348,13 +364,16 @@ class SkipNotice {
//remove it //remove it
document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage); document.getElementById("sponsorSkipNoticeSecondRow" + this.idSuffix).removeChild(previousInfoMessage);
} }
//show button again //show button again
document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display"); document.getElementById("sponsorTimesDownvoteButtonsContainer" + this.idSuffix).style.removeProperty("display");
} }
//close this notice //close this notice
close() { close() {
//reset message
this.resetNoticeInfoMessage();
let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix); let notice = document.getElementById("sponsorSkipNotice" + this.idSuffix);
if (notice != null) { if (notice != null) {
notice.remove(); notice.remove();