diff --git a/files/assets/js/userpage.js b/files/assets/js/userpage.js index 780e553f6..344590b85 100644 --- a/files/assets/js/userpage.js +++ b/files/assets/js/userpage.js @@ -52,9 +52,29 @@ else } } +for (const video of document.getElementsByTagName('video')) +{ + video.addEventListener('play', (event) => { + if (!audio.paused) + { + audio.pause(); + } + }); +} + +for (const a of document.getElementsByTagName('audio')) +{ + a.addEventListener('play', (event) => { + if (!audio.paused) + { + audio.pause(); + } + }); +} + function badge_timestamp(t) { const date = new Date(t.dataset.until*1000); const text = t.getAttribute("data-bs-original-title") t.setAttribute("data-bs-original-title", `${text} ${date.toString()}`); t.removeAttribute("onmouseover") -} \ No newline at end of file +} diff --git a/files/templates/submission.html b/files/templates/submission.html index a2757d781..3d6116ca0 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -1165,6 +1165,26 @@ window.addEventListener('click', () => { if (audio.paused) audio.play(); }, {once : true}); + + for (const video of document.getElementsByTagName('video')) + { + video.addEventListener('play', (event) => { + if (!audio.paused) + { + audio.pause(); + } + }); + } + + for (const a of document.getElementsByTagName('audio')) + { + a.addEventListener('play', (event) => { + if (!audio.paused) + { + audio.pause(); + } + }); + } {% endif %}