From 43617c6db9214d438e4ba4c684fde75bfdb3d520 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 15:54:07 +0200 Subject: [PATCH 1/4] Start work for watch thread on reply. --- 4chan_x.js | 11 ++++++++--- script.coffee | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 52243900f..095214714 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -91,7 +91,8 @@ 'Thread Navigation': [true, 'Navigate to previous / next thread'], 'Thread Updater': [true, 'Update threads'], 'Thread Watcher': [true, 'Bookmark threads'], - 'Unread Count': [true, 'Show unread post count in tab title'] + 'Unread Count': [true, 'Show unread post count in tab title'], + 'Watch on Reply': [false, 'Automatically watch threads you reply to'] }, textarea: { flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n') @@ -1022,9 +1023,13 @@ return _results; }, submit: function(e) { - var form, isQR, recaptcha, span; + var form, isQR, recaptcha, span, value; form = e.target; isQR = form.parentNode.id === 'qr'; + if ($.config('Watch on Reply') && $.config('Thread Watcher')) { + value = g.THREAD_ID || $('input[name=resto]').value; + watcher.watch(null, value); + } if (isQR) { if (span = this.nextSibling) { $.remove(span); @@ -1113,7 +1118,7 @@ }, cooldownStart: function(duration) { var submit, submits, _i, _len; - submits = $$('#qr input[type=submit], form[name=post] input[type=submit]'); + submits = $$('#com_submit'); for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; submit.value = duration; diff --git a/script.coffee b/script.coffee index 87f00f59c..75d486949 100644 --- a/script.coffee +++ b/script.coffee @@ -36,6 +36,7 @@ config = 'Thread Updater': [true, 'Update threads'] 'Thread Watcher': [true, 'Bookmark threads'] 'Unread Count': [true, 'Show unread post count in tab title'] + 'Watch on Reply': [false, 'Automatically watch threads you reply to'] textarea: flavors: [ 'http://regex.info/exif.cgi?url=' @@ -774,6 +775,10 @@ qr = form = e.target isQR = form.parentNode.id == 'qr' + if $.config('Watch on Reply') and $.config('Thread Watcher') + value = g.THREAD_ID or $('input[name=resto]').value + watcher.watch null, value + if isQR if span = @nextSibling $.remove span @@ -854,7 +859,7 @@ qr = return true cooldownStart: (duration) -> - submits = $$ '#qr input[type=submit], form[name=post] input[type=submit]' + submits = $$ '#com_submit' for submit in submits submit.value = duration submit.disabled = true From c669c7a128245d795ae1f8819eb563dbc46e4c26 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 15:56:02 +0200 Subject: [PATCH 2/4] Also have that less retarded selector. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 095214714..4736cb6f9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1130,7 +1130,7 @@ cooldownCB: function() { var submit, submits, _i, _len; qr.duration = qr.duration - 1; - submits = $$('#qr input[type=submit], form[name=post] input[type=submit]'); + submits = $$('#com_submit'); for (_i = 0, _len = submits.length; _i < _len; _i++) { submit = submits[_i]; if (qr.duration === 0) { diff --git a/script.coffee b/script.coffee index 75d486949..6ad1d904b 100644 --- a/script.coffee +++ b/script.coffee @@ -869,7 +869,7 @@ qr = cooldownCB: -> qr.duration = qr.duration - 1 - submits = $$ '#qr input[type=submit], form[name=post] input[type=submit]' + submits = $$ '#com_submit' for submit in submits if qr.duration == 0 submit.disabled = false From 85516f8c9e6c879bb9d85134c10e768f4e110b06 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 17:20:27 +0200 Subject: [PATCH 3/4] Finish watch thread on reply. --- 4chan_x.js | 16 +++++++++++++--- script.coffee | 10 ++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 4736cb6f9..ffebe67da 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1023,12 +1023,22 @@ return _results; }, submit: function(e) { - var form, isQR, recaptcha, span, value; + var form, isQR, recaptcha, span, thread, threads, value, _i, _len; form = e.target; isQR = form.parentNode.id === 'qr'; if ($.config('Watch on Reply') && $.config('Thread Watcher')) { - value = g.THREAD_ID || $('input[name=resto]').value; - watcher.watch(null, value); + if (g.REPLY && $('img.favicon').src === Favicon.empty) { + watcher.watch(null, g.THREAD_ID); + } else { + value = $('input[name=resto]').value; + threads = $$('div.op'); + for (_i = 0, _len = threads.length; _i < _len; _i++) { + thread = threads[_i]; + if (thread.id === value && $('img.favicon', thread).src === Favicon.empty) { + watcher.watch(thread, value); + } + } + } } if (isQR) { if (span = this.nextSibling) { diff --git a/script.coffee b/script.coffee index 6ad1d904b..8c4846ea5 100644 --- a/script.coffee +++ b/script.coffee @@ -776,8 +776,14 @@ qr = isQR = form.parentNode.id == 'qr' if $.config('Watch on Reply') and $.config('Thread Watcher') - value = g.THREAD_ID or $('input[name=resto]').value - watcher.watch null, value + if g.REPLY and $('img.favicon').src is Favicon.empty + watcher.watch null, g.THREAD_ID + else + value = $('input[name=resto]').value + threads = $$ 'div.op' + for thread in threads + if thread.id is value and $('img.favicon', thread).src is Favicon.empty + watcher.watch thread, value if isQR if span = @nextSibling From 17f2d6e8b6cb075bb5988c53eacdd37290043b0b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 22:48:01 +0200 Subject: [PATCH 4/4] Do not break the report button. --- 4chan_x.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 336d64443..edc3e6582 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1697,7 +1697,7 @@ for (_i = 0, _len = arr.length; _i < _len; _i++) { el = arr[_i]; a = $.el('a', { - textContent: '[ ! ]' + innerHTML: '[ ! ]' }); $.bind(a, 'click', quickReport.cb.report); $.after(el, a); diff --git a/script.coffee b/script.coffee index 24d00be20..892b2e7e8 100644 --- a/script.coffee +++ b/script.coffee @@ -1325,7 +1325,7 @@ quickReport = arr = $$ 'span[id^=no]', root for el in arr a = $.el 'a', - textContent: '[ ! ]' + innerHTML: '[ ! ]' $.bind a, 'click', quickReport.cb.report $.after el, a $.after el, $.tn(' ')