Skip to content

Instantly share code, notes, and snippets.

@ovitrif
Last active April 18, 2023 09:17
Show Gist options
  • Save ovitrif/0159d4defb390cd76f648bfb073ca293 to your computer and use it in GitHub Desktop.
Save ovitrif/0159d4defb390cd76f648bfb073ca293 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Expose `setThemeColor` window function to color toolbar of Chrome PWAs
// @namespace http://tampermonkey.net/
// @version 0.1
// @description A simple script to make it easier to set the appbar of Chrome apps via a small running after it.
// @author @ovitrif
// @match https://*/*
// @icon none
// @grant none
// ==/UserScript==
window.setThemeColor = (color) => {
let name = 'theme-color';
document.querySelector(`[name='${name}']`)?.remove()
let meta = document.createElement('meta');
meta.name = name;
meta.content = color;
document.head.appendChild(meta);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment