- Create a new Bookmark
- Copy/Paste the following URL:
javascript:(function()%7Bdocument.querySelectorAll('.js-column-time-count').forEach%20(el%20%3D%3E%20el.remove())%3Bcolumns%20%3D%20document.querySelectorAll('.project-column')%3Bcolumns.forEach((column)%20%3D%3E%20%7Bconst%20nodeListLabels%20%3D%20column.querySelectorAll('.js-project-column-cards%20.project-card%3Anot(.d-none)%20.issue-card-label%20%3E%20.css-truncate-target')%3Bconst%20detailContainer%20%3D%20column.querySelector('.details-container%20%3E%20.hide-sm')%3Bconst%20labels%20%3D%20%5B...nodeListLabels%5D%3Bconst%20totalTime%20%3D%20labels.reduce(%20(acc%2C%20el)%20%3D%3E%20%7Bconst%20match%20%3D%20el.innerText.match(%2Ftime%3A%20(%C2%BD%7C%5B0-9%5D%2B)%2F)%3Bif%20(null%20%3D%3D%3D%20match)%20%7Breturn%20acc%20%2B%200%3B%7Dlet%20time%20%3D%20match%5B1%5D%3Bif%20(time%20%3D%3D%20'%C2%BD')%20%7Btime%20%3D%200.5%3B%7Dreturn%20acc%20%2B%20parseFloat(time)%3B%7D%2C%200)%3Bconst%20timeCounterEl%20%3D%20document.createElement('span')%3BtimeCounterEl.setAttribute('class'%2C%20'js-column-time-count%20Counter%20Counter--gray-light%20position-relative%20ml-1%20v-align-middle')%3BtimeCounterEl.style.backgroundColor%20%3D%20'%23ceddef'%3BtimeCounterEl.innerHTML%20%3D%20'Time%3A%20'%20%2B%20totalTime%3BdetailContainer.append(timeCounterEl)%3B%7D)%7D)()
Last active
March 23, 2020 12:12
-
-
Save gido/73e833fc4555b8aacad8a69453f2b556 to your computer and use it in GitHub Desktop.
Bookmark to add time counter on Github Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelectorAll('.js-column-time-count').forEach (el => el.remove()); | |
columns = document.querySelectorAll('.project-column'); | |
columns.forEach((column) => { | |
const nodeListLabels = column.querySelectorAll('.js-project-column-cards .project-card:not(.d-none) .issue-card-label > .css-truncate-target'); | |
const detailContainer = column.querySelector('.details-container > .hide-sm'); | |
const labels = [...nodeListLabels]; | |
const totalTime = labels.reduce( (acc, el) => { | |
const match = el.innerText.match(/time: (½|[0-9]+)/); | |
if (null === match) { | |
return acc + 0; | |
} | |
let time = match[1]; | |
if (time == '½') { | |
time = 0.5; | |
} | |
return acc + parseFloat(time); | |
}, 0); | |
const timeCounterEl = document.createElement('span'); | |
timeCounterEl.setAttribute('class', 'js-column-time-count Counter Counter--gray-light position-relative ml-1 v-align-middle'); | |
timeCounterEl.style.backgroundColor = '#ceddef'; | |
timeCounterEl.innerHTML = 'Time: ' + totalTime; | |
detailContainer.append(timeCounterEl); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment