Last active
June 9, 2022 14:16
-
-
Save harukaeru/75d3489b7d8502137433cca0023bf82d to your computer and use it in GitHub Desktop.
Reverse calculated rank to distribution percentage in github-readme-stats
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
const debug = v => { console.log('debug', v); return v; } | |
// https://github.com/anuraghazra/github-readme-stats/blob/4e2f631f956a49efde2bc5883e5ce51891621c44/src/getStyles.js#L5 | |
const reverseProgress = (progress) => { | |
const radius = 40; | |
const c = Math.PI * (radius * 2); | |
return 100 * (progress / c) | |
} | |
// https://github.com/anuraghazra/github-readme-stats/blob/4e2f631f956a49efde2bc5883e5ce51891621c44/src/getStyles.js#L27 | |
Promise | |
.resolve(document.styleSheets[0].cssRules) | |
.then(Array.from) | |
.then( | |
arr => | |
arr.find(rule => rule.name === 'rankAnimation')[1].style.strokeDashoffset | |
) | |
.then(reverseProgress) | |
.then(distribution => `You are at the top ${distribution}%`); |
Author
harukaeru
commented
Jun 9, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment