diff --git a/src/General/css/style.css b/src/General/css/style.css index c0d90b3cd..a4c4f7307 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -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, diff --git a/src/Miscellaneous/AntiAutoplay.coffee b/src/Miscellaneous/AntiAutoplay.coffee index 873aaf4f1..f9b0d491b 100644 --- a/src/Miscellaneous/AntiAutoplay.coffee +++ b/src/Miscellaneous/AntiAutoplay.coffee @@ -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', '')