Adding ability to dismiss browser notices

pull/271/head
Kevin Payravi 2023-10-17 03:06:15 -04:00
parent ab080f07d2
commit 9f56e46f93
4 changed files with 69 additions and 37 deletions

View File

@ -77,19 +77,16 @@
}
/* NOTIFICATIONS */
#notificationBanner {
display: none;
#notificationBannerContainer {
background-color: #f8f3d6;
font-size: .9em;
line-height: 1.3em;
padding: 1em;
}
#notificationBanner span {
#notificationBannerContainer span {
padding: 1em;
display: none;
}
#notificationBanner span[style*="display: block"] + span[style*="display: block"]{
padding-top: .75em;
margin-top: .75em;
#notificationBannerContainer span[style*="display: block"] + span[style*="display: block"]{
border-top: 1px solid #000;
}
@ -271,17 +268,19 @@
>
</div>
</div>
<div id="notificationBanner">
<span id="notificationBannerBug">
<div id="notificationBannerContainer">
<span id="notificationBannerChromeBug">
Chromium users: Due to a <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1271154" target="_blank">browser bug</a>,
this extension may stop working after an update. If this happens, try restarting your browser,
turning the extension off and on via your browser's extension settings (chrome://extensions/),
and/or reinstalling the extension.
<a id="chromeBugHideLink" href="#">Hide this message</a>
</span>
<span id="notificationBannerOpera">
Opera users: By default, Opera will block extensions from running on search engines.
Search engine access can be enabled per-extension by going to "chrome://extensions/"
Search engine access can be enabled per-extension by going to "about:extensions"
and selecting the "Allow access to search page results" option under Indie Wiki Buddy.
<a id="operaPermsHideLink" href="#">Hide this message</a>
</span>
</div>
</body>

View File

@ -220,19 +220,35 @@ function setBreezeWiki(setting, storeSetting = true) {
}
// Main function that runs on-load
document.addEventListener('DOMContentLoaded', function () {
notificationBanner = document.getElementById('notificationBanner');
document.addEventListener('DOMContentLoaded', function () {
// If running Chromium, show warning about service worker bug
if (navigator.userAgent.match(/Chrom[e|ium]/)) {
notificationBanner.style.display = 'block';
document.getElementById('notificationBannerBug').style.display = 'block';
const notificationBannerChromeBug = document.getElementById('notificationBannerChromeBug');
chrome.storage.local.get({ 'hideChromeBugNote': false }, function (item) {
if (!item.hideChromeBugNote) {
notificationBannerChromeBug.style.display = 'block';
document.getElementById('chromeBugHideLink').addEventListener('click', function () {
chrome.storage.local.set({ 'hideChromeBugNote': true });
notificationBannerChromeBug.style.display = 'none';
});
}
});
}
// If running Opera, show note about search engine acces
// If running Opera, show note about search engine access
if (navigator.userAgent.match(/OPR\//)) {
notificationBanner.style.display = 'block';
document.getElementById('notificationBannerOpera').style.display = 'block';
const notificationBannerOpera = document.getElementById('notificationBannerOpera');
chrome.storage.local.get({ 'hideOperaPermissionsNote': false }, function (item) {
if (!item.hideOperaPermissionsNote) {
notificationBannerOpera.style.display = 'block';
document.getElementById('operaPermsHideLink').addEventListener('click', function () {
chrome.storage.local.set({ 'hideOperaPermissionsNote': true });
notificationBannerOpera.style.display = 'none';
});
}
});
}
loadBreezeWikiOptions();

View File

@ -106,19 +106,16 @@
}
/* NOTIFICATIONS */
#notificationBanner {
display: none;
#notificationBannerContainer {
background-color: #f8f3d6;
font-size: .9em;
line-height: 1.3em;
padding: 1em;
}
#notificationBanner span {
#notificationBannerContainer span {
padding: 1em;
display: none;
}
#notificationBanner span[style*="display: block"] + span[style*="display: block"]{
padding-top: .75em;
margin-top: .75em;
#notificationBannerContainer span[style*="display: block"] + span[style*="display: block"]{
border-top: 1px solid #000;
}
@ -303,17 +300,19 @@
>Source&nbsp;Code</a
>
</div>
<div id="notificationBanner">
<span id="notificationBannerBug">
<div id="notificationBannerContainer">
<span id="notificationBannerChromeBug">
Chromium users: Due to a <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1271154" target="_blank">browser bug</a>,
this extension may stop working after an update. If this happens, try restarting your browser,
turning the extension off and on via your browser's extension settings (chrome://extensions/),
and/or reinstalling the extension.
<a id="chromeBugHideLink" href="#">Hide this message</a>
</span>
<span id="notificationBannerOpera">
Opera users: By default, Opera will block extensions from running on search engines.
Search engine access can be enabled per-extension by going to "about:extensions"
and selecting the "Allow access to search page results" option under Indie Wiki Buddy.
<a id="operaPermsHideLink" href="#">Hide this message</a>
</span>
<span id="notificationBannerReview">
Enjoying Indie Wiki Buddy? Please leave a review!

View File

@ -514,9 +514,7 @@ function setBreezeWiki(setting, storeSetting = true) {
}
// Main function that runs on-load
document.addEventListener('DOMContentLoaded', function () {
notificationBanner = document.getElementById('notificationBanner');
document.addEventListener('DOMContentLoaded', function () {
// If newly installed, show initial install guide
if (new URLSearchParams(window.location.search).get('newinstall')) {
document.getElementById('firstInstallInfo').style.display = 'block';
@ -524,14 +522,32 @@ document.addEventListener('DOMContentLoaded', function () {
// If running Chromium, show warning about service worker bug
if (navigator.userAgent.match(/Chrom[e|ium]/)) {
notificationBanner.style.display = 'block';
document.getElementById('notificationBannerBug').style.display = 'block';
const notificationBannerChromeBug = document.getElementById('notificationBannerChromeBug');
chrome.storage.local.get({ 'hideChromeBugNote': false }, function (item) {
if (!item.hideChromeBugNote) {
notificationBannerChromeBug.style.display = 'block';
document.getElementById('chromeBugHideLink').addEventListener('click', function () {
chrome.storage.local.set({ 'hideChromeBugNote': true });
notificationBannerChromeBug.style.display = 'none';
});
}
});
}
// If running Opera, show note about search engine acces
// If running Opera, show note about search engine access
if (navigator.userAgent.match(/OPR\//)) {
notificationBanner.style.display = 'block';
document.getElementById('notificationBannerOpera').style.display = 'block';
const notificationBannerOpera = document.getElementById('notificationBannerOpera');
chrome.storage.local.get({ 'hideOperaPermissionsNote': false }, function (item) {
if (!item.hideOperaPermissionsNote) {
notificationBannerOpera.style.display = 'block';
document.getElementById('operaPermsHideLink').addEventListener('click', function () {
chrome.storage.local.set({ 'hideOperaPermissionsNote': true });
notificationBannerOpera.style.display = 'none';
});
}
});
}
// Count number of times settings have been opened
@ -544,7 +560,9 @@ document.addEventListener('DOMContentLoaded', function () {
// and if the banner hasn't been previously dismissed
chrome.storage.local.get({ 'hideReviewReminder': false }, function (item) {
if (!item.hideReviewReminder && ((countSettingsOpened - 1) % 5 === 0)) {
notificationBanner.style.display = 'block';
const notificationBannerReview = document.getElementById('notificationBannerReview');
notificationBannerReview.style.display = 'block';
document.getElementById('notificationBannerReview').style.display = ' block';
// Disable future review reminders if user clicks links:
@ -556,7 +574,7 @@ document.addEventListener('DOMContentLoaded', function () {
});
document.getElementById('reviewReminderHideLink').addEventListener('click', function () {
chrome.storage.local.set({ 'hideReviewReminder': true });
notificationBanner.style.display = 'none';
notificationBannerReview.style.display = 'none';
});
}
});