0

Javascript does not play sound in Tampermonkey script.

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.google.com/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
        var audio = new Audio('https://www.freesound.org/data/previews/256/256458_4772965-lq.mp3');
        audio.play();
        alert('hi!');
})();

The script shows alert but does not play sound. Tried both in Chrome and Safari - no sound! At the same time the same code included in HTML file plays sound.

Artem Kulakov
  • 29
  • 1
  • 5

0 Answers0