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"
},
"noticeUpdate": {
"message": "The notice has been upgraded! If you still don't like it, hit the never show button.",
"description": "The message displayed after the notice was upgraded."
"message": "The notice has been 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": {
"message": "Set key for start sponsor keybind"

View file

@ -618,10 +618,11 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
if (dontShowNoticeOld) {
//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
chrome.storage.sync.set({"dontShowNoticeAgain": false});
//remove this setting
chrome.storage.sync.remove(["dontShowNoticeAgain"]);
dontShowNoticeOld = false;
}
//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
// disable should be available
chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain;
if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) {
chrome.storage.sync.get(["dontShowNotice"], function(result) {
let dontShowNotice = result.dontShowNotice;
if (dontShowNotice != undefined && dontShowNotice) {
SB.showNoticeAgain.style.display = "unset";
}
});
@ -828,7 +828,7 @@ function runThePopup() {
}
function showNoticeAgain() {
chrome.storage.sync.set({"dontShowNoticeAgain": false});
chrome.storage.sync.set({"dontShowNotice": false});
chrome.tabs.query({
active: true,

View file

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