Created
March 26, 2017 00:07
-
-
Save aponxi/8f293e5c2d487f8cec25f604ae13b2fa to your computer and use it in GitHub Desktop.
Chrome Bookmark Parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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