Skip to content

Instantly share code, notes, and snippets.

@Aschen
Last active March 15, 2021 05:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aschen/fb3eb592b1633264446de03f4343b7d0 to your computer and use it in GitHub Desktop.
Save Aschen/fb3eb592b1633264446de03f4343b7d0 to your computer and use it in GitHub Desktop.
Get random card from a Trello board

Shuffle Trello : Pick a random card in a column

This small script pick a random card in a column on a Trello board.

We use this script at Kuzzle to pick a random card for our product workshop.

Usage

Change the number of the column from which you want to take a random card. For example to pick a card in the first column of the board:

var column = 1;
fetch(document.querySelector(`#board > div:nth-child(${column}) > div > div.list-cards.u-fancy-scrollbar.u-clearfix.js-list-cards.js-sortable.ui-sortable`).children[Math.floor(Math.random() * Math.floor(document.querySelector(`#board > div:nth-child(${column}) > div > div.list-cards.u-fancy-scrollbar.u-clearfix.js-list-cards.js-sortable.ui-sortable`).children.length))].getAttribute("href")).then((data) => {document.location = data.url })
// original script from https://github.com/alexandrebouthinon
// Column number to shuffle (From left to right, Trello start with column number 1)
var column = 2;
fetch(document.querySelector(`#board > div:nth-child(${column}) > div > div.list-cards.u-fancy-scrollbar.u-clearfix.js-list-cards.js-sortable.ui-sortable`).children[Math.floor(Math.random() * Math.floor(document.querySelector(`#board > div:nth-child(${column}) > div > div.list-cards.u-fancy-scrollbar.u-clearfix.js-list-cards.js-sortable.ui-sortable`).children.length))].getAttribute("href")).then((data) => {document.location = data.url })
@jatubio
Copy link

jatubio commented Jan 5, 2021

How do you use this one?

@Aschen
Copy link
Author

Aschen commented Jan 5, 2021

It will shuffle cards in the second column. If you want to shuffle card from another column you can change the 2 here "#board > div:nth-child(2)

@jatubio
Copy link

jatubio commented Jan 5, 2021

Thank you for your answer. I meant: Where can I put this code? As a booklet in Chrome?

@Aschen
Copy link
Author

Aschen commented Jan 5, 2021

Yes I think a booklet will work. Otherwise you can put it in the browser console

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