Member-only story

How to click anywhere on the browser to play the audio

Marika Lam
1 min readSep 30, 2022

--

Here is a script I wrote for the user to click anywhere on the screen to play the audio on your page. This is a script I wrote for AnkiWeb (link).

// ==UserScript==
// @name Click anywhere on browser to play sound
// @namespace https://stay.app/
// @version 0.1
// @description Template userscript created by Stay
// @author MKL
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
setTimeout(
function () {
document.addEventListener('click', audioPlay);
function audioPlay() {
const audio = document.querySelector("audio");
if (audio.paused) {
audio.play();
}else{
audio.currentTime = 0
}
}
},
1000
);
})();

Amazon Links to “Must-Haves” as a WFH Software Engineer 🙂💻

24-inch budget-friendly monitor, Portable monitor, Laptop stand, Waterproof desk mat, Keyboard cleaning gel, Six-outlet wall charger and surge protector,, Wi-Fi extender, Blue-light–blocking glasses, Memory foam gel pad, Foam footrest

Courses to learn more about datastructures/algorithms ✍️

Stanford, Duke, UCSD

Courses to learn more about databases 👓

DB Foundations, Data Scientists specialization

Courses to learn more about React 🧢

Full-Stack WebDev, Front-End WebDev with React, IBM Full Stack

--

--

No responses yet