Implementing search filtering on Yandex
parent
27f66f17c0
commit
dff009d2ff
|
@ -37,7 +37,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, and Qwant 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, and Yandex 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.
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
"https://*.duckduckgo.com/*",
|
||||
"https://*.ecosia.org/*",
|
||||
"https://*.qwant.com/*",
|
||||
"https://*.yandex.com/*",
|
||||
"https://*.startpage.com/*",
|
||||
"https://*.search.yahoo.com/*",
|
||||
"https://www.google.com/search*",
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
"https://*.duckduckgo.com/*",
|
||||
"https://*.ecosia.org/*",
|
||||
"https://*.qwant.com/*",
|
||||
"https://*.yandex.com/*",
|
||||
"https://*.startpage.com/*",
|
||||
"https://*.search.yahoo.com/*",
|
||||
"https://www.google.com/search*",
|
||||
|
|
|
@ -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, and Qwant can also be filtered,
|
||||
Search results in Google, Bing, DuckDuckGo, Yahoo, Brave Search, Ecosia, Startpage, Qwant, and Yandex 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.
|
||||
|
|
|
@ -113,9 +113,10 @@ async function commonFunctionFindMatchingSite(site, crossLanguageSetting) {
|
|||
if (crossLanguageSetting === 'on') {
|
||||
matchingSites = sites.filter(el => site.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url));
|
||||
} else {
|
||||
matchingSites = sites.filter(el =>
|
||||
site.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url + el.origin_content_path)
|
||||
|| site.replace(/.*https?:\/\//, '') === el.origin_base_url
|
||||
matchingSites = sites.filter(el => {
|
||||
return site.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url + el.origin_content_path)
|
||||
|| site.replace(/.*https?:\/\//, '').replace(/\/$/, '') === el.origin_base_url
|
||||
}
|
||||
);
|
||||
}
|
||||
if (matchingSites.length > 0) {
|
||||
|
|
|
@ -18,14 +18,14 @@ function base64Decode(text) {
|
|||
// Function to create an observer to watch for mutations on search pages
|
||||
// This is used for search engines that paginate via JavaScript,
|
||||
// or overwrite their results and remove IWB's elements
|
||||
function addLocationObserver(callback) {
|
||||
function addDOMChangeObserver(callback) {
|
||||
const config = {
|
||||
attributes: false,
|
||||
childList: true,
|
||||
subtree: true
|
||||
}
|
||||
const observer = new MutationObserver(callback);
|
||||
observer.observe(document.body, config);
|
||||
const domObserver = new MutationObserver(callback);
|
||||
domObserver.observe(document.body, config);
|
||||
}
|
||||
|
||||
function insertCSS() {
|
||||
|
@ -322,6 +322,10 @@ function hideSearchResults(searchResultContainer, searchEngine, site, showBanner
|
|||
case 'startpage':
|
||||
document.querySelector('#main').prepend(searchRemovalNotice);
|
||||
break;
|
||||
case 'yandex':
|
||||
var searchResultsContainer = document.querySelector('#search-result') || document.querySelector('.main__content .content');
|
||||
searchResultsContainer?.prepend(searchRemovalNotice);
|
||||
break;
|
||||
case 'yahoo':
|
||||
if (document.querySelector('#web > ol')) {
|
||||
var li = document.createElement('li');
|
||||
|
@ -475,6 +479,9 @@ async function filterSearchResults(searchResults, searchEngine, storage) {
|
|||
case 'startpage':
|
||||
searchResultContainer = searchResult.closest('div.w-gl__result');
|
||||
break;
|
||||
case 'yandex':
|
||||
searchResultContainer = searchResult.closest('.serp-item');
|
||||
break;
|
||||
case 'yahoo':
|
||||
searchResultContainer = searchResult.closest('#web > ol > li div.itm .exp, #web > ol > li div.algo, #web > ol > li, section.algo');
|
||||
break;
|
||||
|
@ -497,7 +504,7 @@ async function filterSearchResults(searchResults, searchEngine, storage) {
|
|||
};
|
||||
|
||||
// Add location observer to check for additional mutations
|
||||
addLocationObserver(main);
|
||||
addDOMChangeObserver(main);
|
||||
|
||||
// If any results were filtered, update search filter count
|
||||
if (countFiltered > 0) {
|
||||
|
@ -666,6 +673,26 @@ function main(mutations = null, observer = null) {
|
|||
}
|
||||
}, { once: true });
|
||||
}
|
||||
} else if (currentURL.hostname.includes('yandex.com')) {
|
||||
// Function to filter search results in Yandex
|
||||
function filterYandex() {
|
||||
let searchResults = Array.from(document.querySelectorAll('.serp-item a.link, .serp-item a.Link')).filter(el =>
|
||||
el.href?.includes('.fandom.com') ||
|
||||
el.href?.includes('.wiki.fextralife.com') ||
|
||||
el.href?.includes('.neoseeker.com/wiki/'));
|
||||
filterSearchResults(searchResults, 'yandex', storage);
|
||||
}
|
||||
|
||||
// Wait for document to be interactive/complete:
|
||||
if (['interactive', 'complete'].includes(document.readyState)) {
|
||||
filterYandex();
|
||||
} else {
|
||||
document.addEventListener('readystatechange', e => {
|
||||
if (['interactive', 'complete'].includes(document.readyState)) {
|
||||
filterYandex();
|
||||
}
|
||||
}, { once: true });
|
||||
}
|
||||
} else if (currentURL.hostname.includes('yahoo.com')) {
|
||||
// Function to filter search results in Yahoo
|
||||
function filterYahoo() {
|
||||
|
|
Loading…
Reference in New Issue