From 5d0e950cdb71c19da86e1fdca70a337ac071b941 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 17 Dec 2016 18:33:03 -0600 Subject: [PATCH] Prevent video_with_sound posts from autoplaying when blacklisted. --- app/assets/javascripts/blacklists.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/blacklists.js b/app/assets/javascripts/blacklists.js index 88f3f0a18..72c48785e 100644 --- a/app/assets/javascripts/blacklists.js +++ b/app/assets/javascripts/blacklists.js @@ -43,9 +43,9 @@ if (match) { match.disabled = !match.disabled; if (match.disabled) { - $(e.target).addClass("blacklisted-active"); + Danbooru.Blacklist.post_hide(e.target); } else { - $(e.target).removeClass("blacklisted-active"); + Danbooru.Blacklist.post_unhide(e.target); } } Danbooru.Blacklist.apply(); @@ -121,7 +121,7 @@ if (post_count > 0) { Danbooru.Blacklist.post_hide(post); } else { - $(post).removeClass("blacklisted-active"); + Danbooru.Blacklist.post_unhide(post); } }); @@ -157,6 +157,22 @@ Danbooru.Blacklist.post_hide = function(post) { var $post = $(post); $post.addClass("blacklisted").addClass("blacklisted-active"); + + var $video = $post.find("video").get(0); + if ($video) { + $video.pause(); + $video.currentTime = 0; + } + } + + Danbooru.Blacklist.post_unhide = function(post) { + var $post = $(post); + $post.addClass("blacklisted").removeClass("blacklisted-active"); + + var $video = $post.find("video").get(0); + if ($video) { + $video.play(); + } } Danbooru.Blacklist.initialize_all = function() {