Skip to content

Instantly share code, notes, and snippets.

@harukaeru
Last active June 9, 2022 14:16
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 harukaeru/75d3489b7d8502137433cca0023bf82d to your computer and use it in GitHub Desktop.
Save harukaeru/75d3489b7d8502137433cca0023bf82d to your computer and use it in GitHub Desktop.
Reverse calculated rank to distribution percentage in github-readme-stats
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}%`);
@harukaeru
Copy link
Author

image

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