Skip to content

Instantly share code, notes, and snippets.

@selvan
Created December 16, 2012 15:26
Show Gist options
  • Save selvan/4308471 to your computer and use it in GitHub Desktop.
Save selvan/4308471 to your computer and use it in GitHub Desktop.
Chrome extension to export all bookmarks
//manifest.json
{
"name": "bookmark-search-export",
"version": "1.0",
"manifest_version": 2,
"description": "This extention will dump all bookmarks",
"browser_action": {
"default_icon": "icon.png"
},
"background": {
"scripts": ["export.js"],
"persistent": false
},
"permissions": [
"bookmarks"
]
}
//export.js
chrome.runtime.onInstalled.addListener(function() {
console.log("bookmark search exporter extention Installed.");
var bm_urls = new Array();
function fetch_bookmarks(parentNode) {
parentNode.forEach(function(bookmark) {
if(! (bookmark.url === undefined || bookmark.url === null)) {
bm_urls.push(bookmark.url);
}
if (bookmark.children) {
fetch_bookmarks(bookmark.children);
}
});
}
chrome.bookmarks.getTree(function(rootNode) {
fetch_bookmarks(rootNode);
console.log(JSON.stringify(bm_urls));
});
});
chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
console.log("bookmark added .. " + bookmark.url);
});
chrome.bookmarks.onRemoved.addListener(function(id, removeInfo) {
console.log("bookmark removed .. " + id);
});
chrome.bookmarks.onChanged.addListener(function(id, changeInfo){
console.log("bookmark changed .. " + id);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment