From 649b3480e083730e647043099a0f9aebaaa80d80 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 10 Jan 2021 12:31:31 -0500 Subject: [PATCH] Add "toOverwrite.filters" entry as managed storage property The new entry is an array of strings, each representing a distinct line, and all entries are used to populate the "My filters" pane. This offers an more straightforward way for administrators to specify a list of custom filters to use for all installations. --- platform/chromium/managed_storage.json | 6 ++++++ src/js/storage.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/chromium/managed_storage.json b/platform/chromium/managed_storage.json index fb58b2c61..7a334e241 100644 --- a/platform/chromium/managed_storage.json +++ b/platform/chromium/managed_storage.json @@ -41,6 +41,12 @@ "title": "Settings to overwrite at launch time", "type": "object", "properties": { + "filters": { + "title": "A collection of filters", + "description": "The set of user filters to use at launch time -- where each entry is a distinct line.", + "type": "array", + "items": { "type": "string" } + }, "filterLists": { "title": "A collection of list identifiers and/or list URLs", "description": "The set of filter lists to use at launch time.", diff --git a/src/js/storage.js b/src/js/storage.js index 7852c8f2a..59f3df9e2 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -1387,7 +1387,12 @@ self.addEventListener('hiddenSettingsChanged', ( ) => { vAPI.storage.set(bin); } - if ( typeof data.userFilters === 'string' ) { + if ( + Array.isArray(toOverwrite.filters) && + toOverwrite.filters.length !== 0 + ) { + this.saveUserFilters(toOverwrite.filters.join('\n')); + } else if ( typeof data.userFilters === 'string' ) { this.saveUserFilters(data.userFilters); } };