Last active
January 12, 2019 02:08
-
-
Save bre7/dd0fb48b0de847677d3e4ae8fdbc3967 to your computer and use it in GitHub Desktop.
Swaps the default blue-based palette with a proper one. Thanks to https://learnui.design/tools/data-color-picker.html for the idea & color selection
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
| // ==UserScript== | |
| // @name Google Analytics color fixer | |
| // @description Swaps the default blue-based palette with a proper one. Thanks to https://learnui.design/tools/data-color-picker.html for the idea & color selection | |
| // @version 0.4 | |
| // @author You | |
| // @match https://analytics.google.com/analytics/web/*embed/report-home/*/ | |
| // @match https://analytics.google.com/analytics/web/* | |
| // @grant GM_addStyle | |
| // ==/UserScript== | |
| var colors = ["#003f5c", "#2f4b7c", "#665191", "#a05195", "#d45087", "#f95d6a", "#ff7c43", "#ffa600"]; | |
| for(var i = 0; i < colors.length; i++) { | |
| GM_addStyle('stacked-bar-chart > svg > g:nth-child(2) > g.layer:nth-child('+(i+1)+') { fill: '+colors[i]+' !important; } '); | |
| GM_addStyle('pie-chart > svg > g.pie > path:nth-child('+(i+1)+') { fill: '+colors[i]+' !important; } '); | |
| GM_addStyle('ga-time-of-day-chart .legend-block.blue-'+(i+1)+' { fill: '+colors[i]+' !important; } '); | |
| GM_addStyle('ga-time-of-day-chart .blue-'+(i+1)+' rect { fill: '+colors[i]+' !important; } '); | |
| GM_addStyle('ga-d3-cohort-table .blue-'+(i+1)+' rect { fill: '+colors[i]+' !important; } '); | |
| GM_addStyle('ga-tabbed-chart stacked-bar-chart > svg g.layer:nth-child('+(i+1)+') { fill: '+colors[i]+' !important; } '); | |
| } | |
| (function() { | |
| 'use strict'; | |
| console.log("Started GA color fixer"); | |
| /* TODO Replace timeout | |
| var MutationObserver = MutationObserver || WebKitMutationObserver || MozMutationObserver; | |
| var insertedNodes = []; | |
| var observer = new MutationObserver(function(mutations) { | |
| mutations.forEach(function(mutation) { | |
| for (var i = 0; i < mutation.addedNodes.length; i++) | |
| insertedNodes.push(mutation.addedNodes[i]); | |
| }); | |
| }); | |
| observer.observe(document, { childList: true }); | |
| console.log(insertedNodes); | |
| setTimeout( function() { | |
| $('stacked-bar-chart > svg > g:nth-child(2) > g.layer').each(function () { | |
| //$(this).removeAttr('fill'); | |
| console.log("Removed fills"); | |
| }); | |
| }, 4000); | |
| */ | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credits: https://learnui.design/tools/data-color-picker.html