-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
62 lines (56 loc) · 1.97 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
document.addEventListener('DOMContentLoaded',function(){
//twitter
document.getElementById("twitter").addEventListener('click',onclickTwitter,false)
function onclickTwitter(){
chrome.tabs.query({currentWindow:true,active:true},
function(tabs){
chrome.tabs.sendMessage(tabs[0].id,'twitter',setData)
})
}
function setData(res){
console.log(res);
for(i=0;i<res.len;i++){
const div=document.createElement('div');
const br=document.createElement('br');
div.textContent=`${res.count[i]}`
document.body.appendChild(div)
document.body.appendChild(br)
}
}
//facebook
document.getElementById("facebook").addEventListener('click',onclickFacebook,false)
function onclickFacebook(){
chrome.tabs.query({currentWindow:true,active:true},
function(tabs){
chrome.tabs.sendMessage(tabs[0].id,'facebook',setFbData)
})
}
function setFbData(res){
console.log(res);
for(i=0;i<res.len;i++){
const div=document.createElement('div');
const br=document.createElement('br');
div.textContent=`${res.count[i]}`
document.body.appendChild(div)
document.body.appendChild(br)
}
}
//linkedIn
document.getElementById("linkedin").addEventListener('click',onclickLi,false)
function onclickLi(){
chrome.tabs.query({currentWindow:true,active:true},
function(tabs){
chrome.tabs.sendMessage(tabs[0].id,'linkedin',setLiData)
})
}
function setLiData(res){
console.log(res);
for(i=0;i<res.len;i++){
const div=document.createElement('div');
const br=document.createElement('br');
div.textContent=`${res.count[i]}`
document.body.appendChild(div)
document.body.appendChild(br)
}
}
},false)