2024-02-20 08:11:51 +00:00
|
|
|
const breezewikiRegex = /breezewiki\.com$|antifandom\.com$|bw\.artemislena\.eu$|breezewiki\.catsarch\.com$|breezewiki\.esmailelbob\.xyz$|breezewiki\.frontendfriendly\.xyz$|bw\.hamstro\.dev$|breeze\.hostux\.net$|breezewiki\.hyperreal\.coffee$|breeze\.mint\.lgbt$|breezewiki\.nadeko\.net$|nerd\.whatever\.social$|breeze\.nohost\.network$|z\.opnxng\.com$|bw\.projectsegfau\.lt$|breezewiki\.pussthecat\.org$|bw\.vern\.cc$|breeze\.whateveritworks\.org$|breezewiki\.woodland\.cafe$/;
|
2023-02-06 00:48:53 +00:00
|
|
|
const currentURL = new URL(document.location);
|
|
|
|
|
2024-01-07 00:12:01 +00:00
|
|
|
function outputBannerContainer() {
|
|
|
|
if (!document.getElementById('indie-wiki-banner-container')) {
|
|
|
|
const container = document.createElement('div');
|
|
|
|
container.id = 'indie-wiki-banner-container';
|
2024-01-29 10:20:12 +00:00
|
|
|
let containerExit = document.createElement('div');
|
|
|
|
containerExit.classList.add('indie-wiki-banner-exit');
|
|
|
|
container.appendChild(containerExit);
|
|
|
|
containerExit.textContent = '✕';
|
|
|
|
containerExit.onclick = function () { this.parentElement.remove(); };
|
2024-01-07 00:12:01 +00:00
|
|
|
document.body.insertAdjacentElement('beforeBegin', container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function processBreezeWikiBanner(storage) {
|
|
|
|
// Output BreezeWiki banner, if enabled:
|
|
|
|
if (storage.breezewiki === 'banner' && currentURL.toString().includes('.fandom.com/wiki/')) {
|
|
|
|
// Extract article from URL
|
|
|
|
const subdomain = currentURL.hostname.split(".")[0];
|
|
|
|
const article = currentURL.toString().split('fandom.com/wiki/')[1].replaceAll('%20', '_');
|
|
|
|
breezewikiHost = '';
|
|
|
|
if (!(storage.breezewikiHost ?? null)) {
|
|
|
|
fetch('https://bw.getindie.wiki/instances.json')
|
|
|
|
.then((response) => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json();
|
|
|
|
}
|
|
|
|
throw new Error('Indie Wiki Buddy failed to get BreezeWiki data.');
|
|
|
|
}).then((breezewikiHosts) => {
|
|
|
|
breezewikiHosts = breezewikiHosts.filter(host =>
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.runtime.getManifest().version.localeCompare(host.iwb_version,
|
2024-01-07 00:12:01 +00:00
|
|
|
undefined,
|
|
|
|
{ numeric: true, sensitivity: 'base' }
|
|
|
|
) >= 0
|
|
|
|
);
|
|
|
|
// Check if BreezeWiki's main site is available
|
|
|
|
let breezewikiMain = breezewikiHosts.filter(host => host.instance === 'https://breezewiki.com');
|
|
|
|
if (breezewikiMain.length > 0) {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHost': breezewikiMain[0].instance });
|
2024-01-07 00:12:01 +00:00
|
|
|
} else {
|
|
|
|
// If BreezeWiki.com is not available, set to a random mirror
|
|
|
|
try {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHost': breezewikiHosts[Math.floor(Math.random() * breezewikiHosts.length)].instance });
|
2024-01-07 00:12:01 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.log('Indie Wiki Buddy failed to get BreezeWiki data: ' + e);
|
|
|
|
}
|
|
|
|
}
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHostOptions': breezewikiHosts });
|
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHostFetchTimestamp': Date.now() });
|
2024-01-07 00:12:01 +00:00
|
|
|
breezewikiHost = host;
|
|
|
|
}).catch((e) => {
|
|
|
|
console.log('Indie Wiki Buddy failed to get BreezeWiki data: ' + e);
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'breezewikiHost': 'https://breezewiki.com' });
|
2024-01-07 00:12:01 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (storage.breezewikiHost === 'CUSTOM') {
|
|
|
|
breezewikiHost = storage.breezewikiCustomHost || 'https://breezewiki.com';
|
|
|
|
} else {
|
|
|
|
breezewikiHost = storage.breezewikiHost;
|
|
|
|
}
|
2023-06-26 01:49:04 +00:00
|
|
|
}
|
2024-01-07 00:12:01 +00:00
|
|
|
|
|
|
|
displayBreezewikiBanner(breezewikiHost + '/' + subdomain + '/wiki/' + article);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function displayBreezewikiBanner(newUrl) {
|
|
|
|
// Output banner
|
|
|
|
let banner = document.createElement('div');
|
|
|
|
banner.id = 'indie-wiki-banner-bw';
|
|
|
|
banner.classList.add('indie-wiki-banner');
|
|
|
|
|
|
|
|
// Output main banner text
|
|
|
|
let bannerText = document.createElement('span');
|
|
|
|
let bannerWikiLink = document.createElement('a');
|
|
|
|
bannerWikiLink.classList.add('indie-wiki-banner-link');
|
|
|
|
bannerWikiLink.href = newUrl;
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerWikiLink.textContent = extensionAPI.i18n.getMessage('bannerBreezeWiki');
|
2024-01-07 00:12:01 +00:00
|
|
|
bannerText.appendChild(bannerWikiLink);
|
|
|
|
banner.appendChild(bannerText);
|
|
|
|
|
|
|
|
// Function to insert banner into DOM before body element
|
|
|
|
function addBannerToDOM() {
|
|
|
|
// Check if document is in a ready state
|
|
|
|
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
|
|
// Add banner container if not already in doc
|
|
|
|
outputBannerContainer();
|
|
|
|
// Ensure banner isn't already outputted
|
|
|
|
if (!document.querySelector(':root > #indie-wiki-banner-bw')) {
|
|
|
|
document.getElementById('indie-wiki-banner-container').appendChild(banner);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove readystatechange listener
|
|
|
|
document.removeEventListener('readystatechange', addBannerToDOM);
|
2023-06-26 01:49:04 +00:00
|
|
|
}
|
2024-01-07 00:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('readystatechange', addBannerToDOM);
|
|
|
|
addBannerToDOM();
|
|
|
|
}
|
|
|
|
|
2024-07-18 09:32:58 +00:00
|
|
|
function displayRedirectBanner(newUrl, id, destinationName, destinationLanguage, host, tags, storage) {
|
2023-02-06 00:48:53 +00:00
|
|
|
// Output banner
|
2023-12-18 05:34:37 +00:00
|
|
|
let banner = document.createElement('div');
|
2024-01-07 00:12:01 +00:00
|
|
|
banner.id = 'indie-wiki-banner-redirect';
|
|
|
|
banner.classList.add('indie-wiki-banner');
|
2023-06-26 01:49:04 +00:00
|
|
|
|
2023-06-30 06:44:20 +00:00
|
|
|
// Output control links container
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerControls = document.createElement('div');
|
2024-01-07 00:12:01 +00:00
|
|
|
bannerControls.classList.add('indie-wiki-banner-controls');
|
2023-06-30 06:44:20 +00:00
|
|
|
banner.appendChild(bannerControls);
|
|
|
|
|
2023-06-26 01:49:04 +00:00
|
|
|
// Output "restore banner" link
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerRestoreLink = document.createElement('div');
|
2024-01-07 00:12:01 +00:00
|
|
|
bannerRestoreLink.classList.add('indie-wiki-banner-restore');
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerRestoreLink.classList.add('indie-wiki-banner-link');
|
|
|
|
bannerRestoreLink.classList.add('indie-wiki-banner-link-small');
|
|
|
|
bannerRestoreLink.classList.add('indie-wiki-banner-hidden');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerRestoreLink.textContent = extensionAPI.i18n.getMessage('bannerRestore');
|
2023-06-30 06:44:20 +00:00
|
|
|
bannerControls.appendChild(bannerRestoreLink);
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerRestoreLink.onclick = function (e) {
|
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);
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[id] = 'alert';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2024-06-29 10:20:53 +00:00
|
|
|
e.target.textContent = extensionAPI.i18n.getMessage('bannerRestoreDone');
|
2023-06-26 01:49:04 +00:00
|
|
|
e.target.classList.add('indie-wiki-banner-disabled');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-redirect').textContent = extensionAPI.i18n.getMessage('bannerRedirect');
|
2024-02-08 10:13:37 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-redirect').classList.remove('indie-wiki-banner-disabled');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-disable').textContent = extensionAPI.i18n.getMessage('bannerDisable');
|
2024-02-08 10:13:37 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-disable').classList.remove('indie-wiki-banner-hidden');
|
|
|
|
bannerControls.querySelector('.indie-wiki-banner-disable').classList.remove('indie-wiki-banner-disabled');
|
2023-06-26 01:49:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output "disable banner" link
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerDisableLink = document.createElement('div');
|
2024-01-07 00:12:01 +00:00
|
|
|
bannerDisableLink.classList.add('indie-wiki-banner-disable');
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerDisableLink.classList.add('indie-wiki-banner-link');
|
|
|
|
bannerDisableLink.classList.add('indie-wiki-banner-link-small');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerDisableLink.textContent = extensionAPI.i18n.getMessage('bannerDisable');
|
2023-06-30 06:44:20 +00:00
|
|
|
bannerControls.appendChild(bannerDisableLink);
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerDisableLink.onclick = function (e) {
|
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);
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[id] = 'disabled';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2024-06-29 10:20:53 +00:00
|
|
|
e.target.textContent = extensionAPI.i18n.getMessage('bannerDisableDone');
|
2023-06-26 01:49:04 +00:00
|
|
|
e.target.classList.add('indie-wiki-banner-disabled');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').textContent = extensionAPI.i18n.getMessage('bannerRestore');
|
2024-02-08 10:13:37 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').classList.remove('indie-wiki-banner-hidden');
|
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').classList.remove('indie-wiki-banner-disabled');
|
2023-06-26 01:49:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output "auto redirect" link
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerRedirectLink = document.createElement('div');
|
2024-01-07 00:12:01 +00:00
|
|
|
bannerRedirectLink.classList.add('indie-wiki-banner-redirect');
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerRedirectLink.classList.add('indie-wiki-banner-link');
|
|
|
|
bannerRedirectLink.classList.add('indie-wiki-banner-link-small');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerRedirectLink.textContent = extensionAPI.i18n.getMessage('bannerRedirect');
|
2023-06-30 06:44:20 +00:00
|
|
|
bannerControls.appendChild(bannerRedirectLink);
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerRedirectLink.onclick = function (e) {
|
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);
|
2024-02-27 08:55:41 +00:00
|
|
|
wikiSettings[id] = 'redirect';
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'wikiSettings': await commonFunctionCompressJSON(wikiSettings) });
|
2024-06-29 10:20:53 +00:00
|
|
|
e.target.textContent = extensionAPI.i18n.getMessage('bannerRedirectDone');
|
2023-06-26 01:49:04 +00:00
|
|
|
e.target.classList.add('indie-wiki-banner-disabled');
|
2024-02-08 10:13:37 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-disable').classList.add('indie-wiki-banner-hidden');
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').textContent = extensionAPI.i18n.getMessage('bannerRestore');
|
2024-02-08 10:13:37 +00:00
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').classList.remove('indie-wiki-banner-hidden');
|
|
|
|
bannerControls.querySelector('.indie-wiki-banner-restore').classList.remove('indie-wiki-banner-disabled');
|
2023-06-26 01:49:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output main banner text
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerText = document.createElement('span');
|
2023-06-30 06:44:20 +00:00
|
|
|
bannerText.classList.add('indie-wiki-banner-big-text');
|
2023-02-06 00:48:53 +00:00
|
|
|
banner.appendChild(bannerText);
|
2024-01-07 00:12:01 +00:00
|
|
|
|
2024-07-18 10:21:22 +00:00
|
|
|
// Build descriptors
|
|
|
|
let wikiDescriptor = extensionAPI.i18n.getMessage('bannerDescriptorIndependent');
|
|
|
|
let hostDescriptor = '';
|
|
|
|
|
2024-07-18 09:32:58 +00:00
|
|
|
if (host) {
|
2024-07-18 10:21:22 +00:00
|
|
|
hostDescriptor = extensionAPI.i18n.getMessage('bannerHost', host);
|
2024-07-18 09:32:58 +00:00
|
|
|
if (tags.includes('official')) {
|
2024-07-18 10:21:22 +00:00
|
|
|
wikiDescriptor = extensionAPI.i18n.getMessage('bannerDescriptorOfficial');
|
2024-07-18 09:32:58 +00:00
|
|
|
} else {
|
2024-07-18 10:21:22 +00:00
|
|
|
wikiDescriptor = extensionAPI.i18n.getMessage('bannerDescriptorWiki');
|
2024-07-18 09:32:58 +00:00
|
|
|
}
|
|
|
|
} else if (tags.includes('official')) {
|
2024-07-18 10:21:22 +00:00
|
|
|
wikiDescriptor = extensionAPI.i18n.getMessage('bannerDescriptorIndependentOfficial');
|
2023-12-18 05:34:37 +00:00
|
|
|
}
|
|
|
|
|
2023-11-18 07:39:04 +00:00
|
|
|
if (destinationLanguage === 'EN' && location.href.match(/fandom\.com\/[a-z]{2}\/wiki\//)) {
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerText.textContent = extensionAPI.i18n.getMessage('bannerText', [
|
2024-07-18 10:21:22 +00:00
|
|
|
wikiDescriptor,
|
|
|
|
hostDescriptor,
|
2024-06-29 10:20:53 +00:00
|
|
|
extensionAPI.i18n.getMessage('bannerLanguageEnglish')
|
|
|
|
]);
|
2023-11-05 05:52:22 +00:00
|
|
|
} else {
|
2024-07-18 10:21:22 +00:00
|
|
|
bannerText.textContent = extensionAPI.i18n.getMessage('bannerText', [wikiDescriptor, hostDescriptor, '']);
|
2023-11-05 05:52:22 +00:00
|
|
|
}
|
2023-12-18 05:34:37 +00:00
|
|
|
let bannerWikiLink = document.createElement('a');
|
2023-06-26 01:49:04 +00:00
|
|
|
bannerWikiLink.classList.add('indie-wiki-banner-link');
|
|
|
|
bannerText.appendChild(bannerWikiLink);
|
2023-11-05 05:52:22 +00:00
|
|
|
bannerWikiLink.href = newUrl;
|
2024-06-29 10:20:53 +00:00
|
|
|
bannerWikiLink.textContent = extensionAPI.i18n.getMessage('bannerVisit', [destinationName]);
|
2023-06-26 01:49:04 +00:00
|
|
|
|
2023-09-21 06:37:17 +00:00
|
|
|
// Function to insert banner into DOM before body element
|
|
|
|
function addBannerToDOM() {
|
|
|
|
// Check if document is in a ready state
|
|
|
|
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
2024-01-07 00:12:01 +00:00
|
|
|
// Add banner container if not already in doc
|
|
|
|
outputBannerContainer();
|
2023-09-21 06:44:50 +00:00
|
|
|
// Ensure banner isn't already outputted
|
2024-01-07 00:12:01 +00:00
|
|
|
if (!document.querySelector(':root > #indie-wiki-banner-redirect')) {
|
|
|
|
document.getElementById('indie-wiki-banner-container').appendChild(banner);
|
2023-09-21 06:44:50 +00:00
|
|
|
// Increment banner count
|
|
|
|
if (storage.breezewiki === 'on') {
|
2023-12-13 09:41:04 +00:00
|
|
|
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost?.includes(currentURL.hostname))) {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'countAlerts': (storage.countAlerts ?? 0) + 1 });
|
2023-09-21 06:44:50 +00:00
|
|
|
}
|
|
|
|
} else {
|
2024-04-23 05:18:42 +00:00
|
|
|
extensionAPI.storage.sync.set({ 'countAlerts': (storage.countAlerts ?? 0) + 1 });
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2024-01-04 08:36:26 +00:00
|
|
|
|
|
|
|
// Hide duplicative indie wiki notice on BreezeWiki instances
|
|
|
|
if (currentURL.hostname.match(breezewikiRegex)) {
|
|
|
|
const bwIndieNotice = document.querySelector('aside.niwa__notice');
|
|
|
|
if (bwIndieNotice) {
|
|
|
|
bwIndieNotice.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2023-09-21 06:44:50 +00:00
|
|
|
|
|
|
|
// Remove readystatechange listener
|
|
|
|
document.removeEventListener('readystatechange', addBannerToDOM);
|
2023-09-21 06:37:17 +00:00
|
|
|
}
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2023-09-21 06:37:17 +00:00
|
|
|
|
|
|
|
document.addEventListener('readystatechange', addBannerToDOM);
|
|
|
|
addBannerToDOM();
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2023-07-25 06:17:46 +00:00
|
|
|
function main() {
|
2024-06-04 04:03:07 +00:00
|
|
|
extensionAPI.runtime.sendMessage({ action: 'getStorage' }, (storage) => {
|
2024-03-21 05:09:18 +00:00
|
|
|
// Check if extension is on:
|
|
|
|
if ((storage.power ?? 'on') === 'on') {
|
|
|
|
// Check if there is a pathname, to ensure we're looking at an article
|
|
|
|
if (currentURL.pathname.length > 1) {
|
|
|
|
processBreezeWikiBanner(storage);
|
|
|
|
|
|
|
|
let origin = currentURL.toString();
|
|
|
|
|
|
|
|
// If on a BreezeWiki site, convert to Fandom link to match with our list of wikis:
|
|
|
|
if (currentURL.hostname.match(breezewikiRegex) || (storage.breezewikiHost === 'CUSTOM' && storage.breezewikiCustomHost?.includes(currentURL.hostname))) {
|
|
|
|
origin = String(currentURL.pathname).split('/')[1] + '.fandom.com/wiki/';
|
|
|
|
if (currentURL.search.includes('?q=')) {
|
2024-06-04 04:03:07 +00:00
|
|
|
origin = 'https://' + origin + currentURL.search.substring(3);
|
2024-03-21 05:09:18 +00:00
|
|
|
} else {
|
|
|
|
origin = 'https://' + origin + currentURL.pathname.split('/')[3];
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2024-03-21 05:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
commonFunctionGetSiteDataByOrigin().then(async sites => {
|
|
|
|
let crossLanguageSetting = storage.crossLanguage || 'off';
|
|
|
|
let matchingSite = await commonFunctionFindMatchingSite(origin, crossLanguageSetting);
|
|
|
|
if (matchingSite) {
|
|
|
|
// Get user's settings for the wiki
|
|
|
|
let id = matchingSite['id'];
|
|
|
|
let siteSetting = 'alert';
|
|
|
|
let wikiSettings = await commonFunctionDecompressJSON(storage.wikiSettings || {});
|
|
|
|
if (wikiSettings[id]) {
|
|
|
|
siteSetting = wikiSettings[id];
|
|
|
|
} else if (storage.defaultWikiAction) {
|
|
|
|
siteSetting = storage.defaultWikiAction;
|
|
|
|
}
|
2024-01-07 00:12:01 +00:00
|
|
|
|
2024-03-21 05:09:18 +00:00
|
|
|
// Notify if enabled for the wiki:
|
|
|
|
if (siteSetting === 'alert') {
|
|
|
|
let newURL = commonFunctionGetNewURL(origin, matchingSite);
|
|
|
|
|
|
|
|
// When head elem is loaded, notify that another wiki is available
|
|
|
|
const docObserver = new MutationObserver((mutations, mutationInstance) => {
|
|
|
|
const headElement = document.querySelector('head');
|
|
|
|
if (headElement) {
|
|
|
|
try {
|
2024-07-18 09:32:58 +00:00
|
|
|
displayRedirectBanner(newURL, matchingSite['id'], matchingSite['destination'], matchingSite['language'], matchingSite['destination_host'], matchingSite['tags'], storage);
|
2024-03-21 05:09:18 +00:00
|
|
|
} finally {
|
|
|
|
mutationInstance.disconnect();
|
2024-01-10 09:21:47 +00:00
|
|
|
}
|
2024-03-21 05:09:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
docObserver.observe(document, {
|
|
|
|
childList: true,
|
|
|
|
subtree: true
|
|
|
|
});
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2024-03-21 05:09:18 +00:00
|
|
|
}
|
|
|
|
});
|
2023-02-06 00:48:53 +00:00
|
|
|
}
|
2024-03-21 05:09:18 +00:00
|
|
|
}
|
2023-02-06 00:48:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-21 05:09:18 +00:00
|
|
|
main();
|