In BreezeWiki, append bw-redirect query param to Fandom links

pull/416/head
Kevin Payravi 2024-01-04 03:12:31 -06:00
parent 5fb980f4da
commit 0131ebcd2c
2 changed files with 17 additions and 8 deletions

View File

@ -160,7 +160,7 @@ function redirectToBreezeWiki(storage, tabId, url) {
} }
} }
if (url.includes('fandom.com/wiki/')) { if (url.includes('fandom.com/wiki/') && !url.includes('bw-redirect=no')) {
if (!(storage.breezewikiHost ?? null)) { if (!(storage.breezewikiHost ?? null)) {
fetch('https://bw.getindie.wiki/instances.json') fetch('https://bw.getindie.wiki/instances.json')
.then((response) => { .then((response) => {

View File

@ -5,3 +5,12 @@ bwTopBanners.forEach((banner) => {
banner.style.display = 'none'; banner.style.display = 'none';
} }
}); });
// Append bw-redirect query param to Fandom links
// This allows users to click a Fandom link without being redirected back to BW
const bwFandomLinks = document.querySelectorAll('a[href*=".fandom.com"]');
bwFandomLinks.forEach((link) => {
const url = new URL(link);
url.searchParams.append('bw-redirect', 'no');
link.href = url;
});