-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
48 lines (42 loc) · 1.21 KB
/
content.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
const interval = setInterval(() => {
const header = document.querySelector('._3auIg')
if (header) {
console.log(header)
clearInterval(interval)
const button = document.createElement('button')
button.innerHTML = '2x'
button.classList.add('twoTimesButtonOff')
header.appendChild(button)
document.addEventListener('mousemove', () => {
if (button.classList.contains('twoTimesButtonOn')) {
twoTimesSpeed()
} else {
oneTimeSpeed()
}
})
button.addEventListener('click', () => {
button.classList.toggle('twoTimesButtonOn') // troca a classe(fixa) para essa que passei e vice versa
if (button.classList.contains('twoTimesButtonOff')) {
twoTimesSpeed()
} else {
oneTimeSpeed()
}
})
function twoTimesSpeed () {
audios = document.querySelectorAll('audio')
console.log(audios)
audios.forEach((audio) => {
console.log(audio)
audio.playbackRate = 2
})
}
function oneTimeSpeed () {
audios = document.querySelectorAll('audio')
console.log(audios)
audios.forEach((audio) => {
console.log(audio)
audio.playbackRate = 1
})
}
}
}, 1000)