From 43617c6db9214d438e4ba4c684fde75bfdb3d520 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 7 May 2011 15:54:07 +0200 Subject: [PATCH] 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