blob: 828eb22a444143145e8a1e47d94ce4d22dd8feed [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
Adrià Vilanova Martínezb523be92024-05-25 19:14:19 +020012import {isOptionEnabled} from '../common/options/optionsUtils.js';
Adrià Vilanova Martíneza4dd5fd2022-01-05 04:23:44 +010013
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}