-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
55 lines (52 loc) · 1.59 KB
/
background.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
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({color: '#3aa757'}, function() {
console.log('The color is green');
})
});
let initialSpeed = 1;
let mirrorStatus = 1;
let deg = 0;
chrome.commands.onCommand.addListener(function(command) {
console.log("Command", command);
if (command === 'toggle-speedUp') {
initialSpeed += .1;
initialSpeed = Math.round(initialSpeed * 10) / 10;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{file: 'speedUp.js'}
)
});
}
if (command === 'toggle-speedDown') {
initialSpeed -= .1;
initialSpeed = Math.round(initialSpeed * 10) / 10;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{file: 'speedDown.js'}
)
});
}
if (command === 'toggle-rotate90') {
deg -= 90
var c = 'document.getElementsByClassName("html5-video-player")[0].style.transform = "rotate('+deg.toString()+'deg)"';
console.log(c);
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{code: c}
)
});
}
if (command === 'toggle-mirror') {
mirrorStatus*=-1;
var c = 'document.getElementsByClassName("html5-video-player")[0].style.transform = "scalex('+mirrorStatus.toString()+')"';
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{code: c}
)
});
}
});