This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
popup.js
76 lines (67 loc) · 2.28 KB
/
popup.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
71
72
73
74
75
console.log("POPUP Script in Action!");
load();
let bgpage = chrome.extension.getBackgroundPage();
if (bgpage.word == "Page being used is ZOOM"){
document.getElementById("time_div").style.display = "none";
}
let params= {
active: true,
currentWindow: true
}
var config = 0;
function load() {
chrome.storage.local.get('given_len', function (result) {
rollno_len1 = result.given_len;
//alert(result.given_len);
var elem = document.querySelector('#rolllen');
if(rollno_len1 != undefined){
elem.setAttribute("placeholder",rollno_len1);
elem.setAttribute("value",rollno_len1);
}
});
}
window.onload=function(){
document.getElementById("myBtn").addEventListener("click", function(){
buttonClicked();
save();
});
document.getElementById("add_sname").addEventListener("click",function(){
console.log("clicked on Add Name checkbox");
});
document.getElementById("add_time").addEventListener("click",function(){
console.log("clicked on Add Name checkbox");
});
function buttonClicked(){
var data = [];
var rollno_len = Number((document.getElementById("rolllen").value));
var sname = document.getElementById("add_sname");
var time = document.getElementById("add_time");
console.log("buttonCicked");
data.push(rollno_len);
chrome.tabs.query(params,doIt);
if (sname.checked == true || time.checked == true){
if (sname.checked == true && time.checked == true){
data.push(4);
}else{
if(sname.checked==true){
data.push(2);
}else{
data.push(3);
}
}
}else{data.push(1);}
console.log(data);
function doIt(tabs){
chrome.tabs.sendMessage(tabs[0].id,data);
}
}
function save(){
var rollno_len1 = Number((document.getElementById("rolllen").value));
var sname = document.getElementById("add_sname");
var time = document.getElementById("add_time");
chrome.storage.local.set({'given_len': rollno_len1},function(){
//alert(rollno_len1);
load();
});
}
}