How to create a Safari addon?
I want some personally developed JavaScript to execute whenever I load a page in Safari. It looks like addblock for Safari does it. Does anyone know how to do this?
Safari is not expandable. There is no addon framework for this. But there are still adblock and other addons available for it, although the developers of Apple Webkit and Safari discourage users from using them, calling them "binary hacks". It looks like some of these addons use InputManager which is not documented anywhere, at least not for the way people use it to load scripts in Safari. I guess I'll have to reverse engineer to see how addblock does this, but before I do that I thought I'd ask here. Somebody knows?
a source to share
Input managers are a commonly (ab) used way to inject arbitrary code at other times of application execution. Once there, you must redesign enough of the application itself to figure out how to get the behavior you want; this usually involves a swizzling method to replace parts of the application you are breaking into. This is not documented because there is no API to document it, but you can learn about the individual parts (how to write an input dispatcher in general, how the swizzling method works in Objective C, how to use tools like class-dump) and then put the whole thing together.
What you describe is similar to Greasemonkey, although there are at least one or two hacks that already exist to enable the Greasemonkey behavior in Safari. I would suggest to see if any of them meet your needs first.
a source to share