From c1cd50c2dc263aabc037994f4f40cefdae1fc642 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 20 Jun 2011 11:31:21 -0700 Subject: [PATCH] use switch --- 4chan_x.user.js | 11 ++++++++++- script.coffee | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 012c75e85..0e9522eed 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -576,7 +576,16 @@ return $.cache[pathname].abort(); case '-': a.textContent = a.textContent.replace('-', '+'); - num = g.BOARD === 'b' ? 3 : g.BOARD === 't' ? 1 : 5; + num = (function() { + switch (g.BOARD) { + case 'b': + return 3; + case 't': + return 1; + default: + return 5; + } + })(); table = $.x("following::br[@clear][1]/preceding::table[" + num + "]", a); while ((prev = table.previousSibling) && (prev.nodeName === 'TABLE')) { $.rm(prev); diff --git a/script.coffee b/script.coffee index 379c5dbed..ef9bb2d6f 100644 --- a/script.coffee +++ b/script.coffee @@ -400,7 +400,10 @@ expandThread = when '-' a.textContent = a.textContent.replace '-', '+' #goddamit moot - num = if g.BOARD is 'b' then 3 else if g.BOARD is 't' then 1 else 5 + num = switch g.BOARD + when 'b' then 3 + when 't' then 1 + else 5 table = $.x "following::br[@clear][1]/preceding::table[#{num}]", a while (prev = table.previousSibling) and (prev.nodeName is 'TABLE') $.rm prev