Skip to content

Instantly share code, notes, and snippets.

@kvendrik
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save kvendrik/f9391989c25c289d0129 to your computer and use it in GitHub Desktop.

Select an option

Save kvendrik/f9391989c25c289d0129 to your computer and use it in GitHub Desktop.
Gets first <count> card titles of a Trello list (<listName>) and puts them into a string you can then use to paste them onto another board.
console.log(
getTrelloListItemsStr('Ready for Dev', 9)
);
/**
* Gets first <count> card titles of a Trello list (<listName>) and
* puts them into a string you can then use to paste them onto
* another board.
*
* @param {listName} name of the list to get the cards from
* @param {count} number of cards to get
*/
var getTrelloListItemsStr = function(listName, count){
var listHeads = document.getElementsByClassName('list-header-name'),
resultStr = '';
for(var i = listHeads.length-1; i >= 0; i--){
var currList = listHeads[i];
if(currList.innerText === listName){
var cardTitles = currList.parentNode.parentNode.getElementsByClassName('list-card-title');
for(var j = 0; j < cardTitles.length && j < count; j++){
resultStr += '- '+cardTitles[j].innerText+'\n';
}
}
}
return resultStr;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment