diff --git a/extension/common.js b/extension/common.js
index 98b3e4c..2f56a73 100644
--- a/extension/common.js
+++ b/extension/common.js
@@ -18,21 +18,19 @@ chrome.tabs.onCreated.addListener(tab => {
});
const prefs = {
- ua: '',
- blacklist: [],
- whitelist: [],
- custom: {},
- siblings: {
- 'www.google.com': 0,
- 'www.youtube.com': 0
- }, // a list of domains that are considered siblings (use same index for all)
- mode: 'blacklist',
- color: '#777',
- cache: true,
- exactMatch: false,
- protected: ['google.com/recaptcha', 'gstatic.com/recaptcha'],
- parser: {}, // maps ua string to a ua object,
- log: false
+ 'ua': '',
+ 'blacklist': [],
+ 'whitelist': [],
+ 'custom': {},
+ 'siblings': {}, // a list of domains that are considered siblings (use same index for all)
+ 'mode': 'blacklist',
+ 'color': '#777',
+ 'cache': true,
+ 'exactMatch': false,
+ 'protected': ['google.com/recaptcha', 'gstatic.com/recaptcha'],
+ 'parser': {}, // maps ua string to a ua object,
+ 'log': false,
+ 'json-guid': 'na'
};
window.prefs = prefs; // access from popup
@@ -91,11 +89,29 @@ chrome.storage.local.get(prefs, ps => {
// update prefs.ua from the managed storage
try {
chrome.storage.managed.get({
- ua: ''
+ 'ua': '',
+ 'json': ''
}, rps => {
- if (!chrome.runtime.lastError && rps.ua) {
- chrome.storage.local.set({
- ua: rps.ua
+ if (!chrome.runtime.lastError) {
+ const p = {};
+ if (rps.json) {
+ try {
+ const j = JSON.parse(rps.json);
+ if (prefs['json-guid'] !== j['json-guid'] || j['json-forced']) {
+ Object.assign(p, j);
+ console.warn('preferences are updated by an admin');
+ }
+ }
+ catch (e) {
+ console.warn('cannot parse remote JSON', e);
+ }
+ }
+ if (rps.ua) {
+ p.ua = rps.ua;
+ console.warn('user-agent string is updated by an admin');
+ }
+ chrome.storage.local.set(p, () => {
+ ua.update(undefined, undefined, DCSI);
});
}
else {
diff --git a/extension/data/options/index.css b/extension/data/options/index.css
index f4d56ce..890d673 100644
--- a/extension/data/options/index.css
+++ b/extension/data/options/index.css
@@ -101,3 +101,9 @@ textarea {
grid-template-columns: 1fr 1fr;
}
}
+.admin {
+ background-color: #ffffed;
+ border: solid 1px #e8ec3a;
+ padding: 10px;
+ margin: 15px 0;
+}
diff --git a/extension/data/options/index.html b/extension/data/options/index.html
index 436290f..e327e13 100644
--- a/extension/data/options/index.html
+++ b/extension/data/options/index.html
@@ -60,12 +60,13 @@
Sibling Hostnames
Description
-
A JSON array that contains one or more groups of hostnames to have a single user-agent string per group for the "Custom Mode". For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press here to insert a sample JSON array.
+
A JSON array that contains one or more groups of hostnames to have a single user-agent string per group. For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press here to insert a sample JSON array.
+
This extension supports managed storage. All the preferences can be pre-configured by the domain administrator