Skip to content

Instantly share code, notes, and snippets.

@tilap
Forked from selvan/chrome-bookmarks
Created April 24, 2019 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilap/47eda937ee69f9ea6abf02f00047f148 to your computer and use it in GitHub Desktop.
Save tilap/47eda937ee69f9ea6abf02f00047f148 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