This repository was archived by the owner on Jan 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (32 loc) · 1.33 KB
/
background.js
File metadata and controls
35 lines (32 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
function doNative(whenToHideTitleBar) {
browser.runtime.sendNativeMessage("hide_title_bar",
{whenToHideTitleBar: whenToHideTitleBar}).then(response => {
if ("okay" in response && response.okay) {
browser.storage.local.set({errorText: "NO_ERROR"});
} else if ("knownFailure" in response) {
browser.storage.local.set({errorText: "KNOWN_FAILURE:" + response.knownFailure});
} else if ("unknownFailure" in response) {
browser.storage.local.set({errorText: "UNKNOWN_FAILURE:" + response.unknownFailure});
} else {
browser.storage.local.set({errorText: "RESPONSE_NOT_UNDERSTOOD:" +
JSON.stringify(response));
console.log(response);
}
}, failure => {
browser.storage.local.set({errorText: "NO_RESPONSE"});
console.log(failure);
});
}
browser.storage.local.get({ whenToHideTitleBar: "always" }).then(
prefs => doNative(prefs.whenToHideTitleBar));
browser.storage.onChanged.addListener((changes, areaName) => {
if (areaName !== "local") return;
if ("whenToHideTitleBar" in changes) {
doNative(changes.whenToHideTitleBar.newValue);
}
});