diff --git a/CHANGELOG.md b/CHANGELOG.md index 865b8c6b5..ef766399d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,12 @@ Based on v1.9.14.2. - Bug fixes. +### v1.9.14.4 +*2014-12-08* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.4/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.4/builds/4chan-X-noupdate.crx "Chromium version")] + +**ccd0** +- Fix sounds sometimes playing for a short time before `Disable Autoplaying Sounds` halts them. + ### v1.9.14.3 *2014-12-07* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.3/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.14.3/builds/4chan-X-noupdate.crx "Chromium version")] 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'