Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
Google Chrome Extensions Notification Sounds Returning DOM Error

I'm a bit new to this so if I'm missing some pertinent information I apologize.

I'm working on a Chrome Extension that uses the setInterval method to check an API and play a notification sound when a given change occurs. Right now I'm running into the error: DOMException: play() failed because the user didn't interact with the document first

I know this is something added in Chrome to prevent videos from autoplaying, I'm just wondering if there is anything I can do to get around this for the context of this extension.

content.js:

url = "https://queue.square-9.com/data/support-page.json";
//let myAudio = new Audio(chrome.runtime.getURL("coin.wav"));
var coin = new Audio("coin.wav");
//coin.crossOrigin = "anonymous";
let lastCount = 0;
let newCount = 0;

setInterval(function () {
  fetch(url)
    .then(function (resp) {
      return resp.json();
    })
    .then(function (data) {
      newCount = data.currentQueueCountiOS;
      console.log(data.currentQueueCountiOS);
      if (newCount > lastCount) {
        coin.play();
        console.log("New case in queue!");
      }
      lastCount = newCount;
    });
}, 5000);

manifest.josn:

{
    "manifest_version": 2,
    "name": "Square9 SalesForce Notifications",
    "version": "1.0.0",
    "content_scripts": [
        {
            "matches": ["https://na156.lightning.force.com/*"],
            "js": ["content.js"]
        }
    ],
    "icons": {"128": "icon_128.png"},
    "browser_action": {
        "default_icon": "icon.png",
        "default_pop": "popup.html"
    },
    "permissions": ["activeTab"],
    "web_accessible_resources": [
        "coin.wav"
    ]
}

Thank you in advance for any help.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda