Firefoxの拡張機能でブックマークされたURLを取得する方法。
function getBookmark() { hbm = new Array(); // The RDF service var rdf = Components.classes['@mozilla.org/rdf/rdf-service;1'] .getService(Components.interfaces.nsIRDFService); // The RDF component utilities var rdfc = Components.classes['@mozilla.org/rdf/container-utils;1'] .getService(Components.interfaces.nsIRDFContainerUtils); // The bookmarks service var Bookmarks = Components.classes['@mozilla.org/browser/bookmarks-service;1'] .getService(Components.interfaces.nsIRDFDataSource); var kNC_BookmarksRoot = rdf.GetResource("NC:BookmarksRoot"); var kNC_Name = rdf.GetResource("http://home.netscape.com/NC-rdf#Name"); var kNC_URL = rdf.GetResource("http://home.netscape.com/NC-rdf#URL"); function getBookmarkRecursively(node) { if (rdfc.IsContainer(Bookmarks, node)) { // folder var folder = Bookmarks.GetTarget(node, kNC_Name, true); var name = folder.QueryInterface(Components.interfaces.nsIRDFLiteral).Value; var container = Components.classes['@mozilla.org/rdf/container;1'] .createInstance(Components.interfaces.nsIRDFContainer); container.Init(Bookmarks, node); var contents = container.GetElements(); while (contents.hasMoreElements()) { var next = contents.getNext() .QueryInterface(Components.interfaces.nsIRDFResource); getBookmarkRecursively(next); } } else { // bookmark try { var bm = Bookmarks.GetTarget(node, kNC_URL, true); var url = bm.QueryInterface(Components.interfaces.nsIRDFLiteral).Value hbm[url] = true; } catch (ex) { } } } getBookmarkRecursively(kNC_BookmarksRoot); return hbm; }