forked from ge-ku/Ban-Checker-for-Steam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetkey.js
44 lines (39 loc) · 1.3 KB
/
setkey.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
41
42
43
function save_options() {
var customapikey = document.getElementById('customapikey').value;
if(document.getElementById('radioCustom').checked && customapikey !== '') {
//use custom key
chrome.storage.sync.set({
customapikey: customapikey
}, function() {
// update status
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}else if(document.getElementById('radioDefault').checked || customapikey === '') {
//use default key
chrome.storage.sync.remove('customapikey', function() {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
document.getElementById('radioDefault').checked = true;
document.getElementById('customapikey').value = '';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
}
function restore_options() {
document.getElementById('save').addEventListener('click',
save_options);
chrome.storage.sync.get("customapikey", function(data) {
if (typeof data['customapikey'] == 'undefined'){
}else{
document.getElementById('customapikey').value = data['customapikey'];
document.getElementById('radioCustom').checked = true;
}
});
}
document.addEventListener('DOMContentLoaded', restore_options);