Skip to content

Instantly share code, notes, and snippets.

@Aschen
Last active September 10, 2025 10:04
Show Gist options
  • Select an option

  • Save Aschen/fb3eb592b1633264446de03f4343b7d0 to your computer and use it in GitHub Desktop.

Select an option

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

jatubio commented Jan 5, 2021

Copy link
Copy Markdown

How do you use this one?

@Aschen

Aschen commented Jan 5, 2021

Copy link
Copy Markdown
Author

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

jatubio commented Jan 5, 2021

Copy link
Copy Markdown

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

@Aschen

Aschen commented Jan 5, 2021

Copy link
Copy Markdown
Author

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

@dgmstuart

Copy link
Copy Markdown

This doesn't seem to work anymore - I guess Trello changed their UI a bit:

VM181:2 Uncaught TypeError: Cannot read properties of null (reading 'children')

@Aschen

Aschen commented Sep 10, 2025

Copy link
Copy Markdown
Author

Yes most likely :-) The script is quite old and we don't use it anymore.

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