Extract the code from any Safari Extension
If you have been using any of the new Safari Extensions you might want to peek inside them to see how they work. Fortunately this is really easy because .safariextz files are just xar archives that can be extracted using the Terminal. Here's how you do it.
Start by downloading the Safari extension. It should come in the form of a file with a .safariextz extension. If you wanted to install the extension to use it in Safari you would just double-click it, but don't do that now as the file will disappear from your Downloads folder.
Instead open Terminal, located in the Utilities folder inside the Applications folder. In the window that appears, type the following line and then press return.
This should be the path to the folder where the .safariextz file is located. You will need to change this if you have saved the extension somewhere else. For example you might use
cd ~/Desktop/Extensions or
If you are new to using the Terminal, note that starting with
~/ is a shortcut to inside your user folder, and starting with
/ is for inside your hard drive. The
cd command is for changing directory, i.e. 'moving' to a folder.
Next paste in the following line and press return.
xar -xf 'TheExtensionName.safariextz'
You need to replace TheExtensionName with the filename of the extension. The quotes around the filename are only really important if it contains spaces. If you want to avoid typing in the name, you can just drag the file into the Terminal window from the Finder and it will be entered for you.