diff --git a/src/Miscellaneous/AntiAutoplay.coffee b/src/Miscellaneous/AntiAutoplay.coffee index ac309ab48..873aaf4f1 100644 --- a/src/Miscellaneous/AntiAutoplay.coffee +++ b/src/Miscellaneous/AntiAutoplay.coffee @@ -1,12 +1,13 @@ AntiAutoplay = init: -> return if !Conf['Disable Autoplaying Sounds'] - $.ready @ready + @stop audio for audio in $$ 'audio[autoplay]', doc + window.addEventListener 'loadstart', ((e) => @stop e.target), true - ready: -> - for audio in $$ 'audio[autoplay]' - audio.pause() - audio.autoplay = false - unless audio.controls - audio.controls = true - $.addClass audio, 'controls-added' + stop: (audio) -> + return unless audio.autoplay + audio.pause() + audio.autoplay = false + return if audio.controls + audio.controls = true + $.addClass audio, 'controls-added'