2 years ago
#60941

Leon
Uncaught ReferenceError: Audio is not defined in Chrome Extension JS Script
I'm trying to create a local script that loads a specific page, checks for contents and plays an audio if something is found but as soon as I load the extension in the dev mode it keeps saying "Uncaught ReferenceError: Audio is not defined"...
This is the code of the script:
chrome.tabs.create({ url: "URL"});
var snd = new Audio('https://www.soundjay.com/misc/sounds/bell-ringing-04.mp3');
var res = document.querySelector('[colspan="10"]');
if (res == null) {
snd.play();
chrome.tabs.create({ url: "URL"});
chrome.tabs.getCurrent(function(tab) {
chrome.tabs.remove(tab.id, function() { });
});
}
Some explanations: the page I'm loading contains a list of to-do tasks. What I'm doing in the script is simply check if that list exists: if it does than there's no task, if it does not than the alert is played cause there's something to do (I know the logic is upside-down but blame it on the website creator xD).
Any suggestion?
javascript
google-chrome-extension
web-audio-api
0 Answers
Your Answer