forked from Rob--W/cookie-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
38 lines (35 loc) · 976 Bytes
/
options.js
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
36
37
38
/* globals chrome */
/* jshint browser: true */
'use strict';
var autostart = document.getElementById('autostart');
autostart.onchange = function() {
var items = {
autostart: autostart.checked,
};
if (!chrome.storage) {
// Firefox 51-
chrome.storage.local.set(items);
return;
}
chrome.storage.sync.set(items, function() {
if (chrome.runtime.lastError) {
// Can happen in Firefox 52.
chrome.storage.local.set(items);
}
});
};
if (!chrome.storage.sync) {
// Firefox 51-.
chrome.storage.local.get('autostart', onGotStorage);
} else {
chrome.storage.sync.get('autostart', function(items) {
if (items) {
onGotStorage(items);
} else { // Can happen in Firefox 52.
chrome.storage.local.get('autostart', onGotStorage);
}
});
}
function onGotStorage(items) {
autostart.checked = !items || items.autostart !== false;
}