Re: Safari bookmarks - adding
Re: Safari bookmarks - adding
- Subject: Re: Safari bookmarks - adding
- From: "Gary (Lists)" <email@hidden>
- Date: Sun, 07 Aug 2005 01:05:19 -0400
"Jake Hickok" wrote:
> Trying to add a bookmark to Safari (and/or Firefox) without replacing
> the entire file. Is there an applescript command to do this
Alright, Jake. A Safari bookmark-adding-script is complete. (See below.)
It's not a command, it's a real jungle adventure.
Regarding FireFox...
Clearly you did not start by opening the Firefox application's scripting
dictionary. ;) It's pointless anyway, right?
If you do, you will find exactly 4 commands; 2 of which are mysterious
layovers from the very early web. The remaining 2 are practically aliases of
one another.
As I see it, FireFox has one basic AppleScriptable "action" ... open a URL.
Big deal, eh? Why they didn't rip the Mozilla 1.2.1 dictionary is beyond
me. (Meaning, it probably wasn't technically feasible and the discussion of
those particulars would be beyond me.)
Perhaps with FF's reorganization we will see a more robust AS dictionary
re-appear in an OSX Mozilla.
> or is the only way to dig through the xml and insert something there?
The FireFox bookmark file is not XML. It is, like other Mozillas and like
IE, a Netscape Bookmark File -- which another way to say "sloppy HTML 3.0".
<!DOCTYPE NETSCAPE-Bookmark-file-1>
But, it's easy to add a bookmark to that file, with plain-Jane applescript.
You won't be able to place the bookmark very specifically without lots of
HTML parsing -- I used to just stick them at the end of the list, when I
used IE and when I wrote bookmarks via AppleScript.
If you open such a file, you'll see <DT> and <DD> tags which are the
bookmarks. You can copy the structure to the very end of the file, before
the </body> tag, and you're cooking with gas.
For Safari's Plist-style file...
As for adding a bookmark to Safari, you can try out my new 'Add Safari
Bookmark' script. This script _requires_ XMLLib.osax (free) from Satimage
(the makers of Smile.)
It works quite well in all of my tests.
I used version 2.7, which comes with Smile. Their website only has version
2.0 available, and I did not test the script with version 2.0 of the osax.
You can see if it works, or you can download the free version of Smile --
you can use the scripting addition even if you don't use Smile (but it's so
cool, why not use it? ;)
The script, 'Add Safari Bookmark', will allow you to _add_ (not remove)
bookmarks to Safari even without launching (or ever using) Safari.
You choose the bookmarks folder to which you'd like to add the new bookmark,
then you are asked for the URL and a title. The bookmark is then added. If
Safari is running, the update is automatic -- you'll immediately have access
to the bookmark. If it's not, the bookmark will be present when you launch
Safari (or import into some other bookmark manager...it's now in the
bookmarks file.)
The 'Collections' folder is the content of what displays when you click the
small 'open book' icon on Safari's bookmark bar, or when you choose 'Show
All Bookmarks' from the menu. It's all the stuff in the left-side pane.
'Collections' contains the folders you've defined, as well as some regulars
(always at the top). One of these regulars is the 'Bookmarks Bar' folder --
choose that one to place the new URL you are adding onto the button bar.
Another is 'Bookmarks Menu' -- choose that folder to insert the new bookmark
into the pull-down 'Bookmarks' menu in Safari. Otherwise, put it where
you'd like. (You can not put new bookmarks into sub-folders. I didn't
write that feature.)
I wrote this script in response to your question here, and to apply the
testing I've been doing with XMLLib for another project. I don't regularly
use Safari myself (but I do like it...and it's fast.)
You can download the script from here:
<http://orgdork.org/safari/AddSafariBookmark.html>
There is a download link provided for the XMLLib.osax, so you'll need to
grab that and install before using the script.
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden