forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
40 lines (37 loc) · 1.24 KB
/
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
39
40
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function createForm() {
chrome.storage.sync.get(['removedContextMenu'], function(list) {
let removed = list.removedContextMenu || [];
let form = document.getElementById('form');
for (let key of Object.keys(kLocales)) {
let div = document.createElement('div');
let checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.checked = true;
if (removed.includes(key)) {
checkbox.checked = false;
}
checkbox.name = key;
checkbox.value = kLocales[key];
let span = document.createElement('span');
span.textContent = kLocales[key];
div.appendChild(checkbox);
div.appendChild(span);
form.appendChild(div);
}
});
}
createForm();
document.getElementById('optionsSubmit').onclick = function() {
let checkboxes = document.getElementsByTagName('input');
let removed = [];
for (i=0; i<checkboxes.length; i++) {
if (checkboxes[i].checked == false) {
removed.push(checkboxes[i].name);
}
}
chrome.storage.sync.set({removedContextMenu: removed});
window.close();
}