sophie-glk / bang

A firefox addon which adds bangs (known from duckduckgo) to various search engines.
MIT License
47 stars 5 forks source link

Bad interception of requests in address bar #4

Closed babastienne closed 5 years ago

babastienne commented 5 years ago

Context :

I'm doing a research in the address bar of firefox. Example : !g foo bar My default search engine is ecosia.

Expected behaviour :

The research is intercepted by the extension and the request is changed to search on google. The page displayed is the results of google.

Behaviour :

The request is not intercepted immediately. There is a first request made on ecosia instead of google. The ecosia result is displayed : image Only after it is displayed the new request is made on google and the page is changing again to display the google results : image

Problem : This multiply the requests made and create a small amount of time where firefox can't be used to do anything else. Because if I do my research and then promptly change to a second tab then the first tab will display the ecosia research and the google results will be displayed in the second tab.

I thought that the webRequest.onBeforeRequest would be able to intercept the initial request but when looking at your code you already used it so I'm not sure of how to solve this issue, otherwise I would have done a pull request. Not sure if the description is complete enough to understand the problem. Don't hesitate to ask for more informations in case of need.

sophie-glk commented 5 years ago

Your thought about webRequest.onBeforeRequest was correct. The issue was that I completely forgot that it even existed in my code (background.js). Therefore the feature wasn't updated in like forever and in addition it wasn't implemented that well. I fixed it by basically rewriting background.js, which should make the recognition from the url bar much faster. (A consequence of this is that the custom search engine feature is now completely useless and has therefore been removed). It would be great if you could test it. (Oh and i followed your advice and created a development branch)

babastienne commented 5 years ago

I just looked at your modifications. It's working very well now, congratulations on your work (and for your reactivity). In my opinion the issue is now solved.

However, some bugs has been introduced when you made your last modifications :

If I had more time I would have done a pull request but I'm kind of busy so sorry for this quick answer.

sophie-glk commented 5 years ago

Yeah, i deleted the wrong line by accident. The bug should be fixed now.

babastienne commented 5 years ago

Ok I did a test again, it seems to be working fine now.