Skip to content

Instantly share code, notes, and snippets.

@lucacicada
Created February 11, 2025 09:37
Show Gist options
  • Save lucacicada/ba09f757d3964737b87dab96ee8f33fe to your computer and use it in GitHub Desktop.
Save lucacicada/ba09f757d3964737b87dab96ee8f33fe to your computer and use it in GitHub Desktop.
Swap Google Search Background color scriptlet

Do not paste code randomly on your browser

We are kinda forced since Google treat us as lab rats

For Brave:

brave://settings/shields/filters

Make sure developer mode is on, add this custom filter:

google.com##+js(user-google-bg-color.js)

image

Under Custom scriptlets copy paste the code above

Name the scriptlet google-bg-color.js

The prefix user- will be added by Brave automatically.

What's up with the background color?

https://www.reddit.com/r/google/comments/1i8sub3/whats_up_with_the_background_color/

Google runs the biggest lab experiment in the universe, we are the lab rats

console.log('Color Scriptlet');
function getRootCSSVariables() {
const cssVars = {};
for (const sheet of document.styleSheets) {
try {
for (const rule of sheet.cssRules || []) {
if (rule.selectorText === ":root") {
for (const prop of rule.style) {
if (prop.startsWith("--")) {
cssVars[prop] = rule.style.getPropertyValue(prop).trim();
}
}
}
}
} catch {}
}
return cssVars;
}
function swapRootColors(colorTable) {
const css = getRootCSSVariables();
for (const [oldColor, newColor] of Object.entries(colorTable)) {
for (const [prop, value] of Object.entries(css)) {
if (value.includes(oldColor)) {
document.documentElement.style.setProperty(prop, newColor);
}
}
}
}
document.addEventListener('readystatechange', () => {
// Set your colors here
swapRootColors({
'#101218': '#202124',
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment