diff --git a/src/browser/base/content/zen-assets.inc.xhtml b/src/browser/base/content/zen-assets.inc.xhtml
index 0712bbac4..aede36ce4 100644
--- a/src/browser/base/content/zen-assets.inc.xhtml
+++ b/src/browser/base/content/zen-assets.inc.xhtml
@@ -1,6 +1,6 @@
#include zen-locales.inc.xhtml
-
+# Styles used all over the browser
@@ -25,7 +25,7 @@
-
+# Scripts used all over the browser
@@ -40,3 +40,6 @@
+
+# Unimportant scripts
+
diff --git a/src/browser/base/content/zen-assets.jar.inc.mn b/src/browser/base/content/zen-assets.jar.inc.mn
index 7756c5659..10a2a4487 100644
--- a/src/browser/base/content/zen-assets.jar.inc.mn
+++ b/src/browser/base/content/zen-assets.jar.inc.mn
@@ -22,6 +22,7 @@
content/browser/zen-components/ZenGradientGenerator.mjs (zen-components/ZenGradientGenerator.mjs)
content/browser/zen-components/ZenGlanceManager.mjs (zen-components/ZenGlanceManager.mjs)
content/browser/zen-components/ZenActorsManager.mjs (zen-components/ZenActorsManager.mjs)
+ content/browser/zen-components/ZenRices.mjs (zen-components/ZenRices.mjs)
content/browser/zen-styles/zen-theme.css (content/zen-styles/zen-theme.css)
content/browser/zen-styles/zen-buttons.css (content/zen-styles/zen-buttons.css)
diff --git a/src/browser/base/zen-components/ZenRices.mjs b/src/browser/base/zen-components/ZenRices.mjs
new file mode 100644
index 000000000..b0f57b2b9
--- /dev/null
+++ b/src/browser/base/zen-components/ZenRices.mjs
@@ -0,0 +1,117 @@
+
+{
+ class ZenRiceCollector {
+ constructor() {}
+
+ clear() {
+ this._userChrome = null;
+ this._userContent = null;
+ this._enabledMods = null;
+ this._preferences = null;
+ this._workspaceThemes = null;
+ }
+
+ async gatherAll({
+ userUserChrome = true, userContent = true,
+ enabledMods = true, preferences = true,
+ modPrefs = true, workspaceThemes = true } = {}) {
+ this.clear();
+ // Get the mods first, as they may be needed for the preferences
+ if (enabledMods) {
+ await this.gatherEnabledMods();
+ }
+ await Promise.all([
+ userUserChrome && this.gatherUserChrome(),
+ userContent && this.gatherUserContent(),
+ preferences && this.gatherPreferences({ modPrefs }),
+ workspaceThemes && this.gatherWorkspaceThemes(),
+ ]);
+ }
+
+ get profileDir() {
+ return PathUtils.profileDir;
+ }
+
+ async gatherUserChrome() {
+ try {
+ const path = PathUtils.join(this.profileDir, 'chrome', 'userChrome.css');
+ this._userChrome = await IOUtils.readUTF8(path);
+ } catch (e) {
+ console.warn("[ZenRiceCollector]: Error reading userChrome.css: ", e);
+ return null;
+ }
+ }
+
+ async gatherUserContent() {
+ try {
+ const path = PathUtils.join(this.profileDir, 'chrome', 'userContent.css');
+ this._userContent = await IOUtils.readUTF8(path);
+ } catch (e) {
+ console.warn("[ZenRiceCollector]: Error reading userContent.css: ", e);
+ return null;
+ }
+ }
+
+ async gatherEnabledMods() {
+ const activeThemes = await gZenThemesImporter.getEnabledThemes();
+ if (activeThemes.length === 0) {
+ return;
+ }
+ this._enabledMods = activeThemes;
+ }
+
+ _getThemePrefValue(theme, pref) {
+ if (pref.type === 'checkbox') {
+ return Services.prefs.getBoolPref(pref.property);
+ }
+ return Services.prefs.getStringPref(pref.property);
+ }
+
+ async gatherPreferences({ modPrefs = true } = {}) {
+ this._preferences = {};
+ if (modPrefs && this._enabledMods) {
+ for (const theme of this._enabledMods) {
+ const prefs = await ZenThemesCommon.getThemePreferences(theme);
+ for (const pref of prefs) {
+ this._preferences[pref.property] = this._getThemePrefValue(theme, pref);
+ }
+ }
+ }
+ const boolPrefsToCollect = [
+ 'zen.view.use-single-toolbar',
+ 'zen.view.sidebar-expanded',
+ 'zen.tabs.vertical.right-side',
+ 'zen.view.experimental-no-window-controls',
+ 'zen.view.hide-window-controls',
+ ];
+ const stringPrefsToCollect = [
+ 'browser.uiCustomization.state'
+ ];
+ for (const pref of boolPrefsToCollect) {
+ this._preferences[pref] = Services.prefs.getBoolPref(pref);
+ }
+ for (const pref of stringPrefsToCollect) {
+ this._preferences[pref] = Services.prefs.getStringPref(pref);
+ }
+ }
+
+ async gatherWorkspaceThemes() {
+ const workspaces = (await ZenWorkspaces._workspaces()).workspaces;
+ this._workspaceThemes = workspaces.map(w => w.theme);
+ }
+
+ async packRice() {
+ await this.gatherAll();
+ const rice = {
+ userChrome: this._userChrome,
+ userContent: this._userContent,
+ enabledMods: this._enabledMods?.map(t => t.id),
+ preferences: this._preferences,
+ workspaceThemes: this._workspaceThemes,
+ };
+ return rice;
+ }
+ }
+
+ window.gZenRiceCollector = new ZenRiceCollector();
+}