I have recently been annoyed with the amount of aggregation sites that keep popping up in Google Search results. They offer (to me) nothing useful and obscure the valuable sites. Unfortunately, Google removed their offering to ignore/skip sites in results a while ago. I am starting to work on a Chrome extension to filter these out of search results, and ran into a big of a snag.
The first thing I tried was the webRequest.onBeforeRequest, but ran into issues with differences in Manifest v3. I realized that what I am going for might not be possible, and thought I would check.
The only thing I want to be able to do is modify Google Search requests to include a list of excluded sites, using the -site:<url> syntax that Google supports. For example, a search for "yargs vs commander" might become "yargs vs commander -site:npmtrends.com", assuming the user had set npmtrends.com in the blacklist.
However, I am not sure whether this is possible with Chrome extensions? If it is, will the resulting search display also include the -site:npmtrends.com (ie. in browser bar)? If so, could I simply filter it out again at that point (as it will be added again for future requests)?
I have been using declarativeNetRequest API work (Manifest v3), coupled with a redirect rule. However, while a regexFilter like [?&]q=[^&#]+ and regexSubstitution like \\0+-site%3Anpmtrends.com does work, it also results in an infinite redirection loop (since condition is always true). Google's regex syntax does not seem to support lookbehinds/lookaheads, significantly limiting possibilities.
It is quite frustrating that Manifest v3 seems to be a step backward in power regarding URL requests, as this would be easy if using JS (since it requires several checks over the whole string)...
Welcoming any feedback/recommendations!
EDIT: Apparently I forgot (to my shame) to include examples/link to my attempts...my apologies! I am unable to update with examples at the moment, but do have a GitHub link (for the little value that contains).