Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created September 6, 2022 16:06
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 tjmcewan/a48e61d7284b37d085b8098449b6ab40 to your computer and use it in GitHub Desktop.
Save tjmcewan/a48e61d7284b37d085b8098449b6ab40 to your computer and use it in GitHub Desktop.
Bookmarklet to copy EasyRetro cards to your clipboard as markdown
javascript:
!(() => document.querySelectorAll('.easy-card-list').length < 1
? window.alert('EasyRetro board columns not found')
: (() => {
/* show all the comments first */
document.querySelectorAll('[aria-label="New comment"]').forEach(el => el.click());
navigator.clipboard.writeText(
[...document.querySelectorAll('.easy-card-list')]
/* for each column: get column header */
.map(l => [`# ${l.querySelector('.column-header').textContent.trim()}\n`]
.concat([...l.querySelectorAll('.easy-card')]
/* for each card: get likes, text, comments */
.map(c => '- '
.concat(c.querySelector('.easy-badge-votes').textContent.trim() === '0' ? '' : `[+${c.querySelector('.easy-badge-votes').textContent.trim()}] `)
.concat(c.querySelector('.easy-card-main').textContent.trim().replaceAll('\n---\n', ' || '))
.concat([...c.querySelectorAll('.easy-comment-text')].map(m => '\n - ' + m.textContent.trim()).join(''))
)
).join('\n')
).join('\n\n\n')
).then(() => {
/* if copy to clipboard was a success, hide the comments again */
document.querySelectorAll('[aria-label="New comment"]').forEach(el => el.click());
window.alert('Markdown copied to clipboard');
}, e => console.error(e) || window.alert('Hm, something went wrong'))
})()
)();
void (0);
javascript:!(()=>document.querySelectorAll('.easy-card-list').length<1?window.alert('EasyRetro board columns not found'):(()=>{document.querySelectorAll('[aria-label="New comment"]').forEach(el=>el.click());navigator.clipboard.writeText([...document.querySelectorAll('.easy-card-list')].map(l=>[`# ${l.querySelector('.column-header').textContent.trim()}\n`].concat([...l.querySelectorAll('.easy-card')].map(c=>'- '.concat(c.querySelector('.easy-badge-votes').textContent.trim()==='0'?'':`[+${c.querySelector('.easy-badge-votes').textContent.trim()}] `).concat(c.querySelector('.easy-card-main').textContent.trim().replaceAll('\n---\n',' || ')).concat([...c.querySelectorAll('.easy-comment-text')].map(m=>'\n - '+m.textContent.trim()).join('')))).join('\n')).join('\n\n\n')).then(()=>{document.querySelectorAll('[aria-label="New comment"]').forEach(el=>el.click());window.alert('Markdown copied to clipboard');},e=>console.error(e)||window.alert('Hm, something went wrong'))})())();void(0);
@tjmcewan
Copy link
Author

tjmcewan commented Sep 6, 2022

Reload the page first so that all comments are closed.

@tjmcewan
Copy link
Author

tjmcewan commented Sep 6, 2022

Also, clear all columns with confirmation:

javascript:!(()=>confirm('Clear ALL columns?')&&[...document.querySelectorAll('.easy-card-list')].forEach(col=>{col.querySelector('[aria-label="Open column menu"]').click();col.querySelector('[aria-label="Clear column"]').click();document.querySelector('#swal2-checkbox').checked = true;document.querySelector('button.swal2-confirm').click();}))();void(0);

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