From 5e725ed5179f00aad21fe39191b7cb153d29243f Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 6 Apr 2025 22:13:42 +1000 Subject: [PATCH 1/2] Update GitHub Contribution Color Graph to Manifest V3 This commit updates the Chrome extension from Manifest V2 to Manifest V3 to comply with Google's latest requirements: - Update manifest.json to use manifest_version 3 and add the action field - Modernize Chrome Storage API usage in contentscript.js and options.js to use Promises - Update CSS variable selectors to match GitHub's current contribution graph implementation - Add better error handling with detailed error messages These changes ensure compatibility with Chrome's latest extension requirements while preserving all functionality. --- src/js/contentscript.js | 27 ++++++++++++++------------- src/js/options.js | 8 ++++++-- src/manifest.json | 10 +++++++++- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 8f4eacc..62ea50b 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -69,11 +69,11 @@ var colors = { }; var cssGitHubVars = [ - '--color-calendar-graph-day-bg', - '--color-calendar-graph-day-L1-bg', - '--color-calendar-graph-day-L2-bg', - '--color-calendar-graph-day-L3-bg', - '--color-calendar-graph-day-L4-bg' + '--contribution-default-bgColor-0', + '--contribution-default-bgColor-1', + '--contribution-default-bgColor-2', + '--contribution-default-bgColor-3', + '--contribution-default-bgColor-4' ]; var randomColor = randomProperty(colors); @@ -129,15 +129,16 @@ function applyColorToActivity (color) { } function applyOptions () { - chrome.storage.local.get('favoriteColor', function (color) { - if (!color.favoriteColor) { - color.favoriteColor = 'halloween'; - } else if (color.favoriteColor === 'random') { - color.favoriteColor = randomColor; + chrome.storage.local.get(['favoriteColor']).then((result) => { + let colorName = result.favoriteColor || 'halloween'; + if (colorName === 'random') { + colorName = randomColor; } - applyColorToCssGitHubVars(colors[color.favoriteColor]); - applyColorToLegend(colors[color.favoriteColor]); - applyColorToActivity(colors[color.favoriteColor]); + applyColorToCssGitHubVars(colors[colorName]); + applyColorToLegend(colors[colorName]); + applyColorToActivity(colors[colorName]); + }).catch((error) => { + console.error(`Error when getting stored color: ${error}`); }); } diff --git a/src/js/options.js b/src/js/options.js index ee4c994..b01073b 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -4,20 +4,24 @@ function saveOptions () { var color = document.getElementById('color').value; chrome.storage.local.set({ favoriteColor: color - }, function () { + }).then(() => { var status = document.getElementById('status'); status.textContent = 'Options saved.'; setTimeout(function () { status.textContent = ''; }, 750); + }).catch((error) => { + console.error(`Error when saving options: ${error}`); }); } function restoreOptions () { chrome.storage.local.get({ favoriteColor: 'halloween' - }, function (items) { + }).then((items) => { document.getElementById('color').value = items.favoriteColor; + }).catch((error) => { + console.error(`Error when restoring options: ${error}`); }); } diff --git a/src/manifest.json b/src/manifest.json index a4e7d28..67406fc 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "name": "GitHub Contribution Color Graph", "description": "Change colors of contribution graph in GitHub", - "manifest_version": 2, + "manifest_version": 3, "version": "1.7.2", "content_scripts": [{ @@ -23,5 +23,13 @@ "16": "images/icon-16.png", "48": "images/icon-48.png", "128": "images/icon-128.png" + }, + + "action": { + "default_icon": { + "16": "images/icon-16.png", + "48": "images/icon-48.png", + "128": "images/icon-128.png" + } } } From af18788af8c30774cc246db6cdbdba3d79d0f544 Mon Sep 17 00:00:00 2001 From: Kevin Lee Date: Sun, 6 Apr 2025 22:23:01 +1000 Subject: [PATCH 2/2] github-contribution-color-graph v1.8.0 --- CHANGELOG.md | 10 ++++++++++ src/manifest.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 821f172..766fb0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ Changelog ========= +### v1.8.0 / 2025-04-06 + + - Update extension to Manifest V3 to comply with Chrome requirements + - Update CSS variable selectors to match GitHub's current implementation + - Modernize Chrome Storage API with Promise-based approach + - Add proper error handling with detailed error messages + - Add required "action" field to replace deprecated "browser_action" + - Improve code readability with modern JavaScript syntax + - Enhance error logging for better debugging + ### v1.7.2 / 2020-10-30 - Fix contribution graph and progress bar colors (new GitHub CSS variables) diff --git a/src/manifest.json b/src/manifest.json index 67406fc..90d6871 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "name": "GitHub Contribution Color Graph", "description": "Change colors of contribution graph in GitHub", "manifest_version": 3, - "version": "1.7.2", + "version": "1.8.0", "content_scripts": [{ "js": [ "js/contentscript.js" ],