20 lines
480 B
JavaScript
20 lines
480 B
JavaScript
/* Broadcast color scheme on browser start, because no change event is fired */
|
|
updateColorScheme(window.matchMedia('(prefers-color-scheme: dark)'));
|
|
|
|
function updateColorScheme(event) {
|
|
console.log("doing!");
|
|
chrome.runtime.sendMessage({
|
|
content: "colorScheme",
|
|
isDark: event.matches
|
|
});
|
|
}
|
|
|
|
/* Broadcast when page is loaded */
|
|
window.addEventListener("load", updateState);
|
|
|
|
function updateState() {
|
|
chrome.runtime.sendMessage({
|
|
content: "updateState"
|
|
});
|
|
}
|