Adding per-wiki search engine settings / Revamping settings UI

pull/311/head
Kevin Payravi 2023-11-02 03:12:35 -05:00
parent 29d6909679
commit 32c9ea5f1b
14 changed files with 893 additions and 728 deletions

View File

@ -36,6 +36,33 @@ chrome.runtime.onInstalled.addListener(function (detail) {
if (detail.reason === 'update') {
chrome.tabs.create({ url: 'https://getindie.wiki/changelog/?updated=true' });
}
// Temporary function for 3.0 migration
// On update, set new default action settings:
if (detail.reason === 'update') {
chrome.storage.sync.get({ 'defaultWikiAction': null }, function (item) {
if (!item.defaultWikiAction) {
chrome.storage.sync.get({ 'defaultActionSettings': {} }, function (item) {
if (item.defaultActionSettings['EN']) {
chrome.storage.sync.set({ 'defaultWikiAction': item.defaultActionSettings['EN'] });
}
});
}
});
chrome.storage.sync.get({ 'defaultSearchAction': null }, function (item) {
if (!item.defaultSearchAction) {
chrome.storage.sync.get({ 'defaultSearchFilterSettings': {} }, function (item) {
if (item.defaultSearchFilterSettings['EN']) {
if (item.defaultSearchFilterSettings['EN'] === 'true') {
chrome.storage.sync.set({ 'defaultSearchAction': 'replace' });
} else if (item.defaultSearchFilterSettings['EN'] === 'false') {
chrome.storage.sync.set({ 'defaultSearchAction': 'disabled' });
}
}
});
}
});
}
});
if (chrome.declarativeNetRequest) {
@ -300,8 +327,8 @@ async function main(eventInfo) {
let siteSetting = '';
if (settings.hasOwnProperty(id) && settings[id].hasOwnProperty('action')) {
siteSetting = settings[id].action;
} else if (storage.defaultActionSettings && storage.defaultActionSettings[site.language]) {
siteSetting = storage.defaultActionSettings[site.language];
} else if (storage.defaultWikiAction) {
siteSetting = storage.defaultWikiAction;
} else {
siteSetting = 'alert';
}

View File

@ -266,15 +266,15 @@ function hideSearchResults(searchResultContainer, searchEngine, site) {
searchRemovalNotice.appendChild(disableFilterButton);
disableFilterButton.onclick = function (e) {
if (e.target.textContent.includes('Stop')) {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
response.siteSettings.get(site.id).set('searchFilter', 'false');
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
chrome.storage.sync.get({ 'searchEngineSettings': {} }, function (response) {
response.searchEngineSettings.get(site.id).set('action', 'disabled');
chrome.storage.sync.set({ 'searchEngineSettings': response.searchEngineSettings });
e.target.textContent = 'Re-enable filtering for ' + site.origin_group;
})
} else {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
response.siteSettings.get(site.id).set('searchFilter', 'true');
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
chrome.storage.sync.get({ 'searchEngineSettings': {} }, function (response) {
response.searchEngineSettings.get(site.id).set('action', 'hide');
chrome.storage.sync.set({ 'searchEngineSettings': response.searchEngineSettings });
e.target.textContent = 'Stop filtering ' + site.origin_group + ' in future searches';
})
}
@ -387,17 +387,17 @@ function filterSearchResults(searchResults, searchEngine, storage) {
let site = matchingSites.find(site => site.origin_base_url === closestMatch);
if (site) {
// Get user's settings for the wiki
let settings = storage.siteSettings || {};
let settings = storage.searchEngineSettings || {};
let id = site['id'];
let searchFilterSetting = '';
if (settings.hasOwnProperty(id) && settings[id].searchFilter) {
searchFilterSetting = settings[id].searchFilter;
} else if (storage.defaultSearchFilterSettings && storage.defaultSearchFilterSettings[site.language]) {
searchFilterSetting = storage.defaultSearchFilterSettings[site.language];
if (settings.hasOwnProperty(id) && settings[id].action) {
searchFilterSetting = settings[id].action;
} else if (storage.defaultSearchAction) {
searchFilterSetting = storage.defaultSearchAction;
} else {
searchFilterSetting = 'true';
searchFilterSetting = 'replace';
}
if (searchFilterSetting === 'true') {
if (searchFilterSetting !== 'disabled') {
// Output stylesheet if not already done
if (filteredWikis.length === 0) {
// Wait for head to be available
@ -419,7 +419,6 @@ function filterSearchResults(searchResults, searchEngine, storage) {
}
}
let cssQuery = '';
let searchResultContainer = null;
switch (searchEngine) {
case 'google':
@ -447,7 +446,7 @@ function filterSearchResults(searchResults, searchEngine, storage) {
}
if (searchResultContainer) {
if (storage.searchSetting === 'hide') {
if (searchFilterSetting === 'hide') {
countFiltered += hideSearchResults(searchResultContainer, searchEngine, site);
} else {
countFiltered += redirectSearchResults(searchResultContainer, site, link);
@ -477,7 +476,7 @@ function main(mutations = null, observer = null) {
// Check if extension is on:
if ((storage.power ?? 'on') === 'on') {
// Determine which search engine we're on
if ((storage.searchSetting ?? 'replace') !== 'nothing') {
if ((storage.action ?? 'replace') !== 'nothing') {
if (currentURL.hostname.includes('www.google.')) {
// Function to filter search results in Google
function filterGoogle() {

View File

@ -111,40 +111,13 @@
</p>
<h2>Global settings help</h2>
<p>
There are four global settings options:
There are three global settings options:
</p>
<ul>
<li>
<b>Extension is on/off</b>
<b>🔋 Extension is on/off</b>
<br />
This allows you to enable/disable all Indie Wiki Buddy functionality at the click of a button.
</li>
<br />
<li>
<b>🔎 Search engine options</b>
<br />
Indie Wiki Buddy provides two ways to filter results from
Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, and Startpage.
<br />
<br />
When "disable non-indie wikis & add link to indie counterparts" is selected,
tracked Fandom and Fextralife wikis that appear in search engine results
will be disabled, and a button will be inserted above that attempts to
link you to the same article on the respective indie wiki.
<br />
<br />
When "hide non-indie wikis that have indie counterparts" is selected,
the results are completely hidden. A notice will be inserted at the top of the search page
letting you know that results were hidden, and you will have the option to temporarily
re-reveal the results or disable search engine filtering for that particular wiki.
<br />
<br />
If you don't want a particular Fandom or Fextralife wiki to be filtered from search results,
you can disable search engine filtering per-wiki on the full settings page.
<br />
<br />
Note that image results are not filtered;
we don't want users to miss out on images they might not find elsewhere!
Enable/disable all Indie Wiki Buddy functionality at the click of a button.
</li>
<br />
<li>
@ -160,7 +133,7 @@
</li>
<br />
<li>
<b>🌬️ Use BreezeWiki on Fandom</b>
<b>🌬️ Use BreezeWiki alternative frontend on Fandom</b>
<br />
This option will render Fandom wikis through <a href="https://breezewiki.com/">BreezeWiki</a>, an external service that removes clutter, simplifies the page, and removes ads.
Occasionally, BreezeWiki or one of its mirrors may go down; when this happens, you can simply switch to another working instance. This is off by default.
@ -171,10 +144,13 @@
In the individual settings section, you can configure your settings per-wiki.
<br />
<br />
The first dropdown lets you switch between lists of wikis in different languages.
The "Default settings for future wikis" options let you set the default behavior for wikis added to Indie Wiki Buddy in the future.
<br />
<br />
Below that is a list of all supported wikis (listed as "non-indie wiki » indie wiki"). You can select what happens whenever you visit each listed non-indie wiki.
Below that is a list of all supported wikis. You can select what happens whenever you visit each listed non-indie wiki.
</p>
<p>
The first set of radio buttons controls what happens when you visit the listed non-indie wikis.
</p>
<ul class="no-markers">
<li>
@ -191,21 +167,29 @@
<b>Alert</b>: Have a display banner at the top notifying you that an independent wiki is available.
This will appear on both Fandom and BreezeWiki pages.
</li>
</ul>
<p>
The second set of radio buttons controls what happens to the non-indie wiki on Google, Bing, DuckDuckGo, and other search engines.
</p>
<ul class="no-markers">
<li>
<img src="./images/toggle-search-filter.png" alt="" width="15">
<b>Search filtering</b>: Replace search results in Google, Bing, DuckDuckGo, and other search engines
with text inviting you to visit the independent wiki.
Oftentimes, the non-independent wiki should appear in that same search.
<img src="./images/toggle-disabled.png" alt="" width="15">
<b>Disable</b>: Search engine results are not affected.
</li>
<li>
<img src="./images/toggle-hide.png" alt="" width="15">
<b>Hide</b>: Results are hidden in search engines.
A banner will be shown near the top of the page to inform you, and allow you to re-reveal the hidden results.
</li>
<li>
<img src="./images/toggle-replace.png" alt="" width="15">
<b>Replace</b>: The original non-indie result is disabled, and a button is injected above to take you to the indepedent wiki.
</li>
</ul>
<p>
By default, all wikis will be set to alert with search filtering enabled.
By default, all wikis will be set to alert, with search engine replacement enabled.
You can quickly change the settings for all wikis in the current language view by using the control
buttons above the list of wikis. For example, if you want to be automatically redirect for all wikis,
click "Set all to redirect to indie wikis".
<br /><br />
Once you click on one of these "select all" buttons, that settings
will become the new default for any wikis that are added to the extension in the future.
buttons above the list of wikis.
</p>
<h2>Have questions or feedback?</h2>
<p>

BIN
images/lock-closed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

BIN
images/lock-opened.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 456 B

BIN
images/toggle-hide.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

BIN
images/toggle-replace.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View File

@ -103,6 +103,9 @@
cursor: pointer;
background-color: #fff;
border-radius: 20px;
width: 30px;
height: 30px;
text-align: center;
}
#power > input {
height: 0;
@ -112,8 +115,9 @@
appearance: none;
}
#power img {
width: 30px;
vertical-align: middle;
position: relative;
top: 50%;
transform: translateY(-50%);
}
/* CONTENT */
@ -170,38 +174,19 @@
<div id="power">
<input id="powerCheckbox" type="checkbox" />
<label for="powerCheckbox">
<img id="powerImage" src="" alt="" width="30" />
<img id="powerImage" src="" alt="" width="20" />
</label>
</div>
<h1>Indie Wiki Buddy</h1>
</div>
<div id="content">
<div class="options">
<div class="settingToggleContainer">
<div id="searchFilteringReplace" class="settingToggle">
<label for="searchFilteringReplaceRadio">
<input id="searchFilteringReplaceRadio" type="radio" name="searchSetting" value="replace" />
<span id="searchFilteringReplaceText">🔎 In search engines, disable non-indie wikis & add link to indie counterparts</span>
</label>
</div>
<div id="searchFilteringHide" class="settingToggle">
<label for="searchFilteringHideRadio">
<input id="searchFilteringHideRadio" type="radio" name="searchSetting" value="hide" />
<span id="searchFilteringHideText">🔎 In search engines, hide non-indie wikis that have indie counterparts</span>
</label>
</div>
<div id="searchFilteringNothing" class="settingToggle">
<label for="searchFilteringNothingRadio">
<input id="searchFilteringNothingRadio" type="radio" name="searchSetting" value="nothing" />
<span id="searchFilteringNothingText">🔎 Do nothing on search engines</span>
</label>
</div>
</div>
<div class="settingToggleContainer">
<div id="notifications" class="settingToggle">
<input id="notificationsCheckbox" type="checkbox" />
<label for="notificationsCheckbox">
<span id="notificationsText">🔔 Desktop notifications when redirected to an indie wiki or BreezeWiki</span>
<span id="notificationsText"><span id="notificationsIcon" aria-hidden="true"></span>
Desktop notifications for redirections</span>
</label>
</div>
</div>
@ -271,9 +256,8 @@
<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.
this extension may stop working after an update. If this happens, try turning the extension off
and on via your browser's extension settings (chrome://extensions/).
<a id="chromeBugHideLink" href="#">Hide this message</a>
</span>
<span id="notificationBannerOpera">

View File

@ -137,24 +137,14 @@ function setNotifications(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'notifications': setting });
}
const notificationsIcon = document.getElementById('notificationsIcon');
if (setting === 'on') {
document.getElementById('notificationsCheckbox').checked = true;
notificationsIcon.innerText = '🔔';
} else {
document.getElementById('notificationsCheckbox').checked = false;
}
}
// Set search filter setting
function setSearchSetting(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'searchSetting': setting });
}
if (setting === 'hide') {
document.getElementById('searchFilteringHideRadio').checked = true;
} else if (setting === 'nothing') {
document.getElementById('searchFilteringNothingRadio').checked = true;
} else {
document.getElementById('searchFilteringReplaceRadio').checked = true;
notificationsIcon.innerText = '🔕';
}
}
@ -297,15 +287,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
});
document.getElementById('searchFilteringReplaceRadio').addEventListener('change', function () {
setSearchSetting('replace');
});
document.getElementById('searchFilteringHideRadio').addEventListener('change', function () {
setSearchSetting('hide');
});
document.getElementById('searchFilteringNothingRadio').addEventListener('change', function () {
setSearchSetting('nothing');
});
document.getElementById('breezewikiCheckbox').addEventListener('change', function () {
chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) {
if (item.breezewiki === 'on') {

View File

@ -1,19 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<link rel="icon" href="images/logo.png" />
<title>Indie Wiki Buddy settings</title>
<style>
#togglesKey > div {
position: relative;
}
#togglesKey > div:hover::after {
content: attr(data-title);
padding: 5px;
width: fit-content;
border: 1px solid #000;
position: absolute;
color: #fff;
background: #000;
z-index: 999999;
transform: translateX(calc(-100% - 24px));
opacity: 80%;
top: -45px;
}
/* ELEMENTS */
body {
max-width: 600px;
max-width: 700px;
margin: 0 auto;
padding: 20px;
background-color: #2b2a33;
font-family: Helvetica, Sans-Serif;
font-size: .9em;
font-size: .9rem;
}
a {
@ -21,6 +41,7 @@
text-decoration-thickness: 1px;
color: #005799;
}
a:visited {
color: #005799;
}
@ -30,24 +51,45 @@
border: none;
color: #005799;
background-color: #005799;
margin: 1em 0 .5em 0;
margin: 1rem 0 .5rem 0;
}
h1 {
font-size: 1.3rem;
padding: .5em 0;
margin: 0;
}
h2 {
font-size: 1.2rem;
text-align: center;
padding: .8em;
padding: .5rem 0;
margin: 0;
}
label {
display: inline-block;
height: 1em;
h2 {
font-size: 1.2rem;
text-align: center;
padding: .8rem;
margin: 0;
}
fieldset {
background-color: #f5fbff;
border: 1px solid #ccc;
border-radius: 5px;
padding: 3px 0 8px 0;
margin: 0;
}
fieldset+fieldset {
margin-top: 1.5rem;
}
fieldset>div {
margin: .4rem .5rem;
}
fieldset>span {
margin: .4rem .8rem 0;
display: block;
}
legend {
margin-left: .5rem;
}
.container {
@ -56,13 +98,14 @@
/* HEADER */
#header {
line-height: 1.5em;
padding: .5em 1em;
line-height: 1.5rem;
padding: .5rem 1rem;
box-sizing: border-box;
background-color: #005799;
color: #fff;
width: 100%;
}
#header .settingToggle label {
background-color: #fff;
border-radius: 20px;
@ -73,12 +116,12 @@
#version {
float: right;
font-size: 1.2rem;
margin: .5em 0;
margin: .5rem 0;
}
#links {
background-color: #e5f4ff;
padding: .5em 1em;
padding: .5rem 1rem;
}
#firstInstallInfo {
@ -90,19 +133,20 @@
#content {
background-color: #fff;
box-sizing: border-box;
padding: 1em .75em;
padding: 1rem .75rem;
}
/* FOOTER */
#footer {
padding-bottom: 1.5em;
padding-bottom: 1.5rem;
text-align: center;
line-height: 1.6em;
line-height: 1.6rem;
box-sizing: border-box;
}
#footer a {
padding: 5px 0px;
color: #3174f1;
color: #005799;
}
/* NOTIFICATIONS */
@ -111,27 +155,18 @@
font-size: .9em;
line-height: 1.3em;
}
#notificationBannerContainer span {
padding: 1em;
padding: .5rem 1rem;
display: none;
}
#notificationBannerContainer span[style*="display: block"] + span[style*="display: block"]{
border-top: 1px solid #000;
}
/* GLOBAL SETTINGS SECTION */
.options {
margin: 0 auto;
box-sizing: border-box;
padding-bottom: .5em;
padding-bottom: .5rem;
user-select: none;
width: fit-content;
}
.options .settingToggleContainer {
padding-bottom: 1em;
}
.options .settingToggleContainer:last-child {
padding-bottom: 0;
width: 100%;
}
/* GLOBAL SETTING TOGGLES */
@ -142,32 +177,44 @@
border: none;
appearance: none;
}
#power img {
margin-left: -8px;
}
.two-col {
display: flex;
gap: .5rem;
padding-bottom: .5rem;
}
.two-col>div {
flex: 50%;
}
.settingToggle {
cursor: pointer;
width: fit-content;
display: inline-block;
}
.settingToggle + div {
display: inline-block;
}
.settingToggle input,
.settingToggle label {
cursor: pointer;
}
.settingToggle img {
width: 30px;
vertical-align: middle;
}
#searchFilteringSettings>div {
display: inline-block;
}
#breezewikiHost {
display: none;
padding-left: 3em;
padding-top: .8em;
padding: 0 0 0 1rem;
}
#breezewikiHost label {
cursor: default;
}
@ -175,10 +222,9 @@
/* WIKI CONTROLS */
#wikiControls {
margin: 0 auto;
width: fit-content;
text-align: center;
padding-bottom: .5em;
padding-bottom: .5rem;
}
#wikiControls button {
background: #ffffff;
border: 1px solid #333333;
@ -187,66 +233,105 @@
padding: 3px 5px;
margin: 3px 5px;
}
#wikiControls button:hover {
cursor: pointer;
background: #3174f1;
border: 1px solid#3174f1;
background: #005799;
border: 1px solid#005799;
color: #ffffff;
}
#wikiControls button:hover img {
filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(288deg) brightness(100%) contrast(100%);
}
#langSelectContainer {
margin-bottom: 10px;
#individualWikiSettings {
text-align: center;
}
#individualWikiSettings legend {
text-align: left;
}
#toggles {
#langSelectContainer {
margin: .75em 0;
text-align: center;
}
.toggles {
font-size: 0.8rem;
white-space: nowrap;
position: relative;
padding: 0 1em;
}
#toggles > div:hover {
.toggles label {
display: flex;
align-items: center;
}
.toggles>div:hover {
background-color: #e8f0fe;
}
#toggles input {
.toggles input {
cursor: pointer;
margin: 0;
}
#toggles > div {
line-height: 2em;
.toggles>div {
line-height: 2rem;
display: flex;
flex-direction: row;
width: 100%;
padding: 0 1rem;
}
#toggles .inputsContainer {
.toggles .inputsContainer {
display: flex;
float: right;
}
#toggles img {
width: 1.2em;
height: 1.2em;
.inputsContainer>label,
.inputsContainer>div {
width: 20px;
justify-content: center;
text-align: center;
}
#togglesKey img {
width: auto;
max-width: 17px;
height: auto;
max-height: 18px;
vertical-align: middle;
}
#toggles a:first-child {
line-height: 1.2em;
padding-right: .5em;
.toggles img {
line-height: 1.2rem;
}
#toggles span {
.toggles a img {
padding-right: .5rem;
}
.toggles span {
flex-grow: 1;
overflow: hidden;
text-overflow: ellipsis;
}
#togglesKey {
padding-right: 15px;
text-align: right;
}
#togglesKey > div {
display: inline-block;
width: 17px;
#defaultToggles {
border-bottom: 1px solid #ccc;
background-color: #f5fbff;
}
#togglesKey>div:last-child, #toggles>div>div>label:last-of-type {
margin-left: .5em;
#togglesKey>div:nth-child(3),
.toggles>div>div>label:nth-child(3) {
padding-right: .4rem;
}
#togglesKey>div:nth-child(4),
.toggles>div>div>label:nth-child(4) {
padding-left: .4rem;
border-left: 1px solid #333;
}
/* CONTROL CLASSES */
@ -261,6 +346,10 @@
white-space: nowrap !important;
border: 0 !important;
}
.text-sm {
font-size: .85em;
}
</style>
</head>
@ -271,41 +360,22 @@
<h1>Indie Wiki Buddy</h1>
</div>
<div id="links">
<a
href="guide.html"
>Guide</a
>
<a href="guide.html">Guide</a>
&nbsp;&nbsp;&nbsp;
<a
href="https://getindie.wiki"
target="_blank"
>Website</a
>
<a href="https://getindie.wiki" target="_blank">Website</a>
&nbsp;&nbsp;&nbsp;
<a
href="https://getindie.wiki/changelog/"
target="_blank"
>Changelog</a
>
<a href="https://getindie.wiki/changelog/" target="_blank">Changelog</a>
&nbsp;&nbsp;&nbsp;
<a
href="https://getindie.wiki/#submit"
target="_blank"
>Submit&nbsp;a&nbsp;Wiki</a
>
<a href="https://getindie.wiki/#submit" target="_blank">Submit&nbsp;a&nbsp;Wiki</a>
&nbsp;&nbsp;&nbsp;
<a
href="https://github.com/KevinPayravi/indie-wiki-buddy"
target="_blank"
>Source&nbsp;Code</a
>
<a href="https://github.com/KevinPayravi/indie-wiki-buddy" target="_blank">Source&nbsp;Code</a>
</div>
<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.
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 turning the extension off
and on via your browser's extension settings (chrome://extensions/).
<a id="chromeBugHideLink" href="#">Hide this message</a>
</span>
<span id="notificationBannerOpera">
@ -317,13 +387,16 @@
<span id="notificationBannerReview">
Enjoying Indie Wiki Buddy? Please leave a review!
<br />
<a id="reviewReminderChromeLink" target="_blank" href="https://chrome.google.com/webstore/detail/indie-wiki-buddy/fkagelmloambgokoeokbpihmgpkbgbfm">Chrome</a>
<a id="reviewReminderChromeLink" target="_blank"
href="https://chrome.google.com/webstore/detail/indie-wiki-buddy/fkagelmloambgokoeokbpihmgpkbgbfm">Chrome</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a id="reviewReminderFirefoxLink" target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/indie-wiki-buddy/">Firefox</a>
<a id="reviewReminderFirefoxLink" target="_blank"
href="https://addons.mozilla.org/en-US/firefox/addon/indie-wiki-buddy/">Firefox</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a id="reviewReminderHideLink" href="#">Hide this message</a>
<br /><br />
Having issues or ideas for improvement? Please <a target="_blank" href="https://getindie.wiki/#contact">contact me</a>!
Having issues or ideas for improvement? Please <a target="_blank" href="https://getindie.wiki/#contact">contact
me</a>!
</span>
</div>
<div id="content">
@ -332,11 +405,13 @@
<br /><br />
Use the links above to see the full guide, submit new wikis, or contact the developer.
<br /><br />
In the "global settings" section below, you can toggle features on and off.
In the settings below, you can toggle features on and off.
By default, search engine filtering and notifications when you are redirected are turned on.
You can also turn on <a href="https://breezewiki.com/" target="_blank">BreezeWiki</a>, which will render Fandom wikis without ads or bloat.
You can also turn on <a href="https://breezewiki.com/" target="_blank">BreezeWiki</a>, which will render Fandom
wikis without ads or bloat.
<br /><br />
Below that, you can configure what happens when you visit each Fandom and Fextralife wiki that has an independent alternative.
Below that, you can configure what happens when you visit each Fandom and Fextralife wiki that has an
independent alternative.
This includes whether you want to be
<img src="images/toggle-alert.png" width="12" alt="" /> alerted (default)
or
@ -353,139 +428,179 @@
<img src="./images/jigsaw.png" width="15" alt="" /> (also at the top right of your browser).
<hr />
</div>
<h2>Global settings</h2>
<div class="options">
<div class="settingToggleContainer">
<div id="power" class="settingToggle">
<form name="options" class="options">
<fieldset id="generalSettings">
<legend><span aria-hidden="true">⚙️</span> General settings</legend>
<div class="settingToggle">
<label>
<input id="powerCheckbox" type="checkbox" />
<img id="powerImage" src="" alt="" />
<span id="powerIcon" aria-hidden="true"></span>
<span id="powerText"></span>
</label>
</div>
</div>
<div class="settingToggleContainer">
<div id="searchFilteringReplace" class="settingToggle">
<label for="searchFilteringReplaceRadio">
<input id="searchFilteringReplaceRadio" type="radio" name="searchSetting" value="replace" />
<span id="searchFilteringReplaceText">🔎 In search engines, disable non-indie wikis & add link to indie counterparts</span>
</label>
</div>
<div id="searchFilteringHide" class="settingToggle">
<label for="searchFilteringHideRadio">
<input id="searchFilteringHideRadio" type="radio" name="searchSetting" value="hide" />
<span id="searchFilteringHideText">🔎 In search engines, hide non-indie wikis that have indie counterparts</span>
</label>
</div>
<div id="searchFilteringNothing" class="settingToggle">
<label for="searchFilteringNothingRadio">
<input id="searchFilteringNothingRadio" type="radio" name="searchSetting" value="nothing" />
<span id="searchFilteringNothingText">🔎 Do nothing on search engines</span>
</label>
</div>
</div>
<div class="settingToggleContainer">
<div id="notifications" class="settingToggle">
<div class="settingToggle">
<label>
<input id="notificationsCheckbox" type="checkbox" />
<span id="notificationsText">🔔 Desktop notifications when redirected to an indie wiki or BreezeWiki</span>
<span id="notificationsIcon" aria-hidden="true"></span>
<span id="notificationsText">Desktop notifications for
redirections</span>
</label>
</div>
</div>
<div class="settingToggleContainer">
<div id="breezewiki" class="settingToggle">
</fieldset>
<fieldset id="breezewikiSettings">
<legend>
<span aria-hidden="true"></span> BreezeWiki settings (<a href="https://breezewiki.com/"
target="_blank">learn&nbsp;more</a>)
</legend>
<div class="settingToggle">
<label>
<input id="breezewikiCheckbox" type="checkbox" />
<span id="breezewikiText">🌬️ Use BreezeWiki on Fandom</span>
<span id="breezewikiText">Use BreezeWiki alternative frontend on Fandom</span>
</label>
</div>
<div>
&nbsp;&nbsp;(<a href="https://breezewiki.com/" target="_blank"
>learn more</a
>)
</div>
<div class="settingToggleContainer">
<div id="breezewikiHost" class="settingToggle">
<label for="breezewikiHostSelect">BreezeWiki Host:&nbsp;</label>
<label for="breezewikiHostSelect">BreezeWiki host:&nbsp;</label>
<select name="breezewikiHost" id="breezewikiHostSelect"></select>
</div>
</div>
</div>
</div>
<hr />
</fieldset>
<div id="wikiControls">
<h2>Individual wiki settings</h2>
<fieldset id="defaultBehaviorSettings">
<legend>
<span aria-hidden="true">📥</span> Default settings for future wikis
</legend>
<div class="two-col">
<div>
<span class="text-sm">When visiting a Fandom or Fextralife wiki:</span>
<div class="settingToggle">
<label for="defaultWikiActionDisabledRadio">
<input id="defaultWikiActionDisabledRadio" type="radio" name="defaultWikiAction" value="disabled" />
<span id="defaultWikiActionDisabledText">
<img src="images/toggle-disabled.png" width="16" alt="" /> Do nothing
</span>
</label>
</div>
<div class="settingToggle">
<label for="defaultWikiActionRedirectRadio">
<input id="defaultWikiActionRedirectRadio" type="radio" name="defaultWikiAction" value="redirect" />
<span id="defaultWikiActionRedirectText">
<img src="images/toggle-redirect.png" width="16" alt="" /> Redirect to indie wiki
</span>
</label>
</div>
<div class="settingToggle">
<label for="defaultWikiActionAlertRadio">
<input id="defaultWikiActionAlertRadio" type="radio" name="defaultWikiAction" value="alert" />
<span id="defaultWikiActionAlertText">
<img src="images/toggle-alert.png" width="16" alt="" /> Display banner linking to indie wiki
</span>
</label>
</div>
</div>
<div>
<span class="text-sm">When using search engines:</span>
<div class="settingToggle">
<label for="defaultSearchActionDisabledRadio">
<input id="defaultSearchActionDisabledRadio" type="radio" name="defaultSearchAction"
value="disabled" />
<span id="defaultSearchActionDisabledText">
<img src="images/toggle-disabled.png" width="16" alt="" /> Do nothing
</span>
</label>
</div>
<div class="settingToggle">
<label for="defaultSearchActionHideRadio">
<input id="defaultSearchActionHideRadio" type="radio" name="defaultSearchAction" value="hide" />
<span id="defaultSearchActionHideText">
<img src="images/toggle-hide.png" width="16" alt="" /> Hide non-indie results
</span>
</label>
</div>
<div class="settingToggle">
<label for="defaultSearchActionReplaceRadio">
<input id="defaultSearchActionReplaceRadio" type="radio" name="defaultSearchAction"
value="replace" />
<span id="defaultSearchActionReplaceText">
<img src="images/toggle-replace.png" width="16" alt="" /> Replace non-indie results
</span>
</label>
</div>
</div>
</div>
<span class="text-sm">Tip: These settings are for wikis added in the future. To change settings for current wikis, use the settings below.</span>
</fieldset>
<fieldset id="individualWikiSettings">
<legend>
<span aria-hidden="true">🎛</span>
Change settings for all wikis displayed below
</legend>
<span class="text-sm">When visiting a Fandom or Fextralife wiki:</span>
<button id="setAllDisabled" type="button">
<img src="images/toggle-disabled.png" width="12" height="12" alt="" /> Do nothing
</button>
<button id="setAllRedirect" type="button">
<img src="images/toggle-redirect.png" width="12" height="12" alt="" /> Redirect to
indie wiki
</button>
<button id="setAllAlert" type="button">
<img src="images/toggle-alert.png" width="12" height="12" alt="" /> Display banner
linking to indie wiki
</button>
<br />
<span class="text-sm">When using search engines:</span>
<button id="setAllSearchEngineDisabled" type="button">
<img src="images/toggle-search-filter.png" width="12" height="12" alt="" /> Do nothing
</button>
<button id="setAllSearchEngineHide" type="button">
<img src="images/toggle-hide.png" width="12" height="12" alt="" /> Hide non-indie results
</button>
<button id="setAllSearchEngineReplace" type="button">
<img src="images/toggle-replace.png" width="12" height="12" alt="" /> Replace non-indie results
</button>
</fieldset>
<div id="langSelectContainer">
Viewing wikis in:&nbsp;
Filter wikis by language:&nbsp;
<select name="lang" id="langSelect">
<option value="DE">Deutsch</option>
<option value="EN" selected>English</option>
<option value="ES">Español</option>
<option value="FR">Français</option>
<option value="IT">Italiano</option>
<option value="PL">Polski</option>
<option value="TOK">Toki Pona</option>
<option value="ALL" selected>All languages</option>
<option value="DE">Deutsch (DE)</option>
<option value="EN">English (EN)</option>
<option value="ES">Español (ES)</option>
<option value="FR">Français (FR)</option>
<option value="IT">Italiano (IT)</option>
<option value="PL">Polski (PL)</option>
<option value="TOK">Toki Pona (TOK)</option>
</select>
</div>
Controls to change settings for all non-indie wikis:
</div>
<div id="defaultToggles" class="toggles">
<div>
<span></span>
<div id="togglesKey" class="inputsContainer">
<div data-title="Do nothing when visiting non-indie wiki">
<img src="images/toggle-disabled.png" width="15" alt="Do nothing" />
</div>
<div data-title="Automatically redirect to indie wiki">
<img src="images/toggle-redirect.png" width="15" alt="Automatically redirect to indie wiki" />
</div>
<div data-title="Show banner when indie wiki is available">
<img src="images/toggle-alert.png" width="15"
alt="Show banner when indie wiki is available" />
</div>
<div data-title="Do nothing on search engines">
<img src="images/toggle-search-filter.png" width="15" alt="Do nothing" />
</div>
<div data-title="Hide non-indie wiki from search results">
<img src="images/toggle-hide.png" width="15" alt="Hide non-indie wiki from search results" />
</div>
<div data-title="Replace non-indie search results">
<img src="images/toggle-replace.png" width="15" alt="Replace non-indie search results" />
</div>
</div>
</div>
</div>
<div id="toggles" class="toggles"></div>
</form>
<br />
<button id="setAllDisabled">
<img src="images/toggle-disabled.png" width="10" alt="" /> Disable all
</button>
<button id="setAllRedirect">
<img src="images/toggle-redirect.png" width="10" alt="" /> Set all to
redirect to indie wikis
</button>
<button id="setAllAlert">
<img src="images/toggle-alert.png" width="10" alt="" /> Set all to
notify of indie wikis
</button>
<br />
<button id="setAllSearchFilter">
<img src="images/toggle-search-filter.png" width="10" alt="" /> Filter
all from search engines
</button>
<button id="setNoneSearchFilter">
<img src="images/toggle-search-filter.png" width="10" alt="" /> Filter
none from search engines
</button>
</div>
<div id="togglesKey">
<div>
<img
src="images/toggle-disabled.png"
width="15"
alt="Disable"
title="Disable"
/>
</div>
<div>
<img
src="images/toggle-redirect.png"
width="15"
alt="Automatically redirect to indie wiki"
title="Automatically redirect to indie wiki"
/>
</div>
<div>
<img
src="images/toggle-alert.png"
width="15"
alt="Show a banner on wikis where an indie alternative is available"
title="Show a banner on wikis where an indie alternative is available"
/>
</div>
<div>
<img
src="images/toggle-search-filter.png"
width="15"
alt="Filter non-indie wikis from Google, Bing, DuckDuckGo, & other search engines"
title="Filter non-indie wikis from Google, Bing, DuckDuckGo, & other search engines"
/>
</div>
</div>
<div id="toggles"></div>
<hr />
<div id="footer">
<h2>Fun Stats</h2>
Alerted to indie wikis <span id="countAlerts"></span> times
@ -500,4 +615,5 @@
</div>
</body>
<script type="text/javascript" src="settings.js"></script>
</html>

View File

@ -13,15 +13,16 @@ Object.prototype.set = function(prop, value) {
// Clear wiki toggles
// Used when switching languages
function resetOptions() {
var toggleContainer = document.getElementById('toggles');
const toggleContainer = document.getElementById('toggles');
toggleContainer.textContent = "";
// Clone "select all" buttons to reset listeners
document.getElementById('setAllDisabled').cloneNode(true);
document.getElementById('setAllRedirect').cloneNode(true);
document.getElementById('setAllAlert').cloneNode(true);
document.getElementById('setAllDisabled').cloneNode(true);
document.getElementById('setAllSearchFilter').cloneNode(true);
document.getElementById('setNoneSearchFilter').cloneNode(true);
document.getElementById('setAllSearchEngineDisabled').cloneNode(true);
document.getElementById('setAllSearchEngineHide').cloneNode(true);
document.getElementById('setAllSearchEngineReplace').cloneNode(true);
}
// Get wiki data from data folder
@ -145,12 +146,16 @@ async function loadBreezeWikiOptions() {
async function loadOptions(lang) {
sites = await getData();
// Sort sites alphabetically by destination
sites.sort((a, b) => a.destination.localeCompare(b.destination));
chrome.storage.local.get(function (localStorage) {
chrome.storage.sync.get(function (syncStorage) {
const storage = {...syncStorage, ...localStorage};
let siteSettings = storage.siteSettings || {};
let defaultActionSettings = storage.defaultActionSettings || {};
let defaultSearchFilterSettings = storage.defaultSearchFilterSettings || {};
let searchEngineSettings = storage.searchEngineSettings || {};
let defaultWikiAction = storage.defaultWikiAction || null;
let defaultSearchAction = storage.defaultSearchAction || null;
// Load BreezeWiki options:
chrome.storage.sync.get(['breezewiki'], function (item) {
@ -159,54 +164,93 @@ async function loadOptions(lang) {
}
});
// Load defaults for newly added wikis:
chrome.storage.sync.get(['defaultWikiAction'], function (item) {
if (item.defaultWikiAction === 'disabled') {
document.options.defaultWikiAction.value = 'disabled';
} else if (item.defaultWikiAction === 'redirect') {
document.options.defaultWikiAction.value = 'redirect';
} else {
document.options.defaultWikiAction.value = 'alert';
}
});
chrome.storage.sync.get(['defaultSearchAction'], function (item) {
if (item.defaultSearchAction === 'disabled') {
document.options.defaultSearchAction.value = 'disabled';
} else if (item.defaultSearchAction === 'hide') {
document.options.defaultSearchAction.value = 'hide';
} else {
document.options.defaultSearchAction.value = 'replace';
}
});
// Populate individual wiki settings:
var toggleContainer = document.getElementById('toggles');
const toggleContainer = document.getElementById('toggles');
for (var i = 0; i < sites.length; i++) {
if (sites[i].language === lang) {
if ((lang === 'ALL') || (sites[i].language === lang)) {
var key = sites[i].id;
// Create radio for disabled:
// Create radio for disabling action on wiki:
let labelDisabled = document.createElement("label");
let inputDisabled = document.createElement("input");
inputDisabled.classList = 'toggleDisable';
inputDisabled.type = "radio";
inputDisabled.name = key;
inputDisabled.title = 'Disable actions for ' + sites[i].origins_label;
inputDisabled.id = key + '-redirect';
inputDisabled.lang = lang;
inputDisabled.name = key + '-wiki-action';
inputDisabled.title = 'Do nothing for ' + sites[i].origins_label + ' on search engines';
inputDisabled.lang = sites[i].language;
inputDisabled.setAttribute('data-wiki-key', key);
// Create radio for redirect:
// Create radio for redirecting wiki:
let labelRedirect = document.createElement("label");
let inputRedirect = document.createElement("input");
inputRedirect.classList = 'toggleRedirect';
inputRedirect.type = "radio";
inputRedirect.name = key;
inputRedirect.title = 'Automatically redirect from ' + sites[i].origins_label + ' to ' + sites[i].destination;
inputRedirect.id = key + '-redirect';
inputRedirect.lang = lang;
inputRedirect.name = key + '-wiki-action';
inputRedirect.title = 'Automatically redirect ' + sites[i].origins_label + ' to ' + sites[i].destination;
inputRedirect.lang = sites[i].language;
inputRedirect.setAttribute('data-wiki-key', key);
// Create radio for alert:
// Create radio for inserting banner on wiki:
let labelAlert = document.createElement("label");
let inputAlert = document.createElement("input");
inputAlert.classList = 'toggleAlert';
inputAlert.type = "radio";
inputAlert.name = key;
inputAlert.title = 'Notify with banner when visiting ' + sites[i].origins_label;
inputAlert.id = key + '-alert';
inputAlert.lang = lang;
inputAlert.name = key + '-wiki-action';
inputAlert.title = 'Show banner on ' + sites[i].origins_label + ' linking to ' + sites[i].destination;
inputAlert.lang = sites[i].language;
inputAlert.setAttribute('data-wiki-key', key);
// Create checkbox for search filtering:
let labelFilter = document.createElement("label");
let inputFilter = document.createElement("input");
inputFilter.classList = 'toggleFilter';
inputFilter.type = 'checkbox';
inputFilter.name = key;
inputFilter.title = 'Filter ' + sites[i].origins_label + ' from Google, Bing, DuckDuckGo, & other search engines';
inputFilter.id = key + '-filter';
inputFilter.lang = lang;
// Create radio for disabling action on search engines:
let labelSearchEngineDisabled = document.createElement("label");
let inputSearchEngineDisabled = document.createElement("input");
inputSearchEngineDisabled.classList = 'toggleSearchEngineDisabled';
inputSearchEngineDisabled.type = "radio";
inputSearchEngineDisabled.name = key + '-search-engine-action';
inputSearchEngineDisabled.title = 'Do nothing for ' + sites[i].origins_label;
inputSearchEngineDisabled.lang = sites[i].language;
inputSearchEngineDisabled.setAttribute('data-wiki-key', key);
// Check radio button based on user's settings
// Will default to alert or the last "select all" setting the user chose
// Create radio for hiding results on search engines:
let labelSearchEngineHide = document.createElement("label");
let inputSearchEngineHide = document.createElement("input");
inputSearchEngineHide.classList = 'toggleSearchEngineHide';
inputSearchEngineHide.type = "radio";
inputSearchEngineHide.name = key + '-search-engine-action';
inputSearchEngineHide.title = 'Hide ' + sites[i].origins_label + ' from search engine results';
inputSearchEngineHide.lang = sites[i].language;
inputSearchEngineHide.setAttribute('data-wiki-key', key);
// Create radio for replacing results on search engines:
let labelSearchEngineReplace = document.createElement("label");
let inputSearchEngineReplace = document.createElement("input");
inputSearchEngineReplace.classList = 'toggleSearchEngineReplace';
inputSearchEngineReplace.type = "radio";
inputSearchEngineReplace.name = key + '-search-engine-action';
inputSearchEngineReplace.title = 'Replace ' + sites[i].origins_label + ' search engine results with ' + sites[i].destination;
inputSearchEngineReplace.lang = sites[i].language;
inputSearchEngineReplace.setAttribute('data-wiki-key', key);
// Check radio buttons based on user's settings
if (siteSettings[key] && siteSettings[key].action) {
if (siteSettings[key].action === 'disabled') {
inputDisabled.checked = true;
@ -216,7 +260,7 @@ async function loadOptions(lang) {
inputAlert.checked = true;
}
} else {
let actionSetting = defaultActionSettings[lang];
let actionSetting = defaultWikiAction;
if (actionSetting) {
if (actionSetting === 'disabled') {
inputDisabled.checked = true;
@ -230,102 +274,134 @@ async function loadOptions(lang) {
}
}
// Check search filter checkbox based on user's settings (default filter):
if (siteSettings[key] && siteSettings[key].searchFilter) {
if (siteSettings[key].searchFilter === 'false') {
inputFilter.checked = false;
if (searchEngineSettings[key] && searchEngineSettings[key].action) {
if (searchEngineSettings[key].action === 'disabled') {
inputSearchEngineDisabled.checked = true;
} else if (searchEngineSettings[key].action === 'replace') {
inputSearchEngineReplace.checked = true;
} else {
inputFilter.checked = true;
inputSearchEngineHide.checked = true;
}
} else {
let searchFilterSetting = defaultSearchFilterSettings[lang];
if (searchFilterSetting && searchFilterSetting === 'false') {
inputFilter.checked = false;
let actionSetting = defaultSearchAction;
if (actionSetting) {
if (actionSetting === 'true' || actionSetting === 'replace') {
inputSearchEngineReplace.checked = true;
} else if (actionSetting === 'false' || actionSetting === 'disabled') {
inputSearchEngineDisabled.checked = true;
} else {
inputFilter.checked = true;
inputSearchEngineHide.checked = true;
}
} else {
inputSearchEngineReplace.checked = true;
}
}
// Add listeners for when user clicks control:
inputRedirect.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
var key = input.target.name;
var key = input.target.getAttribute('data-wiki-key');
response.siteSettings.get(key).set('action', 'redirect');
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
});
});
inputAlert.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
var key = input.target.name;
var key = input.target.getAttribute('data-wiki-key');
response.siteSettings.get(key).set('action', 'alert');
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
});
});
inputDisabled.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
var key = input.target.name;
var key = input.target.getAttribute('data-wiki-key');
response.siteSettings.get(key).set('action', 'disabled');
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
});
});
inputFilter.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'siteSettings': {} }, function (response) {
var key = input.target.name;
if (input.target.checked === true) {
response.siteSettings.get(key).set('searchFilter', 'true');
} else {
response.siteSettings.get(key).set('searchFilter', 'false');
}
chrome.storage.sync.set({ 'siteSettings': response.siteSettings });
inputSearchEngineDisabled.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'searchEngineSettings': {} }, function (response) {
var key = input.target.getAttribute('data-wiki-key');
response.searchEngineSettings.get(key).set('action', 'disabled');
chrome.storage.sync.set({ 'searchEngineSettings': response.searchEngineSettings });
});
});
inputSearchEngineHide.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'searchEngineSettings': {} }, function (response) {
var key = input.target.getAttribute('data-wiki-key');
response.searchEngineSettings.get(key).set('action', 'hide');
chrome.storage.sync.set({ 'searchEngineSettings': response.searchEngineSettings });
});
});
inputSearchEngineReplace.addEventListener('click', function (input) {
chrome.storage.sync.get({ 'searchEngineSettings': {} }, function (response) {
var key = input.target.getAttribute('data-wiki-key');
response.searchEngineSettings.get(key).set('action', 'replace');
chrome.storage.sync.set({ 'searchEngineSettings': response.searchEngineSettings });
});
});
// Output disable radio button:
// Output wiki disable radio button:
let inputDisabledText = document.createElement('span');
inputDisabledText.classList.add('visuallyHidden');
inputDisabledText.textContent = 'Disable action for ' + sites[i].origins_label;
labelDisabled.appendChild(inputDisabled);
labelDisabled.appendChild(inputDisabledText);
// Output redirect radio button:
// Output wiki redirect radio button:
let inputRedirectText = document.createElement('span');
inputRedirectText.classList.add('visuallyHidden');
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].origins_label;
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].origins_label + ' to ' + sites[i].destination;
labelRedirect.appendChild(inputRedirect);
labelRedirect.appendChild(inputRedirectText);
// Output alert radio button:
// Output wiki alert radio button:
let inputAlertText = document.createElement('span');
inputAlertText.classList.add('visuallyHidden');
inputAlertText.textContent = 'Automatically alert for' + sites[i].origins_label;
inputAlertText.textContent = 'Show a banner on ' + sites[i].origins_label + ' linking to ' + sites[i].destination;
labelAlert.appendChild(inputAlert);
labelAlert.appendChild(inputAlertText);
// Output search filter checkbox:
let inputFilterText = document.createElement('span');
inputFilterText.classList.add('visuallyHidden');
inputFilterText.textContent = 'Filter ' + sites[i].origins_label + ' from search engine results';
labelFilter.appendChild(inputFilter);
labelFilter.appendChild(inputFilterText);
// Output search engine disable radio button:
let inputSearchEngineDisabledText = document.createElement('span');
inputSearchEngineDisabledText.classList.add('visuallyHidden');
inputSearchEngineDisabledText.textContent = 'Do nothing for ' + sites[i].origins_label + ' on search engines';
labelSearchEngineDisabled.appendChild(inputSearchEngineDisabled);
labelSearchEngineDisabled.appendChild(inputSearchEngineDisabledText);
// Output search engine hide radio button:
let inputSearchEngineHideText = document.createElement('span');
inputSearchEngineHideText.classList.add('visuallyHidden');
inputSearchEngineHideText.textContent = 'Hide ' + sites[i].origins_label + ' from search engines';
labelSearchEngineHide.appendChild(inputSearchEngineHide);
labelSearchEngineHide.appendChild(inputSearchEngineHideText);
// Output search engine replace radio button:
let inputSearchEngineReplaceText = document.createElement('span');
inputSearchEngineReplaceText.classList.add('visuallyHidden');
inputSearchEngineReplaceText.textContent = 'Replace ' + sites[i].origins_label + ' search engine results with ' + sites[i].destination;
labelSearchEngineReplace.appendChild(inputSearchEngineReplace);
labelSearchEngineReplace.appendChild(inputSearchEngineReplaceText);
// Output wiki info:
let wikiInfo = document.createElement('span');
let iconLink = document.createElement("a");
iconLink.href = 'https://' + sites[i].destination_base_url + sites[i].destination_content_path;
iconLink.title = 'Visit ' + sites[i].destination;
iconLink.target = '_blank';
let wikiLink = document.createElement("a");
wikiLink.href = 'https://' + sites[i].destination_base_url + sites[i].destination_content_path;
wikiLink.title = 'Visit ' + sites[i].destination;
wikiLink.target = '_blank';
let icon = document.createElement("img");
icon.src = 'favicons/' + lang.toLowerCase() + '/' + sites[i].destination_icon;
icon.src = 'favicons/' + sites[i].language.toLowerCase() + '/' + sites[i].destination_icon;
icon.alt = 'Visit ' + sites[i].destination;
iconLink.appendChild(icon);
let destinationLink = document.createElement("a");
destinationLink.title = sites[i].destination;
destinationLink.href = 'https://' + sites[i].destination_base_url + sites[i].destination_content_path;
destinationLink.target = '_blank';
destinationLink.append(document.createTextNode(sites[i].destination));
wikiInfo.appendChild(iconLink);
wikiInfo.appendChild(document.createTextNode(sites[i].origins_label + ' » '));
wikiInfo.appendChild(destinationLink);
wikiLink.appendChild(icon);
wikiLink.appendChild(document.createTextNode(sites[i].destination));
wikiInfo.appendChild(wikiLink);
wikiInfo.appendChild(document.createTextNode(' (from ' + sites[i].origins_label + ')'));
if (lang === 'ALL') {
const languageSpan = document.createElement('span');
languageSpan.classList.add('text-sm');
languageSpan.innerText = ' [' + sites[i].language + '] ';
wikiInfo.appendChild(languageSpan);
}
let siteContainer = document.createElement("div");
// Output inputs container:
@ -333,7 +409,9 @@ async function loadOptions(lang) {
inputsContainer.appendChild(labelDisabled);
inputsContainer.appendChild(labelRedirect);
inputsContainer.appendChild(labelAlert);
inputsContainer.appendChild(labelFilter);
inputsContainer.appendChild(labelSearchEngineDisabled);
inputsContainer.appendChild(labelSearchEngineHide);
inputsContainer.appendChild(labelSearchEngineReplace);
inputsContainer.classList = 'inputsContainer';
siteContainer.appendChild(wikiInfo);
siteContainer.appendChild(inputsContainer);
@ -342,64 +420,64 @@ async function loadOptions(lang) {
}
// Add "select all" button event listeners:
var setAllRedirect = document.getElementById('setAllRedirect');
const setAllRedirect = document.getElementById('setAllRedirect');
setAllRedirect.addEventListener('click', function () {
var toggles = document.querySelectorAll('#toggles input.toggleRedirect');
const toggles = document.querySelectorAll('#toggles input.toggleRedirect');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = true;
siteSettings.get(toggles[i].name).set('action', 'redirect');
siteSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'redirect');
}
chrome.storage.sync.set({ 'siteSettings': siteSettings });
defaultActionSettings[toggles[0].lang] = 'redirect';
chrome.storage.sync.set({ 'defaultActionSettings': defaultActionSettings });
});
var setAllAlert = document.getElementById('setAllAlert');
const setAllAlert = document.getElementById('setAllAlert');
setAllAlert.addEventListener('click', function () {
var toggles = document.querySelectorAll('#toggles input.toggleAlert');
const toggles = document.querySelectorAll('#toggles input.toggleAlert');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = true;
siteSettings.get(toggles[i].name).set('action', 'alert');
siteSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'alert');
}
chrome.storage.sync.set({ 'siteSettings': siteSettings });
defaultActionSettings[toggles[0].lang] = 'alert';
chrome.storage.sync.set({ 'defaultActionSettings': defaultActionSettings });
});
var setAllDisabled = document.getElementById('setAllDisabled');
const setAllDisabled = document.getElementById('setAllDisabled');
setAllDisabled.addEventListener('click', function () {
var toggles = document.querySelectorAll('#toggles input.toggleDisable');
const toggles = document.querySelectorAll('#toggles input.toggleDisable');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = true;
siteSettings.get(toggles[i].name).set('action', 'disabled');
siteSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'disabled');
}
chrome.storage.sync.set({ 'siteSettings': siteSettings });
defaultActionSettings[toggles[0].lang] = 'disabled';
chrome.storage.sync.set({ 'defaultActionSettings': defaultActionSettings });
});
var setAllSearchFilter = document.getElementById('setAllSearchFilter');
setAllSearchFilter.addEventListener('click', function () {
var toggles = document.querySelectorAll('#toggles input.toggleFilter');
const setAllSearchEngineDisabled = document.getElementById('setAllSearchEngineDisabled');
setAllSearchEngineDisabled.addEventListener('click', function () {
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineDisabled');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = true;
siteSettings.get(toggles[i].name).set('searchFilter', 'true');
searchEngineSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'disabled');
}
chrome.storage.sync.set({ 'siteSettings': siteSettings });
defaultSearchFilterSettings[toggles[0].lang] = 'true';
chrome.storage.sync.set({ 'defaultSearchFilterSettings': defaultSearchFilterSettings });
chrome.storage.sync.set({ 'searchEngineSettings': searchEngineSettings });
});
var setNoneSearchFilter = document.getElementById('setNoneSearchFilter');
setNoneSearchFilter.addEventListener('click', function () {
var toggles = document.querySelectorAll('#toggles input.toggleFilter');
const setAllSearchEngineHide = document.getElementById('setAllSearchEngineHide');
setAllSearchEngineHide.addEventListener('click', function () {
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineHide');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = false;
siteSettings.get(toggles[i].name).set('searchFilter', 'false');
toggles[i].checked = true;
searchEngineSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'hide');
}
chrome.storage.sync.set({ 'siteSettings': siteSettings });
defaultSearchFilterSettings[toggles[0].lang] = 'false';
chrome.storage.sync.set({ 'defaultSearchFilterSettings': defaultSearchFilterSettings });
chrome.storage.sync.set({ 'searchEngineSettings': searchEngineSettings });
});
const setAllSearchEngineReplace = document.getElementById('setAllSearchEngineReplace');
setAllSearchEngineReplace.addEventListener('click', function () {
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineReplace');
for (var i = 0; i < toggles.length; i++) {
toggles[i].checked = true;
searchEngineSettings.get(toggles[i].getAttribute('data-wiki-key')).set('action', 'replace');
}
chrome.storage.sync.set({ 'searchEngineSettings': searchEngineSettings });
});
});
});
@ -410,14 +488,15 @@ function setPower(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.local.set({ 'power': setting });
}
var powerImage = document.getElementById('powerImage');
powerImage.src = 'images/power-' + setting + '.png';
var powerText = document.getElementById('powerText');
const powerText = document.getElementById('powerText');
powerText.textContent = 'Extension is ' + setting;
const powerIcon = document.getElementById('powerIcon');
if (setting === 'on') {
document.getElementById('powerCheckbox').checked = true;
powerIcon.innerText = '🔋';
} else {
document.getElementById('powerCheckbox').checked = false;
powerIcon.innerText = '🪫';
}
chrome.runtime.sendMessage({
@ -431,24 +510,13 @@ function setNotifications(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'notifications': setting });
}
const notificationsIcon = document.getElementById('notificationsIcon');
if (setting === 'on') {
document.getElementById('notificationsCheckbox').checked = true;
notificationsIcon.innerText = '🔔';
} else {
document.getElementById('notificationsCheckbox').checked = false;
}
}
// Set search filter setting
function setSearchSetting(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'searchSetting': setting });
}
if (setting === 'hide') {
document.getElementById('searchFilteringHideRadio').checked = true;
} else if (setting === 'nothing') {
document.getElementById('searchFilteringNothingRadio').checked = true;
} else {
document.getElementById('searchFilteringReplaceRadio').checked = true;
notificationsIcon.innerText = '🔕';
}
}
@ -457,7 +525,7 @@ function setBreezeWiki(setting, storeSetting = true) {
if (storeSetting) {
chrome.storage.sync.set({ 'breezewiki': setting });
}
var breezewikiHost = document.getElementById('breezewikiHost');
const breezewikiHost = document.getElementById('breezewikiHost');
if (setting === 'on') {
document.getElementById('breezewikiCheckbox').checked = true;
} else {
@ -590,7 +658,7 @@ document.addEventListener('DOMContentLoaded', function () {
loadOptions(item.lang);
});
// Add event listener for language select
var langSelect = document.getElementById("langSelect");
const langSelect = document.getElementById("langSelect");
langSelect.addEventListener('change', function () {
chrome.storage.sync.set({ 'lang': langSelect.value });
resetOptions();
@ -604,14 +672,14 @@ document.addEventListener('DOMContentLoaded', function () {
chrome.storage.sync.get({ 'notifications': 'on' }, function (item) {
setNotifications(item.notifications, false);
});
chrome.storage.sync.get({ 'searchSetting': 'replace' }, function (item) {
setSearchSetting(item.searchSetting, false);
});
// chrome.storage.sync.get({ 'searchSetting': 'replace' }, function (item) {
// setSearchSetting(item.searchSetting, false);
// });
chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) {
setBreezeWiki(item.breezewiki, false);
});
// Add event listeners for setting toggles
// Add event listeners for general setting toggles
document.getElementById('powerCheckbox').addEventListener('change', function () {
chrome.storage.local.get({ 'power': 'on' }, function (item) {
if (item.power === 'on') {
@ -630,15 +698,8 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
});
document.getElementById('searchFilteringReplaceRadio').addEventListener('change', function () {
setSearchSetting('replace');
});
document.getElementById('searchFilteringHideRadio').addEventListener('change', function () {
setSearchSetting('hide');
});
document.getElementById('searchFilteringNothingRadio').addEventListener('change', function () {
setSearchSetting('nothing');
});
// Add event listeners for BreezeWiki settings
document.getElementById('breezewikiCheckbox').addEventListener('change', function () {
chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) {
if (item.breezewiki === 'on') {
@ -649,11 +710,23 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
});
var breezewikiHostSelect = document.getElementById("breezewikiHostSelect");
const breezewikiHostSelect = document.getElementById('breezewikiHostSelect');
breezewikiHostSelect.addEventListener('change', function () {
chrome.storage.sync.set({ 'breezewikiHost': breezewikiHostSelect.value });
});
// Add event listeners for default action selections
document.querySelectorAll('[name="defaultWikiAction"]').forEach((el) => {
el.addEventListener('change', function () {
chrome.storage.sync.set({ 'defaultWikiAction': document.options.defaultWikiAction.value })
});
});
document.querySelectorAll('[name="defaultSearchAction"]').forEach((el) => {
el.addEventListener('change', function () {
chrome.storage.sync.set({ 'defaultSearchAction': document.options.defaultSearchAction.value })
});
});
// Get and display stat counts
chrome.storage.sync.get({ 'countAlerts': 0 }, function (item) {
var key = Object.keys(item)[0];