0

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

Andrew
  • 3,696
  • 3
  • 40
  • 71

2 Answers2

0

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"
alpenglow
  • 88
  • 3
  • I'm not sure exactly what you want to do, but you can get information about the tab URL through the background process: http://dev.opera.com/articles/view/extensions-api-tab-url/ I'm not sure how much control you can have over the main web page from the background process, though. If you are wanting to block certain URLs, then you may want to use the URL Filter API: http://dev.opera.com/articles/view/site-blocking-with-operas-url-filter-api/ – alpenglow Nov 14 '12 at 19:48
0

I believe that the behavior you're seeking is handled server side. If you're the admin of the page you wish a redirect, you'd need to look into URL forwarding, either via your own server or your domain manager. Expanding on alpenglow's answer, the MDN docs show you how to update the URL of a tab. Opera natively supports said methods.

POWRFULCOW89
  • 36
  • 1
  • 6