diff --git a/LICENSE b/LICENSE index 0e9931518..d88c9e07f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.8 - 2013-05-20 +* 4chan X - Version 1.2.8 - 2013-05-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 9250baccc..3096e7ad5 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.8 - 2013-05-20 +* 4chan X - Version 1.2.8 - 2013-05-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -6184,7 +6184,7 @@ } }, toggle: function(post) { - var headRect, rect, root, thumb, top; + var headRect, node, rect, root, thumb, top; thumb = post.file.thumb; if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { @@ -6192,7 +6192,21 @@ return; } ImageExpand.contract(post); - rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); + node = post.nodes.root; + rect = Conf['Advance on contract'] ? (function() { + while (node.nextElementSibling) { + if (!(node = node.nextElementSibling)) { + return post.nodes.root; + } + if (!$.hasClass(node, 'postContainer')) { + continue; + } + if (node.offsetHeight > 0 && !$('.stub', node)) { + break; + } + } + return node.getBoundingClientRect(); + })() : post.nodes.root.getBoundingClientRect(); if (!(rect.top <= 0 || rect.left <= 0)) { return; } diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f1a63aa79..46908d328 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.8 - 2013-05-20 +* 4chan X - Version 1.2.8 - 2013-05-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -6193,7 +6193,7 @@ } }, toggle: function(post) { - var headRect, rect, root, thumb, top; + var headRect, node, rect, root, thumb, top; thumb = post.file.thumb; if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { @@ -6201,7 +6201,21 @@ return; } ImageExpand.contract(post); - rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); + node = post.nodes.root; + rect = Conf['Advance on contract'] ? (function() { + while (node.nextElementSibling) { + if (!(node = node.nextElementSibling)) { + return post.nodes.root; + } + if (!$.hasClass(node, 'postContainer')) { + continue; + } + if (node.offsetHeight > 0 && !$('.stub', node)) { + break; + } + } + return node.getBoundingClientRect(); + })() : post.nodes.root.getBoundingClientRect(); if (!(rect.top <= 0 || rect.left <= 0)) { return; } diff --git a/builds/crx/script.js b/builds/crx/script.js index 90197d1f0..ec7d0027c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.2.8 - 2013-05-20 +* 4chan X - Version 1.2.8 - 2013-05-21 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -6171,7 +6171,7 @@ } }, toggle: function(post) { - var headRect, rect, root, thumb, top; + var headRect, node, rect, root, thumb, top; thumb = post.file.thumb; if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { @@ -6179,7 +6179,21 @@ return; } ImageExpand.contract(post); - rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); + node = post.nodes.root; + rect = Conf['Advance on contract'] ? (function() { + while (node.nextElementSibling) { + if (!(node = node.nextElementSibling)) { + return post.nodes.root; + } + if (!$.hasClass(node, 'postContainer')) { + continue; + } + if (node.offsetHeight > 0 && !$('.stub', node)) { + break; + } + } + return node.getBoundingClientRect(); + })() : post.nodes.root.getBoundingClientRect(); if (!(rect.top <= 0 || rect.left <= 0)) { return; } diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index c711a7627..7fef8b63e 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -68,8 +68,14 @@ ImageExpand = ImageExpand.expand post return ImageExpand.contract post - rect = if Conf['Advance on contract'] and !($.hasClass doc, 'fappeTyme') - post.nodes.root.nextSibling.getBoundingClientRect() + node = post.nodes.root + rect = if Conf['Advance on contract'] then do -> + # FIXME does not work with Quote Threading + while node.nextElementSibling + return post.nodes.root unless node = node.nextElementSibling + continue unless $.hasClass node, 'postContainer' + break if node.offsetHeight > 0 and not $ '.stub', node + node.getBoundingClientRect() else post.nodes.root.getBoundingClientRect() return unless rect.top <= 0 or rect.left <= 0