From 3b623a74bfb3f1e04f8cbc77dceccb545b7d955f Mon Sep 17 00:00:00 2001 From: tilpner Date: Sun, 17 May 2020 20:44:16 +0200 Subject: Use managed policy for default settings, if available --- src/bg/main.js | 12 +++++++++--- src/managed_storage.json | 11 +++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/managed_storage.json (limited to 'src') diff --git a/src/bg/main.js b/src/bg/main.js index d220274..919c971 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -42,9 +42,15 @@ if (policyData && policyData.DEFAULT) { ns.policy = new Policy(policyData); } else { - await include("/legacy/Legacy.js"); - ns.policy = await Legacy.createOrMigratePolicy(); - await ns.savePolicy(); + let managedData = await Storage.get("managed", "defaultSettings"); + if (managedData != null) { + let defaultSettings = JSON.parse(managedData.defaultSettings); + ns.policy = new Policy(defaultSettings.policy); + } else { + await include("/legacy/Legacy.js"); + ns.policy = await Legacy.createOrMigratePolicy(); + await ns.savePolicy(); + } } Sites.onionSecure = ns.local.isTorBrowser; diff --git a/src/managed_storage.json b/src/managed_storage.json new file mode 100644 index 0000000..8243fe0 --- /dev/null +++ b/src/managed_storage.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-03/schema#", + "type": "object", + "properties": { + "defaultSettings": { + "title": "A valid JSON string compliant with NoScripts's backup format.", + "description": "All entries present will overwrite local settings.", + "type": "string" + } + } +} -- cgit v1.2.3