Open HatScripts opened 6 years ago
Weird, it seems to work for me on Chrome, Firefox and Opera (although opera annoyingly hides the querystring part of the url by default).
This is truly bizarre. I just tested it and it worked when the domain was google.com
, google.co.uk
, google.com.br
, etc., but not google.com.au
. It can't be an issue with the regex pattern, because otherwise the Example URL wouldn't match, right?
Could it somehow be because google.com.au
is my default search engine in the Opera settings?
opera://settings/searchEngines
It's possible that there's some kind of special case where they don't pass that url through the redirection api. Does it matter whether you search from the address bar or from the actual google.com.au page?
Does it matter whether you search from the address bar or from the actual google.com.au page?
No, it doesn't work no matter what I try:
Even with all these turned on:
And even when I change my default search engine, e.g.
Actually, I just tested it, and it appears that attempting to redirect any URL that is found within those 6 "Default search engines" fails. None of the following simple wildcard redirects will work for me. I was mistaken when I said it's an issue specific to regex redirects.
Description: | Google - wildcard example |
Example URL: | https://www.google.com.au/search?client=opera&q=test&sourceid=opera&ie=UTF-8&oe=UTF-8 |
Include pattern: | https://www.google.com.au/* |
Redirect to: | https://www.google.com.au/ |
Pattern type: | Wildcard Regular Expression |
Example result: | https |
Description: | DuckDuckGo - wildcard example |
Example URL: | https://duckduckgo.com/?q=test&t=opera&ia=web |
Include pattern: | https://duckduckgo.com/* |
Redirect to: | https://duckduckgo.com/ |
Pattern type: | Wildcard Regular Expression |
Example result: | https |
Description: | Wikipedia - wildcard example |
Example URL: | https://en.wikipedia.org/wiki/Special:Search?search=test |
Include pattern: | https://en.wikipedia.org/wiki/Special:Search* |
Redirect to: | https://en.wikipedia.org/wiki/Main_Page |
Pattern type: | Wildcard Regular Expression |
Example result: | https |
These URLs do correctly redirect to the Wikipedia main page:
https://en.wikipedia.org/
https://en.wikipedia.org/wiki/
https://en.wikipedia.org/wiki/Article
https://en.wikipedia.org/w/index.php?search=blahblah&title=Special:Search
https://en.wikipedia.org/wiki/Special:Search
https://en.wikipedia.org/wiki/Special:Search?search=
But these fail:
https://en.wikipedia.org/wiki/Special:Search?search=whydoesnthisredirect
https://en.wikipedia.org/wiki/Special:Search?search=whydoesnthisredirect&searchToken=4ofgo4idb0tyrnq0sp5vx5jgs
https://en.wikipedia.org/wiki/Special:Search?search=asfgf&searchToken=bg1tp1vjwtk38lmiow0xlot7
It should be noted that by design, Special:Search takes you directly to the article if your query is a valid article name, so
https://en.wikipedia.org/wiki/Special:Search?search=code
->
https://en.wikipedia.org/wiki/Code
and thus Redirector will then redirect
https://en.wikipedia.org/wiki/Code
->
https://en.wikipedia.org/wiki/Main_Page
However, if your query is not a valid article, e.g.
https://en.wikipedia.org/wiki/Special:Search?search=xyx
it will show search results, and some search token gets appended to the URL:
https://en.wikipedia.org/wiki/Special:Search?search=xyx&searchToken=d55zqqne664ltwujujwrd01o9
Redirector then fails to redirect
https://en.wikipedia.org/wiki/Special:Search?search=xyx&searchToken=d55zqqne664ltwujujwrd01o9
->
https://en.wikipedia.org/wiki/Main_Page
Edit: Just tested in Chrome and everything works as expected so this definitely seems to be an Opera specific bug.
Ok, thanks for the info. Seems to be some issue around how Opera processes urls that are related to the search engines. I'll try to investigate it better when I have time :)
Maybe related SO question: webRequest.onBeforeRequest does not fire for certain URLs in Opera 48+ (no answers)
The situation is same at this time?
None of the following regex-based patterns for Google results are triggering a redirect:
Google - Simplify
https://www.google.com.au/search?client=opera&q=test&sourceid=opera&ie=UTF-8&oe=UTF-8
^(https?://www\.google(?:\.\w+)+/search).*?[?&](q=[^&#$]+).*$
$1?$2
https://www.google.com.au/search?q=test
Google - Hex colors (Expand shorthand hex colors)
https://www.google.com.au/search?client=opera&q=%23fff&sourceid=opera&ie=UTF-8&oe=UTF-8
^(https?://www\.google(?:\.\w+)+/search.*?[?&]q=%23)([a-f0-9])([a-f0-9])([a-f0-9])((?:&|#|$).*)$
$1$2$2$3$3$4$4$5
https://www.google.com.au/search?client=opera&q=%23ffffff&sourceid=opera&ie=UTF-8&oe=UTF-8
Google - Currency conversions (Remove '$' from start)
https://www.google.com.au/search?client=opera&q=%24100+aud+to+usd&sourceid=opera&ie=UTF-8&oe=UTF-8
^(https?://www\.google(?:\.\w+)+/search.*?[?&]q=)%24(.+)
$1$2
https://www.google.com.au/search?client=opera&q=100+aud+to+usd&sourceid=opera&ie=UTF-8&oe=UTF-8
However, simple wildcard-based patterns like the following do seem to work:
Google - wildcard example
https://www.google.com.au/search?client=opera&q=test&sourceid=opera&ie=UTF-8&oe=UTF-8
https://www.google.com/*
https://www.google.com/
https://www.google.com/
Edit: I'm using the Opera extension, v3.2.