firefox-bookmarks v0.6.0
firefox-bookmarks 
Extract information from your Firefox bookmarks
This was built as part of the bookmarks project, GitHub hosted websites for searching through other people's bookmarks.
Getting Started
Install the module with: npm install firefox-bookmarks
// Load in raw bookmarks from Firefox backups
var rawBookmarks = require('~/.mozilla/firefox/profile-id/bookmarkbackups/bookmarks-YYYY-MM-DD.json');
/*
{
"title": "",
"id": 1,
"dateAdded": 1364532555307821,
"lastModified": 1364627167084723,
"type": "text/x-moz-place-container",
"root": "placesRoot",
"children": [
...
*/
// Simplify and parse raw bookmarks
var BookmarkCollection = require('firefox-bookmarks');
var bookmarks = new BookmarkCollection(rawBookmarks);
// Output simplified bookmark info
bookmarks.toJSON();
/*
[
{
"type": "folder",
"title": "web dev code",
"children": [
{
"type": "bookmark",
"title": "fxn/tkn - Terminal keynote presentation",
"dateAdded": 1364532709949934,
"lastModified": 1364532719708073,
"description": "tkn - Terminal Keynote - A hack for terminal-based talks",
"uri": "https://github.com/fxn/tkn"
}, ...
]
}, ...
]
*/CLI
We also present a command line tool for usage within npm scripts or globally.
$ npm install -g firefox-bookmarks
npm http GET https://registry.npmjs.org/firefox-bookmarks
npm http 200 https://registry.npmjs.org/firefox-bookmarks
...
$ firefox-bookmarks flatten ~/.mozilla/firefox/profile-id/bookmarkbackups/bookmarks-YYYY-MM-DD.json \
| underscore print | head
[
{
"title": "fxn/tkn - Terminal keynote presentation",
"dateAdded": 1364532709949934,
"lastModified": 1364532719708073,
"description": "tkn - Terminal Keynote - A hack for terminal-based talks",
"uri": "https://github.com/fxn/tkn"
},
{
"title": "pedalboard.js - Open-source JavaScript framework for developing audio effects for guitars",Documentation
firefox-bookmarks exposes BookmarkCollection as its module.exports.
new BookmarkCollection(rawBookmarks, options)
Constructor for interpretting a collection of Firefox bookmarks
- rawBookmarks
Object[]- Bookmarks saved to~/.mozilla/firefox/profile-id/bookmarkbackups/ - options
Object- Container for flags to affect behavior- folders
String[]- Array of whitelisted top-level folders to consume- If not provided, all folders will be consumed
- folders
bookmarks.toJSON()
Export internal bookmark data into simplified structure
Returns:
- retArr
Object[]- Array ofbookmarksandfolders
folder structure:
- type
String- Type of element (foldersusefolder) - title
String- Name of the folder - children
Object[]- Array of morefoldersandbookmarks
bookmark structure:
- type
String- Type of element (bookmarksusebookmark) - title
String- Name of the folder - uri
String- URL that was saved for the bookmark - dateAdded
Number- Microseconds (milliseconds/1000) since Linux epoch thatbookmarkwas added - lastModified
Number- Microseconds since Linux epoch thatbookmarkwas last updated - description
String- Description if there was one provided
bookmarks.flatten()
Export compresses set of bookmark data. All folders are thrown out and all bookmarks are put into one array.
Returns:
- retArr
Object[]- Array ofbookmarks- To save space,
typeis stripped from allbookmarks. Otherwise, these are the same as those inbookmarks.toJSON()
- To save space,
CLI
firefox-bookmarks installs a firefox-bookmarks executable. Options can be found via --help.
CLI flags (e.g. folders) are passed in as options that are passed in to the BookmarkCollection constructor.
$ firefox-bookmarks --help
Usage: firefox-bookmarks [options] [command]
Commands:
to-json [filepath] Parse a bookmarks file into simplified JSON
flatten [filepath] Flatten a bookmarks file into simplified bookmarks
Options:
-h, --help output usage information
-V, --version output the version numberContributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.
Donating
Support this project and others by twolfson via gittip.
Unlicense
As of Jan 21 2014, Todd Wolfson has released this repository and its contents to the public domain.
It has been released under the UNLICENSE.
