From 209e1207069fb8118e90e23cf2086bc48c34b49d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 25 Jun 2011 19:40:47 +0200 Subject: [PATCH 1/2] Append #watch only when auto watch is enabled. close #162 --- 4chan_x.user.js | 26 ++++++++++++++++++-------- changelog | 1 + script.coffee | 23 +++++++++++++++-------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 2e93e747e..1211a76ad 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1366,7 +1366,7 @@ return qr.autohide.set(); }, sys: function() { - var c, id, recaptcha, thread, _, _ref; + var c, id, otoNoko, recaptcha, thread, _, _ref; if (recaptcha = $('#recaptcha_response_field')) { $.bind(recaptcha, 'keydown', Recaptcha.listener); return; @@ -1386,9 +1386,14 @@ c = $('b').lastChild; if (c.nodeType === 8) { _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; + otoNoko = /AEOS.4chan_x.auto_noko=true/.test(d.cookie); if (thread === '0') { - return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; - } else if (/AEOS.4chan_x.auto_noko=true/.test(d.cookie)) { + if (/AEOS.4chan_x.auto_watch=true/.test(d.cookie)) { + return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; + } else if (otoNoko) { + return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id; + } + } else if (otoNoko) { return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id; } } @@ -2684,9 +2689,9 @@ $.bind(form, 'submit', qr.cb.submit); } if ($.config('Auto Noko')) { - document.cookie = "" + NAMESPACE + "auto_noko=true;path=/;domain=.4chan.org"; + d.cookie = "" + NAMESPACE + "auto_noko=true;path=/;domain=.4chan.org"; } else { - document.cookie = "" + NAMESPACE + "auto_noko=false;path=/;domain=.4chan.org"; + d.cookie = "" + NAMESPACE + "auto_noko=false;path=/;domain=.4chan.org"; } if ($.config('Cooldown')) { cooldown.init(); @@ -2740,6 +2745,14 @@ keybinds.init(); } threading.init(); + if ($.config('Auto Watch') && $.config('Thread Watcher')) { + d.cookie = "" + NAMESPACE + "auto_watch=true;path=/;domain=.4chan.org"; + if (g.REPLY && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) { + watcher.watch(null, g.THREAD_ID); + } + } else { + d.cookie = "" + NAMESPACE + "auto_watch=false;path=/;domain=.4chan.org"; + } if (g.REPLY) { if ($.config('Thread Updater')) { updater.init(); @@ -2759,9 +2772,6 @@ if ($.config('Unread Count')) { unread.init(); } - if ($.config('Auto Watch') && $.config('Thread Watcher') && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) { - watcher.watch(null, g.THREAD_ID); - } if ($.config('Reply Navigation')) { nav.init(); } diff --git a/changelog b/changelog index 948daf184..0770ab149 100644 --- a/changelog +++ b/changelog @@ -3,6 +3,7 @@ - image spoiler revealer - optional auto noko - fix options centering on Opera + - fix append '#watch' only when auto watch is enabled - aeosynth: - keep options dialog at constant size - drop firefox 3.6 support (again...) diff --git a/script.coffee b/script.coffee index e49a86ede..3904c9bc0 100644 --- a/script.coffee +++ b/script.coffee @@ -1127,9 +1127,13 @@ qr = c = $('b').lastChild if c.nodeType is 8 #comment node [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) + otoNoko = /AEOS.4chan_x.auto_noko=true/.test d.cookie if thread is '0' - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" - else if /AEOS.4chan_x.auto_noko=true/.test d.cookie + if /AEOS.4chan_x.auto_watch=true/.test d.cookie + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" + else if otoNoko + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}" + else if otoNoko window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}" threading = @@ -2097,9 +2101,9 @@ main = #major features if $.config 'Auto Noko' - document.cookie = "#{NAMESPACE}auto_noko=true;path=/;domain=.4chan.org" + d.cookie = "#{NAMESPACE}auto_noko=true;path=/;domain=.4chan.org" else - document.cookie = "#{NAMESPACE}auto_noko=false;path=/;domain=.4chan.org" + d.cookie = "#{NAMESPACE}auto_noko=false;path=/;domain=.4chan.org" if $.config 'Cooldown' cooldown.init() @@ -2154,6 +2158,13 @@ main = threading.init() + if $.config('Auto Watch') and $.config('Thread Watcher') + d.cookie = "#{NAMESPACE}auto_watch=true;path=/;domain=.4chan.org" + if g.REPLY and location.hash is '#watch' and $('img.favicon').src is Favicon.empty + watcher.watch null, g.THREAD_ID + else + d.cookie = "#{NAMESPACE}auto_watch=false;path=/;domain=.4chan.org" + if g.REPLY if $.config 'Thread Updater' updater.init() @@ -2173,10 +2184,6 @@ main = if $.config 'Unread Count' unread.init() - if $.config('Auto Watch') and $.config('Thread Watcher') and - location.hash is '#watch' and $('img.favicon').src is Favicon.empty - watcher.watch null, g.THREAD_ID - if $.config 'Reply Navigation' nav.init() From 7ab80f7f45793583ff342f9a2fab6f29f33f8c62 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 25 Jun 2011 20:16:52 +0200 Subject: [PATCH 2/2] Simple CSS. --- script.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script.coffee b/script.coffee index 35c1cb33f..94f115d79 100644 --- a/script.coffee +++ b/script.coffee @@ -2327,8 +2327,7 @@ main = height: 120px; } #qr.auto:not(:hover) > form { - height: 0; - overflow: hidden; + display: none; } /* http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css */ #qr input::-webkit-input-placeholder {