From 2049db860010949b43e4e507c631bcd7bc12c028 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 14 Dec 2011 12:17:11 +0100 Subject: [PATCH 1/3] Bit of cleaning. --- 4chan_x.user.js | 7 +++---- script.coffee | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index cbfc98cfb..b60f00b37 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -753,7 +753,7 @@ return 5; } })(); - table = $.x("following::br[@clear][1]/preceding::table[" + num + "]", a); + table = $.x("following::br[@clear]/preceding::table[" + num + "]", a); while ((prev = table.previousSibling) && (prev.nodeName === 'TABLE')) { $.rm(prev); } @@ -1605,7 +1605,7 @@ $('iframe[name=iframe]').src = 'about:blank'; fileCount = $('#files', qr.el).childElementCount; tc = data.textContent; - if (tc !== "Post successful!" && !/uploaded!$/.test(tc)) { + if (!/successful!|uploaded!$/.test(tc)) { if (tc === void 0) { data.textContent = "Connection error with sys.4chan.org."; } @@ -2417,8 +2417,7 @@ _ref = $$('.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; - if (!(qid = quote.hash.slice(1))) continue; - quotes[qid] = quote; + if (qid = quote.hash.slice(1)) quotes[qid] = quote; } id = $('input', root).name; a = $.el('a', { diff --git a/script.coffee b/script.coffee index b58abfb83..beefcba67 100644 --- a/script.coffee +++ b/script.coffee @@ -538,7 +538,7 @@ expandThread = when 'b' then 3 when 't' then 1 else 5 - table = $.x "following::br[@clear][1]/preceding::table[#{num}]", a + table = $.x "following::br[@clear]/preceding::table[#{num}]", a while (prev = table.previousSibling) and (prev.nodeName is 'TABLE') $.rm prev for backlink in $$ '.op a.backlink' @@ -1247,7 +1247,7 @@ qr = fileCount = $('#files', qr.el).childElementCount tc = data.textContent - if tc isnt "Post successful!" and not /uploaded!$/.test tc # error message + unless /successful!|uploaded!$/.test tc # error message, not a successful post if tc is undefined data.textContent = "Connection error with sys.4chan.org." $.extend $('#error', qr.el), data @@ -1915,9 +1915,9 @@ quoteBacklink = quotes = {} for quote in $$ '.quotelink', root #don't process >>>/b/ - continue unless qid = quote.hash[1..] - #duplicate quotes get overwritten - quotes[qid] = quote + if qid = quote.hash[1..] + #duplicate quotes get overwritten + quotes[qid] = quote # op or reply id = $('input', root).name a = $.el 'a', @@ -1997,7 +1997,7 @@ quoteInline = body = $.el 'body', innerHTML: req.responseText - if id == threadID #OP + if id is threadID #OP op = threading.op $('body > form', body).firstChild html = op.innerHTML else @@ -2062,7 +2062,7 @@ quotePreview = body = $.el 'body', innerHTML: req.responseText - if id == threadID #OP + if id is threadID #OP op = threading.op $('body > form', body).firstChild html = op.innerHTML else From 5e0f808e7170ec88227a0889df4f94420c6d193f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 14 Dec 2011 14:26:13 +0100 Subject: [PATCH 2/3] Fix quoting when selecting started from the end of a line on Firefox. This sounds really silly. --- 4chan_x.user.js | 2 +- changelog | 2 ++ script.coffee | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b60f00b37..1db1a0992 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1683,7 +1683,7 @@ text = ">>" + id + "\n"; selection = window.getSelection(); if (s = selection.toString()) { - selectionID = (_ref = $.x('ancestor::blockquote/preceding-sibling::input', selection.anchorNode)) != null ? _ref.name : void 0; + selectionID = (_ref = $.x('ancestor-or-self::blockquote/preceding-sibling::input', selection.anchorNode)) != null ? _ref.name : void 0; if (selectionID === id) { s = s.replace(/\n/g, '\n>'); text += ">" + s + "\n"; diff --git a/changelog b/changelog index ea7330a4a..3266202d4 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- mayhem + fix selection to quote when selecting started from the end of a line on Firefox 2.23.4 - mayhem diff --git a/script.coffee b/script.coffee index beefcba67..aa37759e8 100644 --- a/script.coffee +++ b/script.coffee @@ -1322,7 +1322,7 @@ qr = selection = window.getSelection() if s = selection.toString() - selectionID = $.x('ancestor::blockquote/preceding-sibling::input', selection.anchorNode)?.name + selectionID = $.x('ancestor-or-self::blockquote/preceding-sibling::input', selection.anchorNode)?.name if selectionID is id s = s.replace /\n/g, '\n>' text += ">#{s}\n" From eb8daa7b43eed20318b58370969bd75a0a53b380 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 14 Dec 2011 15:10:30 +0100 Subject: [PATCH 3/3] Single nav.init(). --- 4chan_x.user.js | 3 +-- script.coffee | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1db1a0992..cda86656f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3151,10 +3151,10 @@ if (conf['Quick Reply']) qr.init(); if (conf['Thread Watcher']) watcher.init(); if (conf['Keybinds']) keybinds.init(); + if (conf['Reply Navigation'] || conf['Index Navigation']) nav.init(); if (g.REPLY) { if (conf['Thread Updater']) updater.init(); if (conf['Thread Stats']) threadStats.init(); - if (conf['Reply Navigation']) nav.init(); if (conf['Post in Title']) titlePost.init(); if (conf['Unread Count']) unread.init(); if (conf['Quick Reply'] && conf['Persistent QR'] && canPost) { @@ -3165,7 +3165,6 @@ if (conf['Thread Hiding']) threadHiding.init(); if (conf['Thread Expansion']) expandThread.init(); if (conf['Comment Expansion']) expandComment.init(); - if (conf['Index Navigation']) nav.init(); } nodes = $$('.op, a + table'); _ref = g.callbacks; diff --git a/script.coffee b/script.coffee index aa37759e8..58e19d543 100644 --- a/script.coffee +++ b/script.coffee @@ -2498,6 +2498,9 @@ Main = if conf['Keybinds'] keybinds.init() + if conf['Reply Navigation'] or conf['Index Navigation'] + nav.init() + if g.REPLY if conf['Thread Updater'] updater.init() @@ -2505,9 +2508,6 @@ Main = if conf['Thread Stats'] threadStats.init() - if conf['Reply Navigation'] - nav.init() - if conf['Post in Title'] titlePost.init() @@ -2529,9 +2529,6 @@ Main = if conf['Comment Expansion'] expandComment.init() - if conf['Index Navigation'] - nav.init() - nodes = $$ '.op, a + table' for callback in g.callbacks