Apply parentNode to all Google search results

Need to apply to all for consistency between the three interactions (hiding / replacing / re-ordering)
pull/765/head
Kevin Payravi 2024-07-23 16:25:53 -07:00
parent b1a3110c70
commit fb202486dc
1 changed files with 2 additions and 5 deletions

View File

@ -272,7 +272,8 @@ function getSearchContainer(searchEngine, searchResult) {
case 'google':
const closestJsController = searchResult.closest('div[jscontroller]');
const closestDataDiv = searchResult.closest('div[data-hveid].g') || searchResult.closest('div[data-hveid]');
searchResultContainer = findClosestElement(searchResult, [closestJsController, closestDataDiv]);
// For Google search results, get the parentNode of the result container as that tends to be more reliable:
searchResultContainer = findClosestElement(searchResult, [closestJsController, closestDataDiv]).parentNode;
break;
case 'bing':
searchResultContainer = searchResult.closest('li.b_algo');
@ -344,14 +345,10 @@ async function filterSearchResult(matchingSite, searchResult, searchEngine, coun
countFiltered += hideSearchResults(searchResultContainer, searchEngine, matchingSite, 'off');
console.debug(`Indie Wiki Buddy has hidden a result matching ${searchResultLink} because we re-ordered an indie wiki result with a matching article`);
} else if (searchFilterSetting !== 'disabled') {
// For Google search results, get the parentNode of the result container as that tends to be more reliable:
if (searchFilterSetting === 'hide') {
// Else, if the user has the preference set to hide search results, hide it indiscriminately
countFiltered += hideSearchResults(searchResultContainer, searchEngine, matchingSite, storage['hiddenResultsBanner']);
} else {
if (searchEngine == 'google') {
searchResultContainer = searchResultContainer.parentNode;
}
countFiltered += replaceSearchResults(searchResultContainer, matchingSite, searchResultLink);
}
}