diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 67fce89fe..8e35fbb98 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -7596,7 +7596,7 @@ }); }, node: function() { - var thumb, _ref, _ref1; + var clone, thumb, _ref, _ref1; if (!(((_ref = this.file) != null ? _ref.isImage : void 0) || ((_ref1 = this.file) != null ? _ref1.isVideo : void 0))) { return; } @@ -7606,7 +7606,13 @@ ImageExpand.contract(this); return ImageExpand.expand(this); } else if (this.isClone && this.file.isExpanded && this.file.isVideo) { - return ImageExpand.setupVideoControls(this); + clone = this; + ImageExpand.setupVideoControls(clone); + if (!clone.origin.file.fullImage.paused) { + return $.queueTask(function() { + return ImageExpand.startVideo(clone); + }); + } } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) { return ImageExpand.expand(this); } @@ -7772,7 +7778,12 @@ $.rmClass(post.file.thumb, 'expanding'); post.file.isExpanded = true; if (post.file.isVideo) { - return ImageExpand.setupVideo(post); + ImageExpand.setupVideoControls(post); + post.file.fullImage.muted = !Conf['Allow Sound']; + post.file.fullImage.controls = Conf['Show Controls']; + if (Conf['Autoplay']) { + return ImageExpand.startVideo(post); + } } }, videoCB: { @@ -7829,25 +7840,21 @@ } return $.add(file.text, file.videoControls); }, - setupVideo: function(post) { - var file, video; - ImageExpand.setupVideoControls(post); + startVideo: function(post) { + var controls, file, video; file = post.file; video = file.fullImage; - video.muted = !Conf['Allow Sound']; - video.controls = Conf['Show Controls']; - if (Conf['Autoplay']) { - video.controls = false; - video.play(); - if (Conf['Show Controls']) { - return $.asap((function() { - return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded; - }), function() { - if (file.isExpanded) { - return video.controls = true; - } - }, 500); - } + controls = video.controls; + video.controls = false; + video.play(); + if (controls) { + return $.asap((function() { + return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded; + }), function() { + if (file.isExpanded) { + return video.controls = true; + } + }, 500); } }, error: function() { diff --git a/builds/crx/script.js b/builds/crx/script.js index f83466d20..d535e794d 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -7615,7 +7615,7 @@ }); }, node: function() { - var thumb, _ref, _ref1; + var clone, thumb, _ref, _ref1; if (!(((_ref = this.file) != null ? _ref.isImage : void 0) || ((_ref1 = this.file) != null ? _ref1.isVideo : void 0))) { return; } @@ -7625,7 +7625,13 @@ ImageExpand.contract(this); return ImageExpand.expand(this); } else if (this.isClone && this.file.isExpanded && this.file.isVideo) { - return ImageExpand.setupVideoControls(this); + clone = this; + ImageExpand.setupVideoControls(clone); + if (!clone.origin.file.fullImage.paused) { + return $.queueTask(function() { + return ImageExpand.startVideo(clone); + }); + } } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) { return ImageExpand.expand(this); } @@ -7791,7 +7797,12 @@ $.rmClass(post.file.thumb, 'expanding'); post.file.isExpanded = true; if (post.file.isVideo) { - return ImageExpand.setupVideo(post); + ImageExpand.setupVideoControls(post); + post.file.fullImage.muted = !Conf['Allow Sound']; + post.file.fullImage.controls = Conf['Show Controls']; + if (Conf['Autoplay']) { + return ImageExpand.startVideo(post); + } } }, videoCB: { @@ -7848,25 +7859,21 @@ } return $.add(file.text, file.videoControls); }, - setupVideo: function(post) { - var file, video; - ImageExpand.setupVideoControls(post); + startVideo: function(post) { + var controls, file, video; file = post.file; video = file.fullImage; - video.muted = !Conf['Allow Sound']; - video.controls = Conf['Show Controls']; - if (Conf['Autoplay']) { - video.controls = false; - video.play(); - if (Conf['Show Controls']) { - return $.asap((function() { - return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded; - }), function() { - if (file.isExpanded) { - return video.controls = true; - } - }, 500); - } + controls = video.controls; + video.controls = false; + video.play(); + if (controls) { + return $.asap((function() { + return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded; + }), function() { + if (file.isExpanded) { + return video.controls = true; + } + }, 500); } }, error: function() { diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 6c0a992d6..272557ce3 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -23,7 +23,10 @@ ImageExpand = ImageExpand.contract @ ImageExpand.expand @ else if @isClone and @file.isExpanded and @file.isVideo - ImageExpand.setupVideoControls @ + clone = @ + ImageExpand.setupVideoControls clone + unless clone.origin.file.fullImage.paused + $.queueTask -> ImageExpand.startVideo clone else if ImageExpand.on and !@isHidden and (Conf['Expand spoilers'] or !@file.isSpoiler) ImageExpand.expand @ cb: @@ -143,7 +146,11 @@ ImageExpand = $.addClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' post.file.isExpanded = true - ImageExpand.setupVideo post if post.file.isVideo + if post.file.isVideo + ImageExpand.setupVideoControls post + post.file.fullImage.muted = !Conf['Allow Sound'] + post.file.fullImage.controls = Conf['Show Controls'] + ImageExpand.startVideo post if Conf['Autoplay'] videoCB: click: (e) -> @@ -183,20 +190,17 @@ ImageExpand = $.add file.videoControls, [$.tn('\u00A0'), contract] $.add file.text, file.videoControls - setupVideo: (post) -> - ImageExpand.setupVideoControls post + startVideo: (post) -> {file} = post video = file.fullImage - video.muted = !Conf['Allow Sound'] - video.controls = Conf['Show Controls'] - if Conf['Autoplay'] - video.controls = false - video.play() - # Hacky workaround for Firefox forever-loading bug for very short videos - if Conf['Show Controls'] - $.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !file.isExpanded), -> - video.controls = true if file.isExpanded - , 500 + {controls} = video + video.controls = false + video.play() + # Hacky workaround for Firefox forever-loading bug for very short videos + if controls + $.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !file.isExpanded), -> + video.controls = true if file.isExpanded + , 500 error: -> post = Get.postFromNode @