From 8e651ff102c31e64f6f799a3e1c30a797f898640 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 9 May 2012 10:00:36 +0200 Subject: [PATCH] Fix #411. I always forget that Firefox is shit and doesn't let you select nodes in a logical order. --- 4chan_x.user.js | 2 +- script.coffee | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 126e2ed10..ff2557f03 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1287,7 +1287,7 @@ post.removeAttribute('tabindex'); rect = post.getBoundingClientRect(); if (rect.bottom >= 0 && rect.top <= d.documentElement.clientHeight) { - next = delta === +1 ? $.x('parent::div/following-sibling::div/div[contains(@class,"reply")]', post) : $.x('parent::div/preceding-sibling::div/div[contains(@class,"reply")]', post); + next = $.x('child::div[contains(@class,"post reply")]', delta === +1 ? post.parentNode.nextElementSibling : post.parentNode.previousElementSibling); if (!next) { this.focus(post); return; diff --git a/script.coffee b/script.coffee index f85b1f463..c6c061e85 100644 --- a/script.coffee +++ b/script.coffee @@ -968,11 +968,8 @@ Keybinds = post.removeAttribute 'tabindex' rect = post.getBoundingClientRect() if rect.bottom >= 0 and rect.top <= d.documentElement.clientHeight # We're at least partially visible - next = - if delta is +1 - $.x 'parent::div/following-sibling::div/div[contains(@class,"reply")]', post - else - $.x 'parent::div/preceding-sibling::div/div[contains(@class,"reply")]', post + next = $.x 'child::div[contains(@class,"post reply")]', + if delta is +1 then post.parentNode.nextElementSibling else post.parentNode.previousElementSibling unless next @focus post return