Update 'Disable Autoplaying Sounds' for Youtube videos.
This commit is contained in:
parent
60266a686d
commit
0b2603412f
@ -107,6 +107,12 @@ audio.controls-added {
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
:root.anti-autoplay div.embed {
|
||||
position: static;
|
||||
width: auto;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* fixed, z-index */
|
||||
#overlay,
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
AntiAutoplay =
|
||||
init: ->
|
||||
return if !Conf['Disable Autoplaying Sounds']
|
||||
$.addClass doc, 'anti-autoplay'
|
||||
@stop audio for audio in $$ 'audio[autoplay]', doc
|
||||
window.addEventListener 'loadstart', ((e) => @stop e.target), true
|
||||
Post.callbacks.push
|
||||
name: 'Disable Autoplaying Sounds'
|
||||
cb: @node
|
||||
$.ready => @stopYoutube d.body
|
||||
|
||||
stop: (audio) ->
|
||||
return unless audio.autoplay
|
||||
@ -11,3 +16,10 @@ AntiAutoplay =
|
||||
return if audio.controls
|
||||
audio.controls = true
|
||||
$.addClass audio, 'controls-added'
|
||||
|
||||
node: ->
|
||||
AntiAutoplay.stopYoutube @nodes.root
|
||||
|
||||
stopYoutube: (root) ->
|
||||
for iframe in $$ 'iframe[src*="youtube"][src*="autoplay=1"]', root
|
||||
iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user