1
I’m creating a very simple extension in Chrome for Whatsapp Web to speed up the audio by 1.5x, but so far I’ve only been able to make the function run, and it keeps running until the page is reloaded. I’m trying to make sure that when I click again, the event stops and the audio returns to normal speed. But I don’t know how to end this event. Should I use async/await? Promises?
const interval = setInterval(() => {
const header = document.querySelector('._1QUKR')
if (header) {
console.log(header)
clearInterval(interval)
const button = document.createElement("button")
button.innerHTML = '1.5'
button.classList.add('twoTimesButton')
button.addEventListener('click', () => {
const audios = document.querySelectorAll('audio')
console.log(audios)
audios.forEach((audio) => {
console.log(audio)
audio.playbackRate = 1.5
})
button.addEventListener('click', function() {
audios.pause()
})
})
header.appendChild(button)
}
}, 1000)
I’m starting my studies in Javascript and I’ve already taken a good look at what there is of question here and I’ve seen a topic that really seems to be something very similar to what I’m needing, but I just couldn’t implement the same logic.
I implemented the changes and became really cool. Thanks!
– Dickson Melo