Adjust query for non-standard search results / Fix

For identifying non-standard search results, "div[jsname]" is unreliable as Google does seem to add it to some standard search results. Replacing with checks for attributes that are more specific to Q&A dropdowns + cards.
pull/672/head
Kevin Payravi 2024-05-03 02:38:39 +03:00
parent 05f36d495d
commit 623eb2d149
1 changed files with 2 additions and 2 deletions

View File

@ -586,7 +586,7 @@ async function reorderSearchResults(searchResults, searchEngine, storage) {
for (const searchResult of resultsToSort) {
try {
await reorderDestinationSearchResult(resultsFirstChild, searchResult);
reorderedHrefs.push(searchResultLink);
reorderedHrefs.push(searchResult.href);
} catch (e) {
console.log('Indie Wiki Buddy failed to properly re-order search results with error: ' + e);
}
@ -673,7 +673,7 @@ function startFiltering(searchEngine, storage, mutations = null, observer = null
let searchResults = document.querySelectorAll("div[data-hveid] a:first-of-type:not([role='button']):not([target='_self'])");
// Remove any matches that are not "standard" search results - this could've been done with :has() but limited browser support right now
searchResults = Array.from(searchResults).filter((e) => !e.closest('g-section-with-header, div[jsname]'));
searchResults = Array.from(searchResults).filter((e) => !e.closest('g-section-with-header, div[aria-expanded], div[data-q], div[data-minw], div[data-num-cols]'));
return await reorderSearchResults(searchResults, 'google', storage);
}