From 31ffdc5cc7e745d6a5a198d459b26f4a97b9bba0 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Thu, 10 Dec 2020 08:52:11 +0000 Subject: [PATCH] Dark mode support. --- github-game-of-life.js | 8 ++++++-- manifest.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/github-game-of-life.js b/github-game-of-life.js index e787b00..b5635dc 100644 --- a/github-game-of-life.js +++ b/github-game-of-life.js @@ -1,4 +1,4 @@ -// GitHub Game of Life - 1.0.1 +// GitHub Game of Life - 1.0.2 // Chris Johnson // @defaced / defaced.dev / github.com/workeffortwaste (function () { @@ -47,7 +47,11 @@ for (let i = 0; i < contributions.length; i++) { const days = contributions[i].getElementsByTagName('rect') for (let d = 0; d < 7; d++) { // Magic number - 7 days of the week. - try { days[d].setAttribute('fill', nextGenerationArray[i][d] ? '#40c463' : '#ebedf0') } catch {} + if (document.getElementsByTagName('html')[0].getAttribute('data-color-mode') === 'dark') { + try { days[d].setAttribute('fill', nextGenerationArray[i][d] ? '#40c463' : '#161b22') } catch {} + } else { + try { days[d].setAttribute('fill', nextGenerationArray[i][d] ? '#40c463' : '#ebedf0') } catch {} + } } } } diff --git a/manifest.json b/manifest.json index c4f9b08..9581dbf 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "GitHub Game of Life", "description": "Replace the GitHub contributions graph with Conway's Game of Life.", - "version": "1.0.1", + "version": "1.0.2", "icons": { "16": "icon16.png", "48": "icon48.png",