Skip to content

Instantly share code, notes, and snippets.

@ryz310
Last active August 8, 2019 01:09
Show Gist options
  • Save ryz310/2db09a7ee68dcc0eae1ff3a91421341f to your computer and use it in GitHub Desktop.
Save ryz310/2db09a7ee68dcc0eae1ff3a91421341f to your computer and use it in GitHub Desktop.
朝会の daily-standup-bot に投げるテキストを esa.io の日報から生成する JS。
const pbCopy = (text) => {
const tmp = document.createElement('div');
const pre = document.createElement('pre');
pre.style.webkitUserSelect = 'auto';
pre.style.userSelect = 'auto';
tmp.style.position = 'fixed';
tmp.style.right = '200%';
tmp.appendChild(pre).textContent = text;
document.body.appendChild(tmp);
document.getSelection().selectAllChildren(tmp);
document.execCommand("copy");
document.body.removeChild(tmp);
return text;
}
const morning_meating = document
.getElementById('post_body_md')
.value
.replace(/今日/g, '昨日')
.replace(/明日/g, '今日')
.replace(/\[(WIP|RIP)\] /gm, '')
.replace(/^#+ (.+)/gm, '*$1*')
.replace(/^.+?\[(.+?)\]\(.+\) by .+/gm, '▼ $1')
.replace(/\* /gm, '• ')
.replace(/:@(.+?):/gm, '$1');
pbCopy(morning_meating);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment