Skip to content

Instantly share code, notes, and snippets.

@willthemoor
Created August 5, 2016 04:37
Show Gist options
  • Save willthemoor/ab65dab93c19f9e9d17a48e056b1b30b to your computer and use it in GitHub Desktop.
Save willthemoor/ab65dab93c19f9e9d17a48e056b1b30b to your computer and use it in GitHub Desktop.
Todoist list HTML to CSV via Console
/**
*
* Dump a CSV of all Todoist task to your browser console.
*
* NOTE: Sorry, I was lazy. Requires jQuerify or similar running in your browser
* Alternatively, copy the HTML from Todoist and drop it into the HTML
* field within codepen.io, jsfiddle.net or similar
*
* 1. Run it
* 2. Copy and Paste into Excel
* 3. Go to Data->Text to Columns
*
*/
function getAllTodoistTasks(i, item) {
// Filter: all
var $task, text, date, project, priority, classes, out;
$task = $jq(item);
text = $task.find('.content>span').text();
date = $task.find('.date').text();
project = $task.find('.project_item').text();
classes = $task.attr('class');
classes = classes.split('priority_');
priority = classes[1].substring(0,1);
out = project + ",'" + text + "',";
out += date + "," + priority;
if (i == 0){
console.log("Project,Task,Due Date,Priority");
}
console.log(out);
}
function getProjectTodoistTasks(i, item) {
// Perserves nesting by adding parent items as labels
var $task, text, date, project, priority, classes, out, label = "";
$task = $jq(item);
classes = $task.attr('class');
if (classes.indexOf('checked') > -1 || classes.indexOf('reorder_item') > -1){
return;
} else if (classes.indexOf('indent_2') > 0){
label = $task.prevAll('.indent_1:first').find('.content>span').text();
}
classes = classes.split('priority_');
priority = classes[1].substring(0,1);
text = $task.find('.content>span').text();
date = $task.find('.date').text();
project = $jq('.project_link').find('span').text();
out = project + ",'" + text + "',";
out += date + "," + priority + "," + label;
if (i == 0){
console.log("Project,Task,Due Date,Priority,Label");
}
console.log(out);
}
console.clear();
//$jq('.task_item').each(getAllTodoistTasks);
//$jq('.task_item').each(getProjectTodoistTasks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment