Something went wrong. Try again.
this post sux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384/* * sux sidebar theming — adopts the browser theme's colors when Firefox/Zen * exposes them via the theme API, and falls back to Everforest otherwise. * Applies CSS custom properties; sidebar.css consumes them. *//* global browser */(function () { "use strict";
// Everforest dark (medium) fallback. var FALLBACK = { "--bg": "#2d353b", "--panel": "#343f44", "--border": "#475258", "--text": "#d3c6aa", "--muted": "#859289", "--accent": "#7fbbb3", "--error": "#e67e80", };
function isUsable(color) { if (typeof color !== "string") return false; var c = color.trim(); if (!c || c === "transparent") return false; var m = c.match(/^rgba\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*([\d.]+)\s*\)$/i); if (m && parseFloat(m[1]) === 0) return false; if (/^#[0-9a-f]{8}$/i.test(c) && c.slice(-2) === "00") return false; return true; }
function firstUsable() { for (var i = 0; i < arguments.length; i++) { if (isUsable(arguments[i])) return arguments[i]; } return null; }
// Map theme API color names onto our variables. Returns null when the theme // exposes nothing usable, so the Everforest fallback stays intact. function pick(colors) { if (!colors) return null; var palette = { bg: firstUsable(colors.frame, colors.toolbar), panel: firstUsable(colors.popup, colors.toolbar), text: firstUsable(colors.popup_text, colors.toolbar_text, colors.tab_background_text), border: firstUsable(colors.popup_border, colors.toolbar_field_border, colors.toolbar_bottom_separator), accent: firstUsable(colors.tab_line, colors.tab_loading), }; if (!palette.bg && !palette.panel && !palette.text) return null; return palette; }
function apply(palette) { var style = document.documentElement.style; if (!palette) { Object.keys(FALLBACK).forEach(function (k) { style.setProperty(k, FALLBACK[k]); }); return; } if (palette.bg) style.setProperty("--bg", palette.bg); if (palette.panel) style.setProperty("--panel", palette.panel); if (palette.text) style.setProperty("--text", palette.text); if (palette.border) style.setProperty("--border", palette.border); if (palette.accent) style.setProperty("--accent", palette.accent); // No theme equivalent for secondary text or errors: derive muted from the // theme's own fg/bg, keep Everforest's red for errors. style.setProperty("--muted", "color-mix(in srgb, var(--text) 62%, var(--bg))"); }
function refresh() { if (!browser.theme || typeof browser.theme.getCurrent !== "function") { apply(null); return; } browser.theme.getCurrent().then(function (theme) { apply(pick(theme && theme.colors)); }).catch(function () { apply(null); }); }
refresh(); if (browser.theme && browser.theme.onUpdated) { browser.theme.onUpdated.addListener(refresh); }})();