-
-
Save jdaviescoates/3f2e88121aebe1415984a4e49e78b63d to your computer and use it in GitHub Desktop.
export your Diigo bookmarks from a logged-in account page in browser console (JavaScript)
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
javascript:'use%20strict';void%20function(){(async%20function(){async%20function%20a(a){return%20fetch(%22https://www.diigo.com/interact_api/load_user_items%3Fpage_num=%22+a+%22%26sort=updated%26count=96%22).then(function(a){return%20a.json()})}function%20b(b,c){var%20d=2%3Carguments.length%26%26arguments[2]!==void%200%3Farguments[2]:%22text/plain%22,e=new%20Blob([b],{type:d}),f=document.createElement(%22a%22);f.href=URL.createObjectURL(e),f.download=c,f.click(),URL.revokeObjectURL(f.href)}if(confirm(%22Begin%20export%20to%20diigo-bookmarks.json%3F%20(please%20be%20patient!!)%22)){for(var%20c=-1,d=[];;){var%20e=await%20a(++c),f=e.items;if(f=f.map(function(a){return{description:a.description,tags:a.tags.split(%22,%22),title:a.title,type_name:a.type_name,url:a.url}}),d=d.concat(f),96%3Ef.length)break}console.log({l:d.length});var%20g=JSON.stringify(d,null,2);b(g,%22diigo-bookmarks.json%22)}})()}(); |
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
async function main() { | |
if (!confirm('Begin export to diigo-bookmarks.json? (please be patient!!)')) { return; }; | |
async function dlItems(pg) { | |
return fetch(`https://www.diigo.com/interact_api/load_user_items?page_num=${pg}&sort=updated&count=96`).then(r => r.json()); | |
} | |
let pg = -1; | |
let allitems = []; | |
while(true) { | |
let {items} = await dlItems(++pg); | |
items = items.map(i => { | |
return { | |
description: i.description, | |
tags: i.tags.split(','), | |
title: i.title, | |
type_name: i.type_name, | |
url: i.url | |
}; | |
}); | |
allitems = allitems.concat(items); | |
if (items.length < 96) { break; } | |
} | |
const mystring = JSON.stringify(allitems, null, 2); | |
function downloadToFile(mystring, filename, contentType = 'text/plain') { | |
const file = new Blob([mystring], {type: contentType}); | |
const a = document.createElement('a'); | |
a.href = URL.createObjectURL(file); | |
a.download = filename; | |
a.click(); | |
URL.revokeObjectURL(a.href); | |
}; | |
downloadToFile(mystring, 'diigo-bookmarks.json'); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment