Skip to content

Instantly share code, notes, and snippets.

@voiski
Last active May 12, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voiski/a06ca20c94908e7fec62f4ec532779a9 to your computer and use it in GitHub Desktop.
Save voiski/a06ca20c94908e7fec62f4ec532779a9 to your computer and use it in GitHub Desktop.
Extract trello cards by list
// How to use it:
// 1. Press Command + Option + J (Mac) or Control + Shift + J (Windows, Linux, Chrome OS)
// 2. Copy and past in the console.
// About the functions
// - for js map: trelloExport.export()
// - print each list with cards: trelloExport.print()
(function () {
function extract() {
var board = {};
$(".js-list").each(function (_, list) {
var title = $(list).find(".js-list-name-assist").text();
board[title] = $(list).find(".js-card-name").map(function (_, card) {
return {
desc: $(card).text(),
votes: $(card).parent().find(".badge-text").text()
};
});
});
return board;
}
function print() {
var board = extract();
for (const [key, cards] of Object.entries(board)) {
var line = "* " + key;
$.each(cards, function (_, card) {
line += "\n" + card.desc.replace(/^(#\d+)/, "$1 ")
if(card.votes != "") line += " - " + card.votes + " Votes";
})
console.log(line)
}
}
return {
extract: extract,
print: print
}
})().print()
@voiski
Copy link
Author

voiski commented Jan 29, 2020

Or, the minified version using https://javascript-minifier.com/ - trible click in the line above to select all:

!function(){var t=function(){var t={};return $(".js-list").each(function(e,n){var s=$(n).find(".js-list-name-assist").text();t[s]=$(n).find(".js-card-name").map(function(t,e){return{desc:$(e).text(),votes:$(e).parent().find(".badge-text").text()}})}),t}();for(const[n,s]of Object.entries(t)){var e="* "+n;$.each(s,function(t,n){e+="\n"+n.desc.replace(/^(#\d+)/,"$1 "),""!=n.votes&&(e+=" - "+n.votes+" Votes")}),console.log(e)}}();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment