Stop autoplaying sounds without waiting for DOM to load.
This commit is contained in:
parent
878b77b4dc
commit
974a125cff
@ -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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user