Skip to content

Instantly share code, notes, and snippets.

@rostyq
Created July 11, 2024 16:15
Show Gist options
  • Save rostyq/2cade3bd8ebfb57d12c88a4fbc67cde0 to your computer and use it in GitHub Desktop.
Save rostyq/2cade3bd8ebfb57d12c88a4fbc67cde0 to your computer and use it in GitHub Desktop.
JS snippet to redraw GitHub contribution graph into DTEK power schedule
function convertToPeriodicValue(value, periodLength) {
let modValue = value % periodLength;
if (modValue < 4) {
return 0;
} else if (modValue >= 4 && modValue < 7) {
return 1;
} else if (modValue >= 7 && modValue < 9) {
return 4;
}
}
document.querySelectorAll("td.ContributionCalendar-day").forEach((e, i) => e.setAttribute("data-level", convertToPeriodicValue(i, 9)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment