Search code examples
http-redirecttabsoperaopera-extension

How to make a tab redirect in the Opera extension?


I'm new to Opera extension development.

I need to create an extension which will filter some special URL's and then redirect the user to another url in the same tab. I didn't find Opera API to intercept requests or catch the event of tab loading.

For example, when the user opening the url http://example.com/special I need to redirect him to http://foo.com in the same tab. If possible, even before the browser will send the request to example.com.

Can you advice some methods?

Opera 12.10


Solution

  • The code will need to go in the injected script. You can perform the redirection by assigning the new URL to location.href, e.g.:

    location.href = "http://foo.com"