KevinPayravi / indie-wiki-buddy

Browser extension that automatically notifies and redirects you to independent wikis.
https://getindie.wiki
MIT License
254 stars 70 forks source link

Filtering search results on Startpage.com is broken #733

Open DrWhoFan13 opened 2 months ago

DrWhoFan13 commented 2 months ago

Self-explanatory, "replace non-indie results" and "hide non-indie results" does not work past the first page of search results on Startpage.com. Furthermore, if I were to go back to the first page using the numbered buttons if I am not already on it, then it won't work either.

First page of Startpage results for Tardis Fandom wiki via "replace": Screenshot 2024-06-25 194912

Second page of Startpage results for Tardis Fandom wiki via "replace": Screenshot 2024-06-25 194923

DrWhoFan13 commented 2 months ago

Update: Turns out I didn't have Startpage filtering enabled on my phone.

The problem of Startpage filtering not working past the first page of search results now apply to mobile as well.

The problem's exactly the same on desktop (Doesn't work past the first page if I use the number buttons)

SnorlaxMonster commented 2 months ago

I cannot reproduce this in multiple ways.

Firstly, searching "tardis fandom wiki" on Startpage.com only gives me a single page of results, so I can't reproduce the example you were having the issue with. I tried turning Safe Search off in case results were being hidden, but it didn't make a difference.

Searching "doctor who wiki" does give me multiple pages of results. The first page reports there are 5 pages of results, but in actuality there are only 3 (clicking 4 or 5 gives an error page). On the second page of results, there's a Doctor Who Neoseeker wiki link that IWB successfully replaces with a link to the independent wiki. Navigating back to the first page, the results are still replaced.

I get the same behaviour on both Firefox and Chromium on desktop, as well as Firefox on Android.

DrWhoFan13 commented 2 months ago

I cannot reproduce this in multiple ways.

Firstly, searching "tardis fandom wiki" on Startpage.com only gives me a single page of results, so I can't reproduce the example you were having the issue with. I tried turning Safe Search off in case results were being hidden, but it didn't make a difference.

Searching "doctor who wiki" does give me multiple pages of results. The first page reports there are 5 pages of results, but in actuality there are only 3 (clicking 4 or 5 gives an error page). On the second page of results, there's a Doctor Who Neoseeker wiki link that IWB successfully replaces with a link to the independent wiki. Navigating back to the first page, the results are still replaced.

I get the same behaviour on both Firefox and Chromium on desktop, as well as Firefox on Android.

I've done the same search once a day these past few days to see if I can replicate it, but no such luck outside of one time on Firefox Android after toggling Startpage.com.

I assume it is some sort of “adjusting to Startpage” issue, but I'm uncertain of it.

I've replicated it on Firefox Android, apparently if you were to stop the page from page two onwards loading after the results appear, it stops IWB from replacing the results even if you reload the page or go to page three+.

SnorlaxMonster commented 2 months ago

if you were to stop the page from page two onwards loading after the results appear, it stops IWB from replacing the results even if you reload the page or go to page three+.

Can you clarify what you mean by this? Are you saying that if you cancel a page load (e.g. by pressing the X button in your browser) while navigating on Startpage.com, IWB won't be able to replace search results? While I can reproduce the behaviour of IWB not replacing results if you cancel a page load prematurely, I don't see that as a bug. To me, that sounds like an expected consequence of cancelling a page load before it's complete (that's what cancelling a page load is supposed to do).

However, I cannot reproduce the behaviour of navigating to other pages after cancelling a page load causing IWB not to replace results. Even if I do successfully prevent IWB from replacing results on one particular page by cancelling a page load prematurely, when I navigate to other pages it still replaces results.

DrWhoFan13 commented 2 months ago

Are you saying that if you cancel a page load (e.g. by pressing the X button in your browser) while navigating on Startpage.com, IWB won't be able to replace search results?

More or less, but on all pages of search results; even if it's not the same page as the one I cancelled the search load on. For obvious reasons, it's easier to replicate on Firefox for Android than on Desktop.

However, I cannot reproduce the behaviour of navigating to other pages after cancelling a page load causing IWB not to replace results. Even if I do successfully prevent IWB from replacing results on one particular page by cancelling a page load prematurely, when I navigate to other pages it still replaces results.

I've just managed to replicate the "won't replace on other pages if cancelled on one page" error, curiously enough; though it seemed to fix itself later. Not sure how, outside of cancelling the load at the right time.

KevinPayravi commented 1 month ago

I haven't been able to replicate this exact pagination-related bug, but experienced a similar bug: When doing searches on Startpage with "hide non-indie results" enabled, non-indie results would remain visible upon loading search results.

I believe the issue was a race condition. Startpage does a lot of DOM rewriting, which IWB detects via a MutationObserver and reruns whenever the DOM changes. Previously, this MutationObserver was being added after IWB did its initial run on a search engine result page. I believe that the bug is that, in between IWB's initial filtering and adding the MutationObserver, Startpage would rewrite the DOM and IWB would miss that rewrite. With commit https://github.com/KevinPayravi/indie-wiki-buddy/commit/2221d98dc96bc75766a1e19894c8ea85842098f5, the MutationObserver instantiation occurs before search filtering takes place, preventing this race condition. The downside is that IWB's own insertions are detected as mutations, which will result in a few more loops of the DOM (but there are already dozens of mutations happening across these search engines so not a major concern).

I'm not sure if the above fixes the issue described in OP, but it may!

KevinPayravi commented 2 weeks ago

Issues with Startpage may have also be resolved as part of the rework in PR https://github.com/KevinPayravi/indie-wiki-buddy/pull/776