8

I am currently writing my first extension for Safari 5. I can't find a reference on what events an extension can react.

I want my extension to react on these events:

  • when a new tab is created.
  • when a new browser window is created.
  • when the URL inside a tab changes.

Is this possible?

Richard Slater
  • 6,313
  • 4
  • 53
  • 81
Norwald
  • 81
  • 1

3 Answers3

3

Yes. Create an Injected Script and add it as an End Script. Set the Access Level of Extension Website Access in the builder to All. Your Injected End Script will be called for every page that loads in Safari, which covers all of the cases you mentioned.

Alan Gutierrez
  • 15,339
  • 1
  • 18
  • 17
2

Yes, as of version 5.1

From the Safari documentation:

In Safari 5.1 and later, you can listen for and respond to the following window and tab events:

Open—Safari sends an "open" event to a window or tab when it is first opened.

...

Navigate—Safari sends a "navigate" event to a tab when the main frame of the new URL has loaded.

Community
  • 1
  • 1
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
1

Here is the reference: The Windows and Tabs API

Edit: Hmm... it seems it only documents how to do some actions, not how to listen to events :-/

Arnaud Leymet
  • 5,995
  • 4
  • 35
  • 51