

Safari 5 Extension Development - swannodette
http://developer.apple.com/safari/library/documentation/Tools/Conceptual/SafariExtensionGuide/Introduction/Introduction.html

======
sirn
Interesting, in the Messages and Proxies[1] page, Apple has ad-blocking as an
example which actually _blocks_ the ads from being loaded using the
`beforeload` event (as oppose to hide them after they're loaded):

> Safari 5.0 and later (and other Webkit-based browsers) generates a
> “beforeload” event before loading each sub-resource belonging to a webpage.
> The “beforeload” event is generated before loading every script, iframe,
> image, or stylesheet specified in the webpage, for example.

Isn't this exactly what the NoScript's author says Chrome extension was
lacking[2]?

[1]:
[http://developer.apple.com/safari/library/documentation/Tool...](http://developer.apple.com/safari/library/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html)

[2]: <http://hackademix.net/2009/12/10/why-chrome-has-no-noscript/>

~~~
ComputerGuru
Can I be honest and not be thought less of for it?

I actually like Chrome's "load then hide" version of AdBlock because the ad
impression counts. It doesn't do much for PPC ads, but for PPI, the website
owner has "made an impression" with the ad unit.

Of course, it's robbing the advertiser at the same time....

~~~
potatolicious
I'd rather it not count. AdBlock originated out of a deep annoyance/hatred for
distracting, exploitative ads - but has since grown to cover just about every
advertiser out there, good and bad.

Many people install AdBlock without seemingly realizing this difference. What
I would like to see a much more discerning ad-blocking solution that punishes
scammy, distracting, or otherwise abusive ads, and rewards advertisers that
create consumer-friendly ads.

With a load-then-hide system the website owner has fewer effective metrics on
whether or not people are actively blocking his ads. Perhaps when his
impressions start dropping precipitously he would be much more compelled to
act.

Of course, all of this hinges on the existence of a trusted adblock source
that takes upon itself great pains to maintain a list that bans only abusive
advertisers. I'm not holding my breath.

~~~
rythie
Me too, I'd like to see a block list that only blocked annoying ads. I
actually blogged about annoying advertising here:
[http://posterous.richardcunningham.co.uk/the-problem-with-
on...](http://posterous.richardcunningham.co.uk/the-problem-with-online-
advertising)

------
KirinDave
For those who want to see a naive extension in action, I did a quick version
of Helvetireader to the Safari extension format. It's trivial, but it also is
a good template for further injection projects:

[http://kirindave.tumblr.com/post/675464589/safari-5-port-
of-...](http://kirindave.tumblr.com/post/675464589/safari-5-port-of-
helvetireader)

My big question is: will these make it to the iPad version of Safari?

~~~
macrael
How does it work? I installed it but I can't find a way to activate it.

~~~
sirn
Enable Safari's developer menu. (Preferences → Advanced → Show developer menu)

Then enable extensions. (Develop → Enable Extensions)

~~~
macrael
I got that far, but I guess I don't know what the extent ion actually does.
How do i use it?

~~~
WiseWeasel
You then must find extensions to install. They can be downloaded from any
website, and installed by the browser. Here's one repository of Safari 5
extensions I was able to find:

<http://safariextensions.tumblr.com/>

------
Derferman
I wrote a really simple extension that injects jQuery into the current
webpage. Not very practical as the same features can be found in a
bookmarklet, but fun to make nonetheless.

<http://conroy.posterous.com/jqueried-a-safari-5-extension>

------
tzs
Before this, how did third parties add functionality to Safari? For instance,
the button 1Passwoed puts in the toolbar and the item it adds to the context
menu for form fields?

~~~
sirn
Using InputManager[1] or SIMBL[2]. There are several things Safari Extension
is not capable of due to lack of API (anything not involving webpage data) so
InputManager/SIMBL-plugins are still necessary.

[1]: <http://www.cocoadev.com/index.pl?InputManager>

[2]: <http://culater.net/software/SIMBL/SIMBL.php>

------
icefox
It would be nice if you could listen for events, specifically I want to know
when a tab is closed so I can add a action to re-open the last closed tab.

------
vladocar
Are all Safari 5 Extension will be free?

~~~
WiseWeasel
They're just packages that you download and install, so they could feasibly be
charged for. I'm pretty sure it's impossible to hide the source code, however,
so a copy would emerge almost immediately if you tried to make a market for
yourself. So yes, effectively all Safari 5 extensions will be free.

------
OoTheNigerian
I am no coder so pardon my naive question.

Is it possible for chrome and safari extensions to be interoperable,
especially as they both have the same underlying web-kit technology? Surely,
we do not want another platform fragmentation and battle. I am sure developers
would love do no more work than recompiling the extension they built for
Chrome. It will be a win for everyone.

~~~
lenni
There is no technical reason why this couldn't work, but my guess is that
abstraction libraries will be necessary because Apple and Google won't be able
to a agree on a common API. I kinda agree because having to standardise HTML,
CSS and JS is hard enough and the browser makers don't wanna open up another
battle front. Also, being able to tailor the API tightly to the underlying
browser will attract developers and therefore enable more competition.

Good times for add-on developers!

~~~
Kilimanjaro
In the same vein of commonJS, they should get together and create commonXT

