2023-04-12 05:01:06 +00:00
|
|
|
var sites = [];
|
|
|
|
|
|
|
|
// Clear wiki toggles
|
|
|
|
// Used when switching languages
|
|
|
|
function resetOptions() {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggleContainer = document.getElementById('toggles');
|
2023-04-12 05:01:06 +00:00
|
|
|
toggleContainer.textContent = "";
|
|
|
|
|
|
|
|
// Clone "select all" buttons to reset listeners
|
2023-11-02 08:12:35 +00:00
|
|
|
document.getElementById('setAllDisabled').cloneNode(true);
|
2023-04-12 05:01:06 +00:00
|
|
|
document.getElementById('setAllRedirect').cloneNode(true);
|
|
|
|
document.getElementById('setAllAlert').cloneNode(true);
|
2023-11-02 08:12:35 +00:00
|
|
|
document.getElementById('setAllSearchEngineDisabled').cloneNode(true);
|
|
|
|
document.getElementById('setAllSearchEngineHide').cloneNode(true);
|
|
|
|
document.getElementById('setAllSearchEngineReplace').cloneNode(true);
|
2023-04-12 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2023-11-18 05:34:26 +00:00
|
|
|
// Populate settings and toggles
|
2023-12-07 01:14:41 +00:00
|
|
|
async function loadOptions(lang, textFilter = '') {
|
2024-01-10 09:21:47 +00:00
|
|
|
sites = await commonFunctionGetSiteDataByDestination();
|
2023-12-07 01:14:41 +00:00
|
|
|
textFilter = textFilter.toLocaleLowerCase();
|
2023-06-28 06:29:50 +00:00
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
// Sort sites alphabetically by destination
|
2023-11-05 07:00:22 +00:00
|
|
|
sites.sort((a, b) => {
|
|
|
|
a = a.destination.toLowerCase().replace(' ', '');
|
|
|
|
b = b.destination.toLowerCase().replace(' ', '');
|
|
|
|
return a < b ? -1 : (a > b ? 1 : 0);
|
|
|
|
});
|
2023-11-02 08:12:35 +00:00
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
// Filter wikis by provided language and text filter
|
|
|
|
sites = sites.filter((site) => (
|
|
|
|
(lang === 'ALL' || site.language === lang) &&
|
|
|
|
(site.origins_label.toLowerCase().includes(textFilter) ||
|
2024-02-27 09:43:55 +00:00
|
|
|
site.destination.toLowerCase().includes(textFilter) ||
|
|
|
|
site.destination_base_url.toLowerCase().includes(textFilter))
|
2023-12-07 01:14:41 +00:00
|
|
|
));
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.get((localStorage) => {
|
|
|
|
extensionAPI.storage.sync.get(async (syncStorage) => {
|
2023-11-04 07:54:41 +00:00
|
|
|
const storage = { ...syncStorage, ...localStorage };
|
2024-02-08 08:34:53 +00:00
|
|
|
let wikiSettings = await commonFunctionDecompressJSON(storage.wikiSettings || {});
|
|
|
|
let searchEngineSettings = await commonFunctionDecompressJSON(storage.searchEngineSettings || {});
|
2023-11-02 08:12:35 +00:00
|
|
|
let defaultWikiAction = storage.defaultWikiAction || null;
|
|
|
|
let defaultSearchAction = storage.defaultSearchAction || null;
|
2023-06-28 06:29:50 +00:00
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
// Load defaults for newly added wikis:
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get(['defaultWikiAction'], (item) => {
|
2023-11-02 08:12:35 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
});
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get(['defaultSearchAction'], (item) => {
|
2023-11-02 08:12:35 +00:00
|
|
|
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';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
// Reset toggles:
|
|
|
|
resetOptions();
|
|
|
|
|
2023-04-28 05:17:29 +00:00
|
|
|
// Populate individual wiki settings:
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggleContainer = document.getElementById('toggles');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < sites.length; i++) {
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = sites[i].id;
|
|
|
|
|
|
|
|
// 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 + '-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 inserting banner on wiki:
|
|
|
|
let labelAlert = document.createElement("label");
|
|
|
|
let inputAlert = document.createElement("input");
|
|
|
|
inputAlert.classList = 'toggleAlert';
|
|
|
|
inputAlert.type = "radio";
|
|
|
|
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 radio for redirecting wiki:
|
|
|
|
let labelRedirect = document.createElement("label");
|
|
|
|
let inputRedirect = document.createElement("input");
|
|
|
|
inputRedirect.classList = 'toggleRedirect';
|
|
|
|
inputRedirect.type = "radio";
|
|
|
|
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 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);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// Check radio buttons based on user's settings
|
|
|
|
if (wikiSettings[key]) {
|
|
|
|
if (wikiSettings[key] === 'disabled') {
|
|
|
|
inputDisabled.checked = true;
|
|
|
|
} else if (wikiSettings[key] === 'redirect') {
|
|
|
|
inputRedirect.checked = true;
|
|
|
|
} else {
|
|
|
|
inputAlert.checked = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let actionSetting = defaultWikiAction;
|
|
|
|
if (actionSetting) {
|
|
|
|
if (actionSetting === 'disabled') {
|
2023-04-12 05:01:06 +00:00
|
|
|
inputDisabled.checked = true;
|
2023-12-07 01:14:41 +00:00
|
|
|
} else if (actionSetting === 'redirect') {
|
2023-04-12 05:01:06 +00:00
|
|
|
inputRedirect.checked = true;
|
|
|
|
} else {
|
|
|
|
inputAlert.checked = true;
|
|
|
|
}
|
|
|
|
} else {
|
2023-12-07 01:14:41 +00:00
|
|
|
inputAlert.checked = true;
|
2023-04-12 05:01:06 +00:00
|
|
|
}
|
2023-12-07 01:14:41 +00:00
|
|
|
}
|
2023-04-12 05:01:06 +00:00
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
if (searchEngineSettings[key]) {
|
|
|
|
if (searchEngineSettings[key] === 'disabled') {
|
|
|
|
inputSearchEngineDisabled.checked = true;
|
|
|
|
} else if (searchEngineSettings[key] === 'replace') {
|
|
|
|
inputSearchEngineReplace.checked = true;
|
|
|
|
} else {
|
|
|
|
inputSearchEngineHide.checked = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let actionSetting = defaultSearchAction;
|
|
|
|
if (actionSetting) {
|
|
|
|
if (actionSetting === 'true' || actionSetting === 'replace') {
|
2023-11-02 08:12:35 +00:00
|
|
|
inputSearchEngineReplace.checked = true;
|
2023-12-07 01:14:41 +00:00
|
|
|
} else if (actionSetting === 'false' || actionSetting === 'disabled') {
|
|
|
|
inputSearchEngineDisabled.checked = true;
|
2023-04-28 05:17:29 +00:00
|
|
|
} else {
|
2023-11-02 08:12:35 +00:00
|
|
|
inputSearchEngineHide.checked = true;
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2023-04-12 05:01:06 +00:00
|
|
|
} else {
|
2023-12-07 01:14:41 +00:00
|
|
|
inputSearchEngineReplace.checked = true;
|
2023-04-12 05:01:06 +00:00
|
|
|
}
|
2023-12-07 01:14:41 +00:00
|
|
|
}
|
2023-04-12 05:01:06 +00:00
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
// Add listeners for when user clicks control:
|
2023-12-13 10:10:55 +00:00
|
|
|
inputDisabled.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'wikiSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let wikiSettings = await commonFunctionDecompressJSON(response.wikiSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[key] = 'disabled';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
inputAlert.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'wikiSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let wikiSettings = await commonFunctionDecompressJSON(response.wikiSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[key] = 'alert';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
inputRedirect.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'wikiSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let wikiSettings = await commonFunctionDecompressJSON(response.wikiSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[key] = 'redirect';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
inputSearchEngineDisabled.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'searchEngineSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let searchEngineSettings = await commonFunctionDecompressJSON(response.searchEngineSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[key] = 'disabled';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-11-02 08:12:35 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
inputSearchEngineReplace.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'searchEngineSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let searchEngineSettings = await commonFunctionDecompressJSON(response.searchEngineSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[key] = 'replace';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-11-02 08:12:35 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
inputSearchEngineHide.addEventListener('click', (input) => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'searchEngineSettings': {} }, async (response) => {
|
2024-02-08 08:34:53 +00:00
|
|
|
let searchEngineSettings = await commonFunctionDecompressJSON(response.searchEngineSettings);
|
2023-12-07 01:14:41 +00:00
|
|
|
var key = input.target.getAttribute('data-wiki-key');
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[key] = 'hide';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
2023-12-07 01:14:41 +00:00
|
|
|
});
|
2023-04-12 05:01:06 +00:00
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
// 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 wiki alert radio button:
|
|
|
|
let inputAlertText = document.createElement('span');
|
|
|
|
inputAlertText.classList.add('visuallyHidden');
|
|
|
|
inputAlertText.textContent = 'Show a banner on ' + sites[i].origins_label + ' linking to ' + sites[i].destination;
|
|
|
|
labelAlert.appendChild(inputAlert);
|
|
|
|
labelAlert.appendChild(inputAlertText);
|
|
|
|
|
|
|
|
// Output wiki redirect radio button:
|
|
|
|
let inputRedirectText = document.createElement('span');
|
|
|
|
inputRedirectText.classList.add('visuallyHidden');
|
|
|
|
inputRedirectText.textContent = 'Automatically redirect ' + sites[i].origins_label + ' to ' + sites[i].destination;
|
|
|
|
labelRedirect.appendChild(inputRedirect);
|
|
|
|
labelRedirect.appendChild(inputRedirectText);
|
|
|
|
|
|
|
|
// 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 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 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 wiki info:
|
|
|
|
let wikiInfo = document.createElement('span');
|
|
|
|
let iconLink = document.createElement("a");
|
2023-12-12 10:03:31 +00:00
|
|
|
iconLink.href = 'https://' + sites[i].destination_base_url;
|
2023-12-07 01:14:41 +00:00
|
|
|
iconLink.title = 'Visit ' + sites[i].destination;
|
|
|
|
iconLink.target = '_blank';
|
|
|
|
let icon = document.createElement("img");
|
2024-01-11 04:27:23 +00:00
|
|
|
icon.src = '../../favicons/' + sites[i].language.toLowerCase() + '/' + sites[i].destination_icon;
|
2023-12-07 01:14:41 +00:00
|
|
|
icon.alt = 'Visit ' + sites[i].destination;
|
2024-04-26 03:39:55 +00:00
|
|
|
icon.width = '16';
|
2023-12-07 01:14:41 +00:00
|
|
|
iconLink.appendChild(icon);
|
|
|
|
wikiInfo.appendChild(iconLink);
|
|
|
|
if (lang === 'ALL') {
|
|
|
|
const languageSpan = document.createElement('span');
|
|
|
|
languageSpan.classList.add('text-sm');
|
|
|
|
languageSpan.innerText = ' [' + sites[i].language + '] ';
|
|
|
|
wikiInfo.appendChild(languageSpan);
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2023-12-07 01:14:41 +00:00
|
|
|
let wikiLink = document.createElement("a");
|
2023-12-12 10:03:31 +00:00
|
|
|
wikiLink.href = 'https://' + sites[i].destination_base_url;
|
2023-12-07 01:14:41 +00:00
|
|
|
wikiLink.title = 'Visit ' + sites[i].destination;
|
|
|
|
wikiLink.target = '_blank';
|
|
|
|
wikiLink.appendChild(document.createTextNode(sites[i].destination));
|
|
|
|
wikiInfo.appendChild(wikiLink);
|
|
|
|
wikiInfo.appendChild(document.createTextNode(' (from ' + sites[i].origins_label + ')'));
|
|
|
|
let siteContainer = document.createElement("div");
|
2024-03-21 05:10:55 +00:00
|
|
|
siteContainer.classList.add('site-container')
|
2023-12-07 01:14:41 +00:00
|
|
|
|
|
|
|
// Output inputs container:
|
|
|
|
let inputsContainer = document.createElement('div');
|
|
|
|
inputsContainer.appendChild(labelDisabled);
|
|
|
|
inputsContainer.appendChild(labelAlert);
|
|
|
|
inputsContainer.appendChild(labelRedirect);
|
|
|
|
inputsContainer.appendChild(labelSearchEngineDisabled);
|
|
|
|
inputsContainer.appendChild(labelSearchEngineReplace);
|
|
|
|
inputsContainer.appendChild(labelSearchEngineHide);
|
|
|
|
inputsContainer.classList = 'inputsContainer';
|
|
|
|
siteContainer.appendChild(wikiInfo);
|
|
|
|
siteContainer.appendChild(inputsContainer);
|
|
|
|
toggleContainer.appendChild(siteContainer);
|
2023-04-12 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 05:17:29 +00:00
|
|
|
// Add "select all" button event listeners:
|
2023-11-02 08:12:35 +00:00
|
|
|
const setAllRedirect = document.getElementById('setAllRedirect');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllRedirect.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleRedirect');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[toggles[i].getAttribute('data-wiki-key')] = 'redirect';
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-28 05:17:29 +00:00
|
|
|
});
|
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
const setAllAlert = document.getElementById('setAllAlert');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllAlert.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleAlert');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[toggles[i].getAttribute('data-wiki-key')] = 'alert';
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-28 05:17:29 +00:00
|
|
|
});
|
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
const setAllDisabled = document.getElementById('setAllDisabled');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllDisabled.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleDisable');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[toggles[i].getAttribute('data-wiki-key')] = 'disabled';
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2023-04-28 05:17:29 +00:00
|
|
|
});
|
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
const setAllSearchEngineDisabled = document.getElementById('setAllSearchEngineDisabled');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllSearchEngineDisabled.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineDisabled');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[toggles[i].getAttribute('data-wiki-key')] = 'disabled';
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-11-02 08:12:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const setAllSearchEngineHide = document.getElementById('setAllSearchEngineHide');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllSearchEngineHide.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineHide');
|
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[toggles[i].getAttribute('data-wiki-key')] = 'hide';
|
2023-11-02 08:12:35 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-04-28 05:17:29 +00:00
|
|
|
});
|
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
const setAllSearchEngineReplace = document.getElementById('setAllSearchEngineReplace');
|
2024-02-08 08:34:53 +00:00
|
|
|
setAllSearchEngineReplace.addEventListener('click', async () => {
|
2023-11-02 08:12:35 +00:00
|
|
|
const toggles = document.querySelectorAll('#toggles input.toggleSearchEngineReplace');
|
2023-04-28 05:17:29 +00:00
|
|
|
for (var i = 0; i < toggles.length; i++) {
|
2023-11-02 08:12:35 +00:00
|
|
|
toggles[i].checked = true;
|
2024-02-27 08:55:41 +00:00
|
|
|
searchEngineSettings[toggles[i].getAttribute('data-wiki-key')] = 'replace';
|
2023-04-28 05:17:29 +00:00
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'searchEngineSettings': await commonFunctionCompressJSON(searchEngineSettings) });
|
2023-04-28 05:17:29 +00:00
|
|
|
});
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-18 08:03:37 +00:00
|
|
|
function displayCustomSearchEngine(customSearchEngineHostname, customSearchEnginePreset) {
|
|
|
|
let customSearchEnginesList = document.getElementById('customSearchEnginesList');
|
|
|
|
|
|
|
|
let listItem = document.createElement('div');
|
|
|
|
listItem.classList.add('customSearchEngine');
|
|
|
|
|
|
|
|
let customSearchEngineHostnameLabel = document.createElement('span');
|
|
|
|
customSearchEngineHostnameLabel.classList.add('customSearchEngineHostname');
|
|
|
|
customSearchEngineHostnameLabel.innerText = customSearchEngineHostname;
|
|
|
|
|
|
|
|
let customSearchEnginePresetLabel = document.createElement('span');
|
|
|
|
customSearchEnginePresetLabel.classList.add('customSearchEnginePreset');
|
|
|
|
customSearchEnginePresetLabel.innerText = document.getElementById('newCustomSearchEnginePreset')
|
|
|
|
.querySelector(`option[value="${customSearchEnginePreset}"]`).innerText;
|
|
|
|
|
|
|
|
let customSearchEngineDeleteButton = document.createElement('button');
|
|
|
|
customSearchEngineDeleteButton.classList.add('customSearchEngineDelete');
|
|
|
|
customSearchEngineDeleteButton.innerText = 'Delete';
|
|
|
|
customSearchEngineDeleteButton.addEventListener('click', () => {
|
|
|
|
listItem.remove();
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'customSearchEngines': {} }, (item) => {
|
2024-03-18 08:03:37 +00:00
|
|
|
let customSearchEngines = item.customSearchEngines;
|
|
|
|
delete customSearchEngines[customSearchEngineHostname];
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'customSearchEngines': customSearchEngines });
|
2024-03-18 08:03:37 +00:00
|
|
|
});
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
let customSearchEngine = customSearchEngineHostname;
|
|
|
|
// Add "https://" if not already present
|
|
|
|
if (!customSearchEngine.includes('://')) {
|
|
|
|
customSearchEngine = 'https://' + customSearchEngine;
|
|
|
|
}
|
|
|
|
customSearchEngine = new URL(customSearchEngine);
|
|
|
|
extensionAPI.permissions.remove({
|
|
|
|
origins: [ `${customSearchEngine}*` ]
|
|
|
|
});
|
|
|
|
|
|
|
|
extensionAPI.scripting.unregisterContentScripts({ ids: [`content-search-filtering-${customSearchEngineHostname}`] });
|
2024-03-18 08:03:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
listItem.appendChild(customSearchEngineHostnameLabel);
|
|
|
|
listItem.appendChild(customSearchEnginePresetLabel);
|
|
|
|
listItem.appendChild(customSearchEngineDeleteButton);
|
|
|
|
|
|
|
|
customSearchEnginesList.appendChild(listItem);
|
|
|
|
}
|
|
|
|
|
2023-04-12 05:01:06 +00:00
|
|
|
// Set power setting
|
2023-04-27 05:47:34 +00:00
|
|
|
function setPower(setting, storeSetting = true) {
|
|
|
|
if (storeSetting) {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'power': setting });
|
2023-04-27 05:47:34 +00:00
|
|
|
}
|
2023-11-02 08:12:35 +00:00
|
|
|
const powerText = document.getElementById('powerText');
|
2023-04-12 05:01:06 +00:00
|
|
|
powerText.textContent = 'Extension is ' + setting;
|
2023-11-02 08:12:35 +00:00
|
|
|
const powerIcon = document.getElementById('powerIcon');
|
2023-04-12 05:01:06 +00:00
|
|
|
if (setting === 'on') {
|
|
|
|
document.getElementById('powerCheckbox').checked = true;
|
2023-11-02 08:12:35 +00:00
|
|
|
powerIcon.innerText = '🔋';
|
2023-04-12 05:01:06 +00:00
|
|
|
} else {
|
|
|
|
document.getElementById('powerCheckbox').checked = false;
|
2023-11-02 08:12:35 +00:00
|
|
|
powerIcon.innerText = '🪫';
|
2023-04-12 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.runtime.sendMessage({
|
2023-04-12 05:01:06 +00:00
|
|
|
action: 'updateIcon',
|
|
|
|
value: setting
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-04 07:54:41 +00:00
|
|
|
async function migrateData() {
|
2024-01-10 09:21:47 +00:00
|
|
|
commonFunctionMigrateToV3();
|
2023-11-04 07:54:41 +00:00
|
|
|
}
|
|
|
|
|
2023-04-12 05:01:06 +00:00
|
|
|
// Main function that runs on-load
|
2023-12-13 10:10:55 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2023-09-18 09:05:46 +00:00
|
|
|
// If newly installed, show initial install guide
|
|
|
|
if (new URLSearchParams(window.location.search).get('newinstall')) {
|
|
|
|
document.getElementById('firstInstallInfo').style.display = 'block';
|
|
|
|
}
|
|
|
|
|
2023-10-17 07:06:15 +00:00
|
|
|
// If running Opera, show note about search engine access
|
2023-10-16 05:53:26 +00:00
|
|
|
if (navigator.userAgent.match(/OPR\//)) {
|
2023-10-17 07:06:15 +00:00
|
|
|
const notificationBannerOpera = document.getElementById('notificationBannerOpera');
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.get({ 'hideOperaPermissionsNote': false }, (item) => {
|
2023-10-17 07:06:15 +00:00
|
|
|
if (!item.hideOperaPermissionsNote) {
|
|
|
|
notificationBannerOpera.style.display = 'block';
|
|
|
|
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('operaPermsHideLink').addEventListener('click', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'hideOperaPermissionsNote': true });
|
2023-10-17 07:06:15 +00:00
|
|
|
notificationBannerOpera.style.display = 'none';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2023-10-16 05:53:26 +00:00
|
|
|
}
|
|
|
|
|
2023-04-27 05:15:36 +00:00
|
|
|
// Count number of times settings have been opened
|
|
|
|
// Purposefully using local storage instead of sync
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.get({ 'countSettingsOpened': 0 }, (item) => {
|
2023-04-27 05:15:36 +00:00
|
|
|
const countSettingsOpened = item.countSettingsOpened;
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'countSettingsOpened': countSettingsOpened + 1 });
|
2023-04-27 05:15:36 +00:00
|
|
|
|
|
|
|
// Show review reminder every 5 opens,
|
|
|
|
// and if the banner hasn't been previously dismissed
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.get({ 'hideReviewReminder': false }, (item) => {
|
2023-04-27 05:15:36 +00:00
|
|
|
if (!item.hideReviewReminder && ((countSettingsOpened - 1) % 5 === 0)) {
|
2023-10-17 07:06:15 +00:00
|
|
|
const notificationBannerReview = document.getElementById('notificationBannerReview');
|
|
|
|
|
|
|
|
notificationBannerReview.style.display = 'block';
|
2023-07-01 06:33:11 +00:00
|
|
|
document.getElementById('notificationBannerReview').style.display = ' block';
|
2023-04-27 05:15:36 +00:00
|
|
|
|
2023-04-27 05:53:24 +00:00
|
|
|
// Disable future review reminders if user clicks links:
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('reviewReminderChromeLink').addEventListener('click', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'hideReviewReminder': true });
|
2023-07-01 06:33:11 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('reviewReminderFirefoxLink').addEventListener('click', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'hideReviewReminder': true });
|
2023-04-27 05:53:24 +00:00
|
|
|
});
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('reviewReminderHideLink').addEventListener('click', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.local.set({ 'hideReviewReminder': true });
|
2023-10-17 07:06:15 +00:00
|
|
|
notificationBannerReview.style.display = 'none';
|
2023-07-01 06:33:11 +00:00
|
|
|
});
|
2023-04-27 05:15:36 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-04-12 05:01:06 +00:00
|
|
|
// Adding version to popup:
|
2024-04-23 05:18:42 +00:00
|
|
|
const version = extensionAPI.runtime.getManifest().version;
|
2023-04-12 05:01:06 +00:00
|
|
|
document.getElementById('version').textContent = 'v' + version;
|
|
|
|
|
|
|
|
// Get user's last set language
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'lang': 'EN' }, (item) => {
|
2023-04-12 05:01:06 +00:00
|
|
|
langSelect.value = item.lang;
|
2023-12-07 01:14:41 +00:00
|
|
|
const filterInput = document.getElementById('filterInput').value;
|
|
|
|
loadOptions(item.lang, filterInput);
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
|
|
|
// Add event listener for language select
|
2023-11-02 08:12:35 +00:00
|
|
|
const langSelect = document.getElementById("langSelect");
|
2023-12-13 10:10:55 +00:00
|
|
|
langSelect.addEventListener('change', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'lang': langSelect.value });
|
2023-12-07 01:14:41 +00:00
|
|
|
const filterInput = document.getElementById('filterInput').value;
|
|
|
|
loadOptions(langSelect.value, filterInput);
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
|
|
|
|
2024-01-10 09:21:47 +00:00
|
|
|
// Add event listener for BreezeWiki host select
|
2023-11-02 08:12:35 +00:00
|
|
|
const breezewikiHostSelect = document.getElementById('breezewikiHostSelect');
|
2023-12-13 10:10:55 +00:00
|
|
|
breezewikiHostSelect.addEventListener('change', () => {
|
2023-11-27 03:00:08 +00:00
|
|
|
if (breezewikiHostSelect.value === 'CUSTOM') {
|
|
|
|
document.getElementById('breezewikiCustomHost').style.display = 'block';
|
|
|
|
document.getElementById('breezewikiCustomHostStatus').innerText = '';
|
|
|
|
} else {
|
|
|
|
document.getElementById('breezewikiCustomHost').style.display = 'none';
|
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHost': breezewikiHostSelect.value });
|
2023-04-12 05:01:06 +00:00
|
|
|
});
|
|
|
|
|
2023-11-27 03:00:08 +00:00
|
|
|
function setCustomBreezewikiDomain() {
|
|
|
|
let breezewikiCustomDomain = document.getElementById('customBreezewikiHost').value;
|
|
|
|
// Add "https://" if not already present
|
|
|
|
if (!/^https?:\/\//i.test(breezewikiCustomDomain)) {
|
|
|
|
breezewikiCustomDomain = 'https://' + breezewikiCustomDomain;
|
|
|
|
}
|
|
|
|
// Reduce to just protocal + hostname
|
|
|
|
breezewikiCustomDomain = new URL(breezewikiCustomDomain);
|
|
|
|
breezewikiCustomDomain = breezewikiCustomDomain.protocol + "//" + breezewikiCustomDomain.hostname
|
|
|
|
breezewikiCustomDomain = breezewikiCustomDomain.toString();
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.permissions.request({
|
2023-11-27 03:00:08 +00:00
|
|
|
origins: [breezewikiCustomDomain + '/*']
|
|
|
|
}, (granted) => {
|
|
|
|
// The callback argument will be true if the user granted the permissions.
|
|
|
|
if (granted) {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.scripting.registerContentScripts([{
|
2023-11-27 03:00:08 +00:00
|
|
|
id: 'content-banners',
|
|
|
|
matches: [breezewikiCustomDomain + '/*'],
|
2024-02-23 07:27:53 +00:00
|
|
|
js: ['/scripts/common-functions.js', '/scripts/content-banners.js', '/scripts/content-breezewiki.js'],
|
|
|
|
runAt: "document_idle"
|
2023-11-27 03:00:08 +00:00
|
|
|
}]);
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiCustomHost': breezewikiCustomDomain });
|
2023-11-27 03:00:08 +00:00
|
|
|
document.getElementById('breezewikiCustomHostStatus').innerText = 'Successfully added';
|
|
|
|
} else {
|
|
|
|
document.getElementById('breezewikiCustomHostStatus').innerText = 'Failed to set host';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('setCustomBreezewikiDomain').addEventListener('click', () => {
|
2024-02-27 09:43:55 +00:00
|
|
|
setCustomBreezewikiDomain();
|
2023-11-27 03:00:08 +00:00
|
|
|
});
|
2024-02-27 09:43:55 +00:00
|
|
|
document.getElementById('customBreezewikiHost').onkeyup = function (e) {
|
2023-11-27 03:00:08 +00:00
|
|
|
if (e.key === 'Enter') {
|
|
|
|
setCustomBreezewikiDomain();
|
|
|
|
}
|
|
|
|
}
|
2024-02-27 09:43:55 +00:00
|
|
|
document.options.addEventListener("submit", function (e) {
|
2023-11-27 03:00:08 +00:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2024-03-18 08:03:37 +00:00
|
|
|
// Add event listener for adding custom search engine
|
|
|
|
function addCustomSearchEngine() {
|
|
|
|
let customSearchEngine = document.getElementById('newCustomSearchEngineDomain').value;
|
|
|
|
|
|
|
|
// Add "https://" if not already present
|
|
|
|
if (!customSearchEngine.includes('://')) {
|
|
|
|
customSearchEngine = 'https://' + customSearchEngine;
|
|
|
|
}
|
|
|
|
customSearchEngine = new URL(customSearchEngine);
|
|
|
|
|
|
|
|
// Check not already added
|
|
|
|
let hostnames = document.querySelectorAll('.customSearchEngineHostname');
|
|
|
|
for (let i = 0; i < hostnames.length; i++) {
|
|
|
|
if (hostnames[i].innerText === customSearchEngine.hostname) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.permissions.request({
|
2024-03-18 08:03:37 +00:00
|
|
|
origins: [ `${customSearchEngine}*` ]
|
|
|
|
}, (granted) => {
|
|
|
|
// Callback is true if the user granted the permissions.
|
|
|
|
if (!granted) return;
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
try {
|
|
|
|
extensionAPI.scripting.registerContentScripts([{
|
|
|
|
id: `content-search-filtering-${customSearchEngine.hostname}`,
|
|
|
|
matches: [customSearchEngine + '*'],
|
|
|
|
js: [ '/scripts/common-functions.js', '/scripts/content-search-filtering.js' ],
|
|
|
|
runAt: "document_start"
|
|
|
|
}]);
|
|
|
|
} catch(e) {
|
|
|
|
(`Could not register content script for ${customSearchEngine}.`)
|
|
|
|
}
|
2024-03-18 08:03:37 +00:00
|
|
|
|
|
|
|
let customSearchEnginePreset = document.getElementById('newCustomSearchEnginePreset').value;
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'customSearchEngines': {} }, (item) => {
|
2024-03-18 08:03:37 +00:00
|
|
|
let customSearchEngines = item.customSearchEngines;
|
|
|
|
customSearchEngines[customSearchEngine.hostname] = customSearchEnginePreset;
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'customSearchEngines': customSearchEngines });
|
2024-03-18 08:03:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
displayCustomSearchEngine(customSearchEngine.hostname, customSearchEnginePreset);
|
|
|
|
|
|
|
|
document.getElementById('newCustomSearchEngineDomain').value = '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-23 05:18:42 +00:00
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
// Custom search engines are currently disabled
|
|
|
|
// due to content scripts being unregistered on-update.
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
// document.getElementById('addCustomSearchEngine').addEventListener('click', () => {
|
|
|
|
// addCustomSearchEngine();
|
|
|
|
// });
|
|
|
|
// document.getElementById('newCustomSearchEngineDomain').onkeyup = function(e) {
|
|
|
|
// if (e.key === 'Enter') {
|
|
|
|
// addCustomSearchEngine();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
extensionAPI.storage.sync.get({ 'customSearchEngines': {} }, (item) => {
|
2024-03-18 08:03:37 +00:00
|
|
|
Object.keys(item.customSearchEngines).forEach((key) => {
|
|
|
|
displayCustomSearchEngine(key, item.customSearchEngines[key]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-11-02 08:12:35 +00:00
|
|
|
// Add event listeners for default action selections
|
|
|
|
document.querySelectorAll('[name="defaultWikiAction"]').forEach((el) => {
|
2023-12-13 10:10:55 +00:00
|
|
|
el.addEventListener('change', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'defaultWikiAction': document.options.defaultWikiAction.value })
|
2023-11-02 08:12:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
document.querySelectorAll('[name="defaultSearchAction"]').forEach((el) => {
|
2023-12-13 10:10:55 +00:00
|
|
|
el.addEventListener('change', () => {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'defaultSearchAction': document.options.defaultSearchAction.value })
|
2023-11-02 08:12:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-12-07 01:14:41 +00:00
|
|
|
// Add event listener for filtering by text
|
2023-12-13 10:10:55 +00:00
|
|
|
document.getElementById('filterInput').addEventListener('input', (e) => {
|
2023-12-07 01:14:41 +00:00
|
|
|
const langSelect = document.getElementById("langSelect");
|
|
|
|
loadOptions(langSelect.value, e.target.value);
|
|
|
|
});
|
|
|
|
|
2023-04-12 05:01:06 +00:00
|
|
|
// Get and display stat counts
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'countAlerts': 0 }, (item) => {
|
2023-04-12 05:01:06 +00:00
|
|
|
var key = Object.keys(item)[0];
|
|
|
|
document.getElementById('countAlerts').textContent = item[key];
|
|
|
|
});
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'countRedirects': 0 }, (item) => {
|
2023-04-12 05:01:06 +00:00
|
|
|
var key = Object.keys(item)[0];
|
|
|
|
document.getElementById('countRedirects').textContent = item[key];
|
|
|
|
});
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'countSearchFilters': 0 }, (item) => {
|
2023-04-12 05:01:06 +00:00
|
|
|
var key = Object.keys(item)[0];
|
|
|
|
document.getElementById('countSearchFilters').textContent = item[key];
|
2023-06-27 08:10:03 +00:00
|
|
|
});
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.get({ 'countBreezeWiki': 0 }, (item) => {
|
2023-06-27 08:10:03 +00:00
|
|
|
var key = Object.keys(item)[0];
|
|
|
|
document.getElementById('countBreezeWiki').textContent = item[key];
|
|
|
|
});
|
2023-09-15 04:35:20 +00:00
|
|
|
});
|
2023-11-05 10:21:33 +00:00
|
|
|
|
|
|
|
// Run v3 data migration:
|
|
|
|
migrateData();
|