-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
58 lines (49 loc) · 1.72 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
document.querySelector("#loop").addEventListener("click", loop, false);
document.querySelector("#start").addEventListener("click", start, false);
document.querySelector("#stop").addEventListener("click", stop, false);
document.querySelector("#end").addEventListener("click", end, false);
function loop() {
console.log("loop");
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, "loop");
})
}
function start() {
console.log("start");
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, "start");
})
}
function stop() {
console.log("stop");
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, "stop");
})
}
function end() {
console.log("end");
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, "end");
})
}
// document.addEventListener('DOMContentLoaded', function () {
// const bg = chrome.extension.getBackgroundPage()
// Object.keys(bg.bears).forEach(function (url) {
// const div = document.createElement('div')
// div.textContent = `${url}: ${bg.bears[url]}`
// document.body.appendChild(div)
// })
// document.querySelector('button').addEventListener('click', onclick, false)
//
// function onclick () {
// chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
// chrome.tabs.sendMessage(tabs[0].id, 'hi', setCount)
// })
// }
//
// function setCount (res) {
// const div = document.createElement('div')
// div.textContent = `${res.count} bears`
// document.body.appendChild(div)
// }
// }, false)