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': [ 'Disable Autoplaying Sounds': [
false false
'Prevent sounds on the page from autoplaying.' 'Stop autoplaying sounds and other annoyances.'
] ]
'Linkification': 'Linkification':

View File

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

View File

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