-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (44 loc) · 1.23 KB
/
index.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
console.log('%ciniciando whatsapp web audio speeder...', 'color: #97B4FF;');
let velocity = 1;
let audios = [];
function playAudios() {
audios.forEach(audio => {
audio.playbackRate = velocity;
audio.addEventListener("ratechange", e=>{
if(audio.playbackRate != velocity) {
audio.playbackRate = velocity;
}
})
});
}
document.addEventListener('play', (e) => {
_audios = document.querySelectorAll("audio");
_audios.forEach(audio=>{
if(!audios.includes(audio)) {
audios.push(audio);
}
})
playAudios();
}, true);
const interval = setInterval(() => {
const header = document.querySelector("header");
if (header) {
clearInterval(interval);
const btn = document.createElement('button');
btn.innerHTML = `1x`;
btn.style = styles;
header.appendChild(btn);
btn.addEventListener('click', () => {
if ((velocity += .5) >= 3.5) velocity = 1;
btn.innerHTML = `${velocity}x`;
playAudios();
})
}
}, 1000);
const styles = `
font-size: 16px;
font-family: Roboto, sans-serif;
padding: 8px;
font-weight: bold;
color: gray;
`