After switching to OS X, I started using Safari as my main browser. Using the browser for several years, there were no problems with it. Here the truth of plug-ins to it is much less than to Chrome or Firefox, in this connection, the convenience of viewing certain sites in different browsers is very different.
So, as I’m just used to Safari and don’t want to switch to another browser, I decided that I could write all the plugins that don’t reach me. Plus, as it turned out, it is very simple.
Under the cut an example of creating a plug-in and publishing it in extensions.apple.com
Training
First you need to choose what you will develop. Due to the fact that I often listen to music from
Soundcloud , and the “jumping out” comments on the site annoy me a lot, I decided to write a plugin that will automatically turn off comments when playing.
What it looks like:
')
Comments included
Turn off comments
To develop a plugin, you need an Apple dev account. You can register it
here .
After that, you need to
get a certificate to sign your plugins. Problems when registering and obtaining a certificate should not arise, just follow the instructions on the site.
Development
After installing the developer certificate, you can begin to develop. First you need to activate the developer mode in Safari-> Settings-> Add-ons-> Put a tick "Show development menu"
Now open the menu item Development-> Extension builder in the menu and configure your plugin, after which we save it.
I wrote a plugin on js using jQuery. Details on the supported programming languages ​​and features of Safari browser plugins can be found
here .
In the folder where you saved the script, create a plugin.js file in it and the plugin code will be stored.
My code for examplefunction soundcloud() { $(document) .ready(function () { $(".player") .each(function () { $(this) .children() != undefined && $(this) .toggleClass("no-comments"); }) }) }; soundcloud();
In the Extension builder, select your script in the End Scripts item and click on Install.
Your plugin is created and installed in Safari.
Preparation for publication
Preparing for publication took me the most time. We need to do a lot of little things:
- Create icons with dimensions of 32x32, 48x48, 64x64, 100x100 pixels and put them in a folder with a plugin under the name Icon-32.png, and so on.
- Screenshot of the plugin with a size of 425x275 px.
- Write a short and long description of the plugin.
- Create a web page for the plugin. (For example, an entry in your blog where this plugin is described.)
- Create a plugin update manifest file (described below as)
- Download the plugin on the server to be able to download it for a direct link.
With the icons, the description and the page of the plug-in, I think everything is clear, as far as the manifest is concerned, it’s just an XML file that describes the current version of the plug-in.
Template of such file <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Extension Updates</key> <array> <dict> <key>CFBundleIdentifier</key> <string>com.yourCompany.safari.yourExtensionName</string> <key>Developer Identifier</key> <string>YourCertificateID</string> <key>CFBundleVersion</key> <string>Your current bundle version</string> <key>CFBundleShortVersionString</key> <string>Your current display version</string> <key>URL</key> <string>Your-.safariextz-URL</string> </dict> </array> </dict> </plist>
An example of my file <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Extension Updates</key> <array> <dict> <key>CFBundleIdentifier</key> <string>com.bukashk0zzz.safari.soundcloudcommenthider</string> <key>Developer Identifier</key> <string>123456ABCD</string> <key>CFBundleVersion</key> <string>1</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>URL</key> <string>http://mysimple.name/wd/Soundcloud_Comment_Hider.safariextz</string> </dict> </array> </dict> </plist>
Safari Developer is the number of your DEV account in Apple. It can be found in the Extension builder in the upper right corner.
Also, before publishing, do not forget on your web server to add to MIME the type .safariextz
Apache example:
AddType application / octet-stream .safariextz
Publication
If you have prepared everything, you can safely
open and send your creation to Apple for consideration.
I published the plugin the second time, at first it did not work, since I did not add icons to the plugin. Apple had both the first and the second 7 days pending review plugin. I liked that they give a clear answer why the plugin is not published, since it is clear what needs to be fixed.
This plugin is published in the Entertainment section titled Soundcloud Comment Hider.
The source code of the plugin and the rest is available on
github .
Link to download the plugin.