Bookmarks

Initialising and querying the bookmark service

The first step to interacting with bookmarks is to get a reference to the bookmark service/manager. The steps below all base themselves off this code here:

// Get the service pane first, and initialise it 
var SPS = Components.classes['@songbirdnest.com/servicepane/service;1']
  .getService(Components.interfaces.sbIServicePaneService); 
SPS.init(); 

// Now get the bookmark service 
var BMS = Components.classes['@songbirdnest.com/servicepane/bookmarks;1']
  .getService(Components.interfaces.sbIBookmarks);

Creating a folder

var bookmarkNode = BMS.addFolder("My Bookmarks");

Adding bookmarks to a folder

var node = BMS.addBookmarkAt("http://songbirdnest.com", "Songbird Homepage", null,
    bookmarkNode, null);

Removing bookmarks

Let's say you wanted to remove the Birdhouse link from the Service Pane, you can accomplish this by doing:

// Try to find the Birdhouse node in the service pane, and remove it
var birdhouse = SPS.getNode("http://birdhouse.songbirdnest.com/");
if (birdhouse)
    SPS.removeNode(birdhouse);
Tag page
You must login to post a comment.