Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!