-
Notifications
You must be signed in to change notification settings - Fork 0
/
sahaaya.js
44 lines (42 loc) · 1.1 KB
/
sahaaya.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
var $ = function(elt) {
return document.querySelector(elt);
}
var _ = function(elt, command, fn) {
return elt.addEventListener(command, fn);
}
var Sahaaya = function() {
if (localStorage.getItem("serviceStatus") == "start") {
Sahaaya.startService();
} else {
Sahaaya.stopService();
}
}
Sahaaya.startService = function() {
localStorage.setItem("serviceStatus", "start");
$(".disabled").style.display = "none";
$(".enabled").style.display = "block";
$("body").classList.add("on");
chrome.browserAction.setIcon({path:" icon.png"});
chrome.storage.sync.set({
serviceStatus: "start"
});
}
Sahaaya.stopService = function() {
localStorage.setItem("serviceStatus", "stop");
$(".disabled").style.display = "block";
$(".enabled").style.display = "none";
$("body").classList.remove("on");
chrome.browserAction.setIcon({path:" icon-disabled.png"});
chrome.storage.sync.set({
serviceStatus: "stop"
});
}
_($("#enableSahaaya"), "click", function() {
Sahaaya.startService();
});
_($("#disableSahaaya"), "click", function() {
Sahaaya.stopService();
});
_(document, "DOMContentLoaded", function() {
Sahaaya();
});