diff --git a/4chan_x.user.js b/4chan_x.user.js index 611b239ce..c766fdaa1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1475,29 +1475,30 @@ return parent.postMessage(data, '*'); }); c = $('b').lastChild; - if (c.nodeType === 8) { - _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; - search = location.search; - cooldown = /cooldown/.test(search); - noko = /noko/.test(search); - sage = /sage/.test(search); - watch = /watch/.test(search); - url = "http://boards.4chan.org/" + g.BOARD; - if (watch && thread === '0') { - url += "/res/" + id + "?watch"; - } else if (noko) { - url += '/res/'; - url += thread === '0' ? id : thread; - } - if (cooldown) { - duration = Date.now() + (sage ? 60 : 30) * 1000; - url += '?cooldown=' + duration; - } - if (noko) { - url += '#' + id; - } - return window.location = url; + if (c.nodeType !== 8) { + return; } + _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; + search = location.search; + cooldown = /cooldown/.test(search); + noko = /noko/.test(search); + sage = /sage/.test(search); + watch = /watch/.test(search); + url = "http://boards.4chan.org/" + g.BOARD; + if (watch && thread === '0') { + url += "/res/" + id + "?watch"; + } else if (noko) { + url += '/res/'; + url += thread === '0' ? id : thread; + } + if (cooldown) { + duration = Date.now() + (sage ? 60 : 30) * 1000; + url += '?cooldown=' + duration; + } + if (noko) { + url += '#' + id; + } + return window.location = url; }, validateFileSize: function(e) { var file; diff --git a/script.coffee b/script.coffee index 3f11a8bc1..6fba65792 100644 --- a/script.coffee +++ b/script.coffee @@ -1204,29 +1204,31 @@ qr = parent.postMessage data, '*' c = $('b').lastChild - if c.nodeType is 8 #comment node - [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) - {search} = location - cooldown = /cooldown/.test search - noko = /noko/ .test search - sage = /sage/ .test search - watch = /watch/ .test search + return unless c.nodeType is 8 #comment node - url = "http://boards.4chan.org/#{g.BOARD}" + [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) - if watch and thread is '0' - url += "/res/#{id}?watch" - else if noko - url += '/res/' - url += if thread is '0' then id else thread - if cooldown - duration = Date.now() + (if sage then 60 else 30) * 1000 - url += '?cooldown=' + duration - if noko - url += '#' + id + {search} = location + cooldown = /cooldown/.test search + noko = /noko/ .test search + sage = /sage/ .test search + watch = /watch/ .test search - window.location = url + url = "http://boards.4chan.org/#{g.BOARD}" + + if watch and thread is '0' + url += "/res/#{id}?watch" + else if noko + url += '/res/' + url += if thread is '0' then id else thread + if cooldown + duration = Date.now() + (if sage then 60 else 30) * 1000 + url += '?cooldown=' + duration + if noko + url += '#' + id + + window.location = url validateFileSize: (e) -> return unless @files[0].size > $('input[name=MAX_FILE_SIZE]').value