Created
March 5, 2021 09:52
-
-
Save tschoffelen/291d92149823b78f6d052543f603035c to your computer and use it in GitHub Desktop.
Little tool I built for myself to export roam notes.
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
window.exportRoamNote = async () => { | |
const noteId = Math.round(Math.random()*10000) + '-note.md'; | |
const body = $('.roam-body .roam-app .roam-main .roam-article')[0].innerHTML; | |
const boxUrl = 'https://mrm5dm6of9.execute-api.eu-west-1.amazonaws.com/' | |
+ 'production/box/get-url?filename='+noteId+'&' | |
+ 'contentType=text%2Fplain'; | |
const res = await fetch(boxUrl, {method: 'GET' }); | |
const {key, url} = await res.json(); | |
await fetch(url, { | |
method: "PUT", | |
body, | |
headers: { | |
'Content-Type': 'text/plain', | |
'ContentEncoding': 'utf-8' | |
} | |
}) | |
const noteUrl = `https://schof.co/notes/${key.replace('-note.md', '').replace('f/','').replace('/','-')}`; | |
console.log(noteUrl); | |
window.open(noteUrl); | |
} | |
setTimeout(() => { | |
$('#export-share').length || $('.rm-topbar').append('<span id="export-share" onclick="window.exportRoamNote()">⬆️</span>') | |
}, 2500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added using the
{{[[roam/js]]}}
tag, with a nested code block: