<script type="text/javascript" src="JS/bkmkscrub.js"></script>
<script type="text/javascript">
var myjsonobj = eval('(' + "the firefox bookmark JSON text data" + ')');
var myjson_bkmrks_streamlined = bkmkscrub.jsonbkmks( myjsonobj );
</script>
Download the bookmark scrubber project.
<script type="text/javascript" src="JS/bkmkscrub.js"></script>
Get the JSON data (text) file and feed it into eval(). There are a few ways to obtain the text data: URL, file browser or inlined. See the sample page for an example on using the file browser. The demo above shows how to fetch the data via the URL request. And inlining is just hard coding the text data.
var myjsonobj = eval('(' + "the firefox bookmark JSON text data" + ')');
WARNING:
eval() can take a long time if the
bookmark file is pretty large.
After myjsonobj is set with the JSON object, just pass it into bkmkscrub.jsonbkmks() like this:
var myjson_bkmrks_streamlined = bkmkscrub.jsonbkmks( myjsonobj );The value returned is the bare essential JSON entries needed for the Bookmark Organizer's restore feature to still work. The streamlined data is packed to be diff-edit-merge friendly and (hopefully) still human readable.
HTML Issues
The browser, however, may not like the results, you will have to make it HTML
friendly. An HTML open tag [ < ]
in the title or description will make the browser's renderer to go wonky.
It's not the browser's fault for doing what it's reading to do. So
myjson_bkmrks_streamlined needs to be neutered:
var myhtml = myjson_bkmrks_streamlined.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');Restore Issues
But importing the the streamlined JSON data shows this:
The first sub-children array is restored flipped. (Again, this only happends on the first children.children array. All other sub-of-a-sub children array are treated as you would expect it to.)
Long story short, there is no need for the following values in the streamlined version (but found in the original bookmark JSON data):
var flipme = 1; var myjson_bkmrks_streamlined = bkmkscrub.jsonbkmks( myjsonobj, flipme );
Why not use the index value to sort this out properly? If one items gets inserted in the list (say at the top) causing everyone else to shift down by one - the index number causes every item in that list to CHANGE. A big no-no as far as I'm concerned when trying to keep this diff-edit-merge friendly. But, this feature is very easy to impliment. Yes, left as an excercise for the reader... =)
// filter these folders on the fly var scrubTheseTitles=["a folder to omit", "another folder to drop", "Nonvisible Stuff"]; var flipme = 0; var scrubme = 1; var myjson_bkmrks_streamlined = bkmkscrub.jsonbkmks( myjsonobj, flipme, scrubme, scrubTheseTitles );Please see the JSON2HTML tutorial page to read more details about the scrub option. This feature will not be shown on the sample page. It is noted here, just in case this feature is needed for some reason.