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;
|
display: block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
:root.anti-autoplay div.embed {
|
||||||
|
position: static;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/* fixed, z-index */
|
/* fixed, z-index */
|
||||||
#overlay,
|
#overlay,
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
AntiAutoplay =
|
AntiAutoplay =
|
||||||
init: ->
|
init: ->
|
||||||
return if !Conf['Disable Autoplaying Sounds']
|
return if !Conf['Disable Autoplaying Sounds']
|
||||||
|
$.addClass doc, 'anti-autoplay'
|
||||||
@stop audio for audio in $$ 'audio[autoplay]', doc
|
@stop audio for audio in $$ 'audio[autoplay]', doc
|
||||||
window.addEventListener 'loadstart', ((e) => @stop e.target), true
|
window.addEventListener 'loadstart', ((e) => @stop e.target), true
|
||||||
|
Post.callbacks.push
|
||||||
|
name: 'Disable Autoplaying Sounds'
|
||||||
|
cb: @node
|
||||||
|
$.ready => @stopYoutube d.body
|
||||||
|
|
||||||
stop: (audio) ->
|
stop: (audio) ->
|
||||||
return unless audio.autoplay
|
return unless audio.autoplay
|
||||||
@ -11,3 +16,10 @@ AntiAutoplay =
|
|||||||
return if audio.controls
|
return if audio.controls
|
||||||
audio.controls = true
|
audio.controls = true
|
||||||
$.addClass audio, 'controls-added'
|
$.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