I want to make a Firefox add-on that would loop playing a sound when the user opens a certain website (e.g. mozilla.org). I've read that Firefox blocks autoplay until user interacts with a site (clicks on sth etc) so I decided to make a loop that would try to play the sound over and over again so eventually when user activates the site the sound starts playing. It doesn't work and i have no idea why. Nothing shows up in the console (theoretically there should be information about blocked autoplay).
json:
{
"manifest_version": 2,
"name": "Borderify",
"version": "1.0",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
"matches": [ "*://*.mozilla.org/*" ],
"js": [ "borderify.js" ]
}
]
}
js:
function sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
var audio = new Audio('airhorn.mp3');
while(true){
audio.play();
sleep(1000);
}