-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookmarklet.js
1 lines (1 loc) · 945 Bytes
/
bookmarklet.js
1
javascript:(function() %7Bvar access_token = 'YOUR_TOKEN_HERE';function ajax(params) %7Bvar request = new XMLHttpRequest();request.onreadystatechange = function() %7Bif (this.readyState == 4) %7Bif (this.status == 200) %7Bparams.success(this.responseText);%7D else %7Bconsole.error(new Error('Response returned with error code.'));console.error(this.responseText);%7D%7D%7D;request.open(params.type, params.url, true);params.beforeSend(request);request.send();%7Dajax(%7Btype: 'POST',beforeSend: function(request) %7Brequest.setRequestHeader('Content-Type', 'application/octet-stream');request.setRequestHeader('Authorization', %60Bearer $%7Baccess_token%7D%60);request.setRequestHeader('Dropbox-API-Arg', '%7B"import_format":"markdown"%7D');%7D,url: 'https://api.dropboxapi.com/2/paper/docs/create',success: function(resp) %7Bvar data = JSON.parse(resp);window.location = %60https://paper.dropbox.com/doc/$%7Bdata.doc_id%7D%60;%7D,%7D);%7D)();