-
Notifications
You must be signed in to change notification settings - Fork 2
/
bw.js
70 lines (54 loc) · 1.49 KB
/
bw.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var config = {
enable : 0,
total : 0,
interval : 5,
ignore_list: ''
}
$(document).ready(function(){
$("#btn_start").click(function(){
config.enable = 1;
config.interval = parseInt($("#interval").val());
if(config.interval == 0) {
alert("min interval is 1, default 5 seconds")
return;
}
$(this).attr("disabled","disabled");
$("#btn_stop").removeAttr("disabled");
config.ignore_list = $("#ta_ignore").val();
chrome.storage.sync.set({ignore_list: config.ignore_list, interval: config.interval});
set_status();
});
$("#btn_stop").click(function(){
config.enable = 0;
$(this).attr("disabled","disabled");
$("#btn_start").removeAttr("disabled");
set_status();
});
get_status();
});
function set_status(){
chrome.runtime.sendMessage({action: "set",
enable: config.enable,
ignore_list: config.ignore_list,
interval: config.interval
}, function(response){});
}
function get_status(){
var $b = $("#btn_start");
var $b1 = $("#btn_stop");
chrome.runtime.sendMessage({action: "get"}, function(response){
config.enable = response.enable;
config.ignore_list = response.ignore_list;
config.interval = response.interval;
if(config.interval < 1) { config.interval = 5; }
if (config.enable == 0){
$b.removeAttr("disabled");
$b1.attr("disabled","disabled");
} else {
$b.attr("disabled","disabled");
$b1.removeAttr("disabled");
}
$('#ta_ignore').val(config.ignore_list);
$('#interval').val(config.interval);
});
}