Have 'Disable Autoplaying Sounds' stop <marquee> too.

This commit is contained in:
ccd0 2014-12-15 20:47:15 -08:00
parent 0b2603412f
commit dd62735fc1
3 changed files with 11 additions and 4 deletions

View File

@ -103,7 +103,7 @@ Config =
]
'Disable Autoplaying Sounds': [
false
'Prevent sounds on the page from autoplaying.'
'Stop autoplaying sounds and other annoyances.'
]
'Linkification':

View File

@ -113,6 +113,9 @@ audio.controls-added {
height: auto;
text-align: center;
}
:root.anti-autoplay marquee {
visibility: hidden;
}
/* fixed, z-index */
#overlay,

View File

@ -7,7 +7,7 @@ AntiAutoplay =
Post.callbacks.push
name: 'Disable Autoplaying Sounds'
cb: @node
$.ready => @stopYoutube d.body
$.ready => @process d.body
stop: (audio) ->
return unless audio.autoplay
@ -18,8 +18,12 @@ AntiAutoplay =
$.addClass audio, 'controls-added'
node: ->
AntiAutoplay.stopYoutube @nodes.root
AntiAutoplay.process @nodes.root
stopYoutube: (root) ->
process: (root) ->
for iframe in $$ 'iframe[src*="youtube"][src*="autoplay=1"]', root
iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '')
for marquee in $$ 'marquee', root
span = $.el 'span', className: 'removed-marquee'
$.replace marquee, span
$.add span, [marquee.childNodes...]