Only run re-ordering when wiki not disabled

pull/659/head
Kevin Payravi 2024-04-27 20:07:30 -04:00
parent 3f87018ac8
commit d7fcc1d172
1 changed files with 12 additions and 9 deletions

View File

@ -560,6 +560,8 @@ async function reorderSearchResults(searchResults, searchEngine, storage) {
// Handle re-ordering of results to move destination results up the page
let matchingDest = await commonFunctionFindMatchingSite(searchResultLink, crossLanguageSetting, true);
if (matchingDest) {
let searchEngineSettings = await commonFunctionDecompressJSON(storage.searchEngineSettings || {});
if (searchEngineSettings[matchingDest.id] !== 'disabled') {
if (resultsFirstChild.contains(searchResult)) {
// If this search result is inside the first child of the results container (aka, it's the first result),
// and there is a matchingDest at this point, then an indie wiki is #1 on the search results page.
@ -571,6 +573,7 @@ async function reorderSearchResults(searchResults, searchEngine, storage) {
reorderedHrefs.push(searchResultLink);
}
}
}
} catch (e) {
console.log('Indie Wiki Buddy failed to properly re-order search results with error: ' + e);
}