Search filtering for Kagi

pull/512/head
Autumn McKee 2024-02-21 23:27:37 +00:00 committed by Kevin Payravi
parent 723b8957b2
commit 4ca39ec1c3
5 changed files with 27 additions and 2 deletions

View File

@ -38,7 +38,7 @@ Large, corporate-run wiki farms have enabled hundreds of great wikis and communi
When visiting a wiki on a large corporate wiki farm such as Fandom, Indie Wiki Buddy will notify and/or automatically redirect you if a quality, independent alternative is available. You can customize your experience per-wiki.
In addition, search results in Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, Startpage, Qwant, and Yandex can also be filtered, replacing non-independent wikis with text inviting you to visit the independent counterpart.
In addition, search results in Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, Startpage, Qwant, Yandex, and Kagi can also be filtered, replacing non-independent wikis with text inviting you to visit the independent counterpart.
Indie Wiki Buddy also supports [BreezeWiki](https://breezewiki.com/), a service that renders Fandom wikis without ads or bloat. This helps give you a more enjoyable reading experience on Fandom when an independent wiki isn't available.

View File

@ -84,6 +84,7 @@
"https://*.ya.ru/*",
"https://*.startpage.com/*",
"https://*.search.yahoo.com/*",
"https://kagi.com/search*",
"https://www.google.com/search*",
"https://www.google.ad/search*",
"https://www.google.ae/search*",

View File

@ -162,6 +162,7 @@
"https://*.ya.ru/*",
"https://*.startpage.com/*",
"https://*.search.yahoo.com/*",
"https://kagi.com/search*",
"https://www.google.com/search*",
"https://www.google.ad/search*",
"https://www.google.ae/search*",

View File

@ -101,7 +101,7 @@
<br /><br />
When you visit a wiki on a large, corporate-run wiki host, this extension can notify or automatically redirect
you to quality independent wikis when they're available.
Search results in Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, Startpage, Qwant, and Yandex can also be filtered,
Search results in Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, Startpage, Qwant, Yandex, and Kagi can also be filtered,
replacing non-independent wikis with links to independent counterpart (or hiding them completely).
<br /><br />
We currently redirect from Fandom and Fextralife wikis to independent counterparts.

View File

@ -335,6 +335,9 @@ function hideSearchResults(searchResultContainer, searchEngine, site, showBanner
document.querySelector('#main-algo').prepend(searchRemovalNotice);
}
break;
case 'kagi':
document.querySelector('#main').prepend(searchRemovalNotice);
break;
default:
}
}
@ -485,6 +488,9 @@ async function filterSearchResults(searchResults, searchEngine, storage) {
case 'yahoo':
searchResultContainer = searchResult.closest('#web > ol > li div.itm .exp, #web > ol > li div.algo, #web > ol > li, section.algo');
break;
case 'kagi':
searchResultContainer = searchResult.closest('div.search-result, div.__srgi');
break;
default:
}
@ -733,6 +739,23 @@ function main(mutations = null, observer = null) {
}
}, { once: true });
}
} else if (currentURL.hostname.includes('kagi.com')) {
// Function to filter search results in Kagi
function filterKagi() {
let searchResults = document.querySelectorAll('h3>a[href*=".fandom.com"], h3>a[href*=".wiki.fextralife.com"], h3>a[href*=".neoseeker.com/wiki/"]');
filterSearchResults(searchResults, 'kagi', storage);
}
// Wait for document to be interactive/complete:
if (['interactive', 'complete'].includes(document.readyState)) {
filterKagi();
} else {
document.addEventListener('readystatechange', e => {
if (['interactive', 'complete'].includes(document.readyState)) {
filterKagi();
}
}, { once: true });
}
}
}
});