From 346b5ded7c5c740cffa5ed7df7ad30e5d92d9c8b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 23 Nov 2024 13:17:13 -0500 Subject: [PATCH] [mv3] Add ability for admins to disable features New managed setting: "disabledFeatures": { "title": "User interface features to disable", "description": "A list of tokens, each of which correspond to a user interface feature to disable.", "type": "array", "items": { "type": "string" } } Supported tokens: - `dashboard`: Prevent access to all dashboard settings - `filteringMode`: Prevent changes to the default filtering mode, or the current filtering mode of any site Related feedback: https://github.com/uBlockOrigin/uBOL-home/discussions/35#discussioncomment-11326086 --- platform/mv3/extension/css/filtering-mode.css | 17 +++++++++++++---- platform/mv3/extension/css/popup.css | 7 +++++++ platform/mv3/extension/css/settings.css | 14 ++++++++++++++ platform/mv3/extension/dashboard.html | 2 +- platform/mv3/extension/js/background.js | 16 +++++++++++++++- platform/mv3/extension/js/popup.js | 10 ++++++++++ platform/mv3/extension/js/settings.js | 13 +++++++++++++ platform/mv3/extension/managed_storage.json | 6 ++++++ platform/mv3/extension/popup.html | 2 +- 9 files changed, 80 insertions(+), 7 deletions(-) diff --git a/platform/mv3/extension/css/filtering-mode.css b/platform/mv3/extension/css/filtering-mode.css index fecb1ac3c..f6ed77831 100644 --- a/platform/mv3/extension/css/filtering-mode.css +++ b/platform/mv3/extension/css/filtering-mode.css @@ -13,7 +13,7 @@ border-radius: 30% 15% / 15% 30%; height: 100%; position: absolute; - width: 25%; + width: calc(25% + 2px); z-index: 10; } @@ -39,12 +39,18 @@ .filteringModeSlider span[data-level] { background-color: var(--accent-surface-1); + border: 1px solid var(--accent-surface-1); + box-sizing: border-box; display: inline-flex; height: 30%; margin-left: 1px; width: 25%; } +.filteringModeSlider span[data-level]:first-of-type { + margin-left: 0; + } + .filteringModeSlider.moving span[data-level] { pointer-events: none; } @@ -53,13 +59,13 @@ left: 0; } .filteringModeSlider[data-level="1"] .filteringModeButton { - left: 25%; + left: calc(25% - 1px); } .filteringModeSlider[data-level="2"] .filteringModeButton { - left: 50%; + left: calc(50% - 1px); } .filteringModeSlider[data-level="3"] .filteringModeButton { - left: 75%; + left: calc(75% - 1px); } [dir="rtl"] .filteringModeSlider[data-level="0"] .filteringModeButton { left: 75%; @@ -77,14 +83,17 @@ .filteringModeSlider[data-level="0"] span[data-level] { background-color: var(--surface-2); + border-color: var(--surface-2); } .filteringModeSlider[data-level="1"] span[data-level]:nth-of-type(1) ~ span[data-level] { background-color: var(--surface-2); + border-color: var(--surface-2); } .filteringModeSlider[data-level="2"] span[data-level]:nth-of-type(2) ~ span[data-level] { background-color: var(--surface-2); + border-color: var(--surface-2); } .filteringModeSlider[data-level]:not(.moving) span[data-level]:hover { diff --git a/platform/mv3/extension/css/popup.css b/platform/mv3/extension/css/popup.css index 385a05165..cc6824674 100644 --- a/platform/mv3/extension/css/popup.css +++ b/platform/mv3/extension/css/popup.css @@ -63,6 +63,13 @@ hr { font-weight: 600; } +body[data-forbid~="filteringMode"] .filteringModeSlider { + pointer-events: none; + } +body[data-forbid~="dashboard"] #gotoDashboard { + display: none; + } + #filteringModeText { color: var(--ink-3); margin: var(--default-gap-small); diff --git a/platform/mv3/extension/css/settings.css b/platform/mv3/extension/css/settings.css index fb5ba9151..feefcadd8 100644 --- a/platform/mv3/extension/css/settings.css +++ b/platform/mv3/extension/css/settings.css @@ -1,3 +1,6 @@ +body.loading { + visibility: hidden; + } body .firstRun { display: none; } @@ -13,6 +16,17 @@ p { white-space: pre-line; } +body[data-forbid~="dashboard"] #dashboard-nav [data-pane="settings"], +body[data-forbid~="dashboard"] section[data-pane="settings"], +body[data-forbid~="dashboard"] #dashboard-nav [data-pane="rulesets"], +body[data-forbid~="dashboard"] section[data-pane="rulesets"] { + display: none; + } +body[data-forbid~="filteringMode"] section[data-pane="settings"] > div:has(> h3[data-i18n="defaultFilteringModeSectionLabel"]), +body[data-forbid~="filteringMode"] section[data-pane="settings"] > div:has(> h3[data-i18n="filteringMode0Name"]) { + display: none; + } + #showBlockedCount:has(input[type="checkbox"][disabled]) { opacity: 0.5; } diff --git a/platform/mv3/extension/dashboard.html b/platform/mv3/extension/dashboard.html index c8442cabc..bcd1726bd 100644 --- a/platform/mv3/extension/dashboard.html +++ b/platform/mv3/extension/dashboard.html @@ -16,7 +16,7 @@ - +