From 1641aeacfd160f2c902122f00394de5511324706 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 26 Dec 2017 15:47:36 -0800 Subject: [PATCH] AntiAutoplay: Only add 'display: block' if display is set to hidden. Also fix aspect ratio and remove redundancy. --- src/Miscellaneous/AntiAutoplay.coffee | 11 +++++++---- src/css/style.css | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Miscellaneous/AntiAutoplay.coffee b/src/Miscellaneous/AntiAutoplay.coffee index 3cdba9c34..7aec63f74 100644 --- a/src/Miscellaneous/AntiAutoplay.coffee +++ b/src/Miscellaneous/AntiAutoplay.coffee @@ -22,9 +22,12 @@ AntiAutoplay = process: (root) -> for iframe in $$ 'iframe[src*="youtube"][src*="autoplay=1"]', root - iframe.src = iframe.src.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '') - $.addClass iframe, 'autoplay-removed' + AntiAutoplay.processVideo iframe, 'src' for object in $$ 'object[data*="youtube"][data*="autoplay=1"]', root - object.data = object.data.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '') - $.addClass object, 'autoplay-removed' + AntiAutoplay.processVideo object, 'data' return + + processVideo: (el, attr) -> + el[attr] = el[attr].replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '') + el.style.display = 'block' if window.getComputedStyle(el).display is 'hidden' + $.addClass el, 'autoplay-removed' diff --git a/src/css/style.css b/src/css/style.css index 8561376fe..601258d41 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -156,10 +156,9 @@ audio.controls-added { text-align: center; } :root.anti-autoplay .autoplay-removed { - display: block !important; visibility: visible !important; min-width: 640px; - min-height: 390px; + min-height: 360px; } /* fixed, z-index */