blob: 52f0d1074f77353b0cc5d1346c716a1e69863030 [file] [log] [blame]
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +01001// Most options are dynamic, which means whenever they are enabled or disabled,
2// the effect is immediate. However, some features aren't controlled directly in
3// content scripts or injected scripts but instead in the background
4// script/service worker.
5//
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +02006// An example was the "blockdrafts" feature, which when enabled enabled the
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +01007// static ruleset blocking *DraftMessages requests.
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +02008//
9// The "blockdrafts" feature was removed, but this logic has been kept in case
10// it is needed in the future.
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +010011
12import {isOptionEnabled} from '../common/optionsUtils.js';
13
14// List of features controled in the background:
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +020015export var bgFeatures = [];
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +010016
17export function handleBgOptionChange(feature) {
18 isOptionEnabled(feature)
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +020019 // eslint-disable-next-line no-unused-vars
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +010020 .then(enabled => {
Adrià Vilanova Martínez879d44a2024-05-17 15:30:03 +020021 // eslint-disable-next-line no-empty
22 switch (feature) {}
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +010023 })
24 .catch(err => {
25 console.error(
26 'handleBgOptionChange: error while handling feature "' + feature +
27 '": ',
28 err);
29 });
30}
31
32export function handleBgOptionsOnStart() {
33 for (let feature of bgFeatures) handleBgOptionChange(feature);
34}