Adding option to hide hidden search results banner
parent
217eccc7d8
commit
b6c8a9559d
|
@ -280,9 +280,9 @@ function replaceSearchResults(searchResultContainer, site, link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
function hideSearchResults(searchResultContainer, searchEngine, site) {
|
||||
function hideSearchResults(searchResultContainer, searchEngine, site, showBanner = 'on') {
|
||||
// Insert search result removal notice
|
||||
if (!filteredWikis.includes(site.lang + ' ' + site.origin_group)) {
|
||||
if (showBanner === 'on' && !filteredWikis.includes(site.lang + ' ' + site.origin_group)) {
|
||||
filteredWikis.push(site.lang + ' ' + site.origin_group);
|
||||
|
||||
let elementId = stringToId(site.lang + '-' + site.origin_group);
|
||||
|
@ -494,7 +494,7 @@ function filterSearchResults(searchResults, searchEngine, storage) {
|
|||
|
||||
if (searchResultContainer) {
|
||||
if (searchFilterSetting === 'hide') {
|
||||
countFiltered += hideSearchResults(searchResultContainer, searchEngine, site);
|
||||
countFiltered += hideSearchResults(searchResultContainer, searchEngine, site, storage['hiddenResultsBanner']);
|
||||
} else {
|
||||
countFiltered += replaceSearchResults(searchResultContainer, site, link);
|
||||
}
|
||||
|
|
|
@ -350,6 +350,14 @@
|
|||
redirections
|
||||
</label>
|
||||
</div>
|
||||
<div class="settingToggle">
|
||||
<label>
|
||||
<input id="hiddenResultsBannerCheckbox" type="checkbox" />
|
||||
<span id="hiddenResultsBannerIcon" aria-hidden="true"></span>
|
||||
On search engines, show banner when
|
||||
Fandom/Fextralife results have been hidden
|
||||
</label>
|
||||
</div>
|
||||
<div class="settingToggle">
|
||||
<label>
|
||||
<input id="crossLanguageCheckbox" type="checkbox" />
|
||||
|
|
27
popup.js
27
popup.js
|
@ -234,6 +234,21 @@ function setNotifications(setting, storeSetting = true) {
|
|||
}
|
||||
}
|
||||
|
||||
// Set search results hidden banner setting
|
||||
function setHiddenResultsBanner(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
chrome.storage.sync.set({ 'hiddenResultsBanner': setting });
|
||||
}
|
||||
const hiddenResultsBannerIcon = document.getElementById('hiddenResultsBannerIcon');
|
||||
if (setting === 'on') {
|
||||
document.getElementById('hiddenResultsBannerCheckbox').checked = true;
|
||||
hiddenResultsBannerIcon.innerText = '🔔';
|
||||
} else {
|
||||
document.getElementById('hiddenResultsBannerCheckbox').checked = false;
|
||||
hiddenResultsBannerIcon.innerText = '🔕';
|
||||
}
|
||||
}
|
||||
|
||||
// Set cross-language setting
|
||||
function setCrossLanguage(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
|
@ -393,6 +408,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
chrome.storage.sync.get({ 'notifications': 'on' }, function (item) {
|
||||
setNotifications(item.notifications, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'hiddenResultsBanner': 'on' }, function (item) {
|
||||
setHiddenResultsBanner(item.hiddenResultsBanner, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
|
||||
setCrossLanguage(item.crossLanguage, false);
|
||||
});
|
||||
|
@ -427,6 +445,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
document.getElementById('hiddenResultsBannerCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'hiddenResultsBanner': 'on' }, function (item) {
|
||||
if (item.hiddenResultsBanner === 'on') {
|
||||
setHiddenResultsBanner('off');
|
||||
} else {
|
||||
setHiddenResultsBanner('on');
|
||||
}
|
||||
});
|
||||
});
|
||||
document.getElementById('crossLanguageCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
|
||||
if (item.crossLanguage === 'on') {
|
||||
|
|
|
@ -555,6 +555,14 @@
|
|||
redirections
|
||||
</label>
|
||||
</div>
|
||||
<div class="settingToggle">
|
||||
<label>
|
||||
<input id="hiddenResultsBannerCheckbox" type="checkbox" />
|
||||
<span id="hiddenResultsBannerIcon" aria-hidden="true"></span>
|
||||
On search engines, show banner when
|
||||
Fandom/Fextralife results have been hidden
|
||||
</label>
|
||||
</div>
|
||||
<div class="settingToggle">
|
||||
<label>
|
||||
<input id="crossLanguageCheckbox" type="checkbox" />
|
||||
|
|
27
settings.js
27
settings.js
|
@ -536,6 +536,21 @@ function setNotifications(setting, storeSetting = true) {
|
|||
}
|
||||
}
|
||||
|
||||
// Set search results hidden banner setting
|
||||
function setHiddenResultsBanner(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
chrome.storage.sync.set({ 'hiddenResultsBanner': setting });
|
||||
}
|
||||
const hiddenResultsBannerIcon = document.getElementById('hiddenResultsBannerIcon');
|
||||
if (setting === 'on') {
|
||||
document.getElementById('hiddenResultsBannerCheckbox').checked = true;
|
||||
hiddenResultsBannerIcon.innerText = '🔔';
|
||||
} else {
|
||||
document.getElementById('hiddenResultsBannerCheckbox').checked = false;
|
||||
hiddenResultsBannerIcon.innerText = '🔕';
|
||||
}
|
||||
}
|
||||
|
||||
// Set cross-language setting
|
||||
function setCrossLanguage(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
|
@ -785,6 +800,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
chrome.storage.sync.get({ 'notifications': 'on' }, function (item) {
|
||||
setNotifications(item.notifications, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'hiddenResultsBanner': 'on' }, function (item) {
|
||||
setHiddenResultsBanner(item.hiddenResultsBanner, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
|
||||
setCrossLanguage(item.crossLanguage, false);
|
||||
});
|
||||
|
@ -819,6 +837,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
});
|
||||
});
|
||||
document.getElementById('hiddenResultsBannerCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'hiddenResultsBanner': 'on' }, function (item) {
|
||||
if (item.hiddenResultsBanner === 'on') {
|
||||
setHiddenResultsBanner('off');
|
||||
} else {
|
||||
setHiddenResultsBanner('on');
|
||||
}
|
||||
});
|
||||
});
|
||||
document.getElementById('crossLanguageCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) {
|
||||
if (item.crossLanguage === 'on') {
|
||||
|
|
Loading…
Reference in New Issue