Skip to content

Instantly share code, notes, and snippets.

@aponxi
Created March 26, 2017 00:07
Show Gist options
  • Save aponxi/8f293e5c2d487f8cec25f604ae13b2fa to your computer and use it in GitHub Desktop.
Save aponxi/8f293e5c2d487f8cec25f604ae13b2fa to your computer and use it in GitHub Desktop.
Chrome Bookmark Parser
function parse(callback) {
results = new Array();
anchors = $("dl").find("a");
anchors.each(function(i, e) {
var add_date, name, result, tags, url;
url = $(e).attr("href");
name = $(e).text();
add_date = $(e).attr("add_date");
tags = new Array();
$(e).parents("dl").each(function(ii, ee) {
var folder, tag;
folder = $(ee).prev();
tag = folder.text();
tags.push(tag);
});
result = {
url: url,
name: name,
add_date: add_date,
tags: tags//,
// attr: $(e).attr()
};
results.push(result);
});
if (typeof callback === "function" ) {
return callback(results);
} else {
if(typeof callback !== "undefined")
return console.warn("Callback isn't a function.");
}
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment