-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopUp.js
66 lines (58 loc) · 2.03 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
document.addEventListener('DOMContentLoaded', function () {
//firstly enquire the current speed of video playback
let params={
active:true,
currentWindow:true
}
chrome.tabs.query(params,gotTabs);
//sending message to content script
function gotTabs(tabs){
let msg={
type:"ENQUIRE_SPEED"
}
chrome.tabs.sendMessage(tabs[0].id,msg,function(response){
document.getElementById("playbackspeed").innerHTML=response.playbackspeed;
});
}
var increment_btn = document.getElementById('increment');
increment_btn.addEventListener('click', function() {
var currentSpeed=parseFloat(document.getElementById("playbackspeed").innerText);
currentSpeed+=0.1;
currentSpeed=currentSpeed.toFixed(1);
document.getElementById("playbackspeed").innerHTML=currentSpeed;
let params={
active:true,
currentWindow:true
}
chrome.tabs.query(params,gotTabs);
//sending message to content script
function gotTabs(tabs){
let msg={
type:"CHANGE_SPEED",
speed:currentSpeed
}
chrome.tabs.sendMessage(tabs[0].id,msg);
}
});
var decrement_btn = document.getElementById('decrement');
decrement_btn.addEventListener('click', function() {
var currentSpeed=parseFloat(document.getElementById("playbackspeed").innerText);
currentSpeed-=0.1;
currentSpeed=currentSpeed.toFixed(1);
currentSpeed=(currentSpeed<0.5)?0.5:currentSpeed;
document.getElementById("playbackspeed").innerHTML=currentSpeed;
let params={
active:true,
currentWindow:true
}
chrome.tabs.query(params,gotTabs);
//sending message to content script
function gotTabs(tabs){
let msg={
type:"CHANGE_SPEED",
speed:currentSpeed
}
chrome.tabs.sendMessage(tabs[0].id,msg);
}
});
});