From 39b7fe1319fc41bdda5a165a5d7bf685dd0ad5e2 Mon Sep 17 00:00:00 2001 From: Farid Zelli <82771409+FaridZelli@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:22:12 +0330 Subject: [PATCH] Added "Use system theme (auto)" to context menu --- background.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/background.js b/background.js index 77c2368..c11f8c1 100644 --- a/background.js +++ b/background.js @@ -16,3 +16,22 @@ function toggleTheme() { } browser.action.onClicked.addListener(toggleTheme); + +function toggleSystemTheme() { + browser.management.get("default-theme@mozilla.org").then(info => { + browser.management.setEnabled("default-theme@mozilla.org", !info.enabled); + }); +} + +browser.menus.create({ + id: "use-systemtheme", + type: "normal", + title: "Use system theme (auto)", + contexts: ["action"], + icons: { + "16": "icons/browser.svg", + "32": "icons/browser.svg" + }, +}); + +browser.menus.onClicked.addListener(toggleSystemTheme);