diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index f2b043a66..ce4cae17c 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -269,7 +269,11 @@ Keybinds = key post: (thread) -> - $('.post.highlight', thread) or $('.op', thread) + s = g.SITE.selectors + ( + $("#{s.postContainer}#{s.highlightable.reply}.#{g.SITE.classes.highlight}", thread) or + $("#{if g.SITE.isOPContainerThread then s.thread else s.postContainer}#{s.highlightable.op}", thread) + ) qr: (thread) -> QR.open() @@ -318,33 +322,35 @@ Keybinds = location.href = url hl: (delta, thread) -> - postEl = $ '.reply.highlight', thread + replySelector = "#{g.SITE.selectors.postContainer}#{g.SITE.selectors.highlightable.reply}" + {highlight} = g.SITE.classes + + postEl = $ "#{replySelector}.#{highlight}", thread unless delta - $.rmClass postEl, 'highlight' if postEl + $.rmClass postEl, highlight if postEl return if postEl {height} = postEl.getBoundingClientRect() if Header.getTopOf(postEl) >= -height and Header.getBottomOf(postEl) >= -height # We're at least partially visible - root = postEl.parentNode + {root} = Get.postFromNode(postEl).nodes axis = if delta is +1 'following' else 'preceding' - return if not (next = $.x "#{axis}-sibling::div[contains(@class,'replyContainer') and not(@hidden) and not(child::div[@class='stub'])][1]/child::div[contains(@class,'reply')]", root) + return unless (next = $.x "#{axis}-sibling::#{g.SITE.xpath.replyContainer}[not(@hidden) and not(child::div[@class='stub'])][1]", root) + next = $ replySelector, next unless next.matches(replySelector) Header.scrollToIfNeeded next, delta is +1 - @focus next - $.rmClass postEl, 'highlight' + $.addClass next, highlight + $.rmClass postEl, highlight return - $.rmClass postEl, 'highlight' + $.rmClass postEl, highlight - replies = $$ '.reply', thread + replies = $$ replySelector, thread replies.reverse() if delta is -1 for reply in replies if delta is +1 and Header.getTopOf(reply) > 0 or delta is -1 and Header.getBottomOf(reply) > 0 - @focus reply + $.addClass reply, highlight return - - focus: (post) -> - $.addClass post, 'highlight' + return diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee index 948a7729c..74aea824e 100644 --- a/src/site/SW.tinyboard.coffee +++ b/src/site/SW.tinyboard.coffee @@ -110,9 +110,13 @@ SW.tinyboard = prev: '.pages > form > [value=Previous]' next: '.pages > form > [value=Next]' + classes: + highlight: 'highlighted' + xpath: - thread: 'div[starts-with(@id,"thread_")]' - postContainer: 'div[starts-with(@id,"reply_") or starts-with(@id,"thread_")]' + thread: 'div[starts-with(@id,"thread_")]' + postContainer: 'div[starts-with(@id,"reply_") or starts-with(@id,"thread_")]' + replyContainer: 'div[starts-with(@id,"reply_")]' regexp: quotelink: diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index 2cc8160d0..d9af44255 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -75,9 +75,13 @@ SW.yotsuba = prev: '.prev > form > [type=submit]' next: '.next > form > [type=submit]' + classes: + highlight: 'highlight' + xpath: - thread: 'div[contains(concat(" ",@class," ")," thread ")]' - postContainer: 'div[contains(@class,"postContainer")]' + thread: 'div[contains(concat(" ",@class," ")," thread ")]' + postContainer: 'div[contains(@class,"postContainer")]' + replyContainer: 'div[contains(@class,"replyContainer")]' regexp: quotelink: