From 160e9efc525c00147c04c7a0aac26e5ee55ac007 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 23 May 2011 20:04:54 +0200 Subject: [PATCH 1/2] Magical auto noko. --- 4chan_x.js | 11 ++++++----- script.coffee | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 9294ed71b..48decdcc1 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1180,7 +1180,7 @@ return qr.autohide.set(); }, sys: function() { - var board, c, id, recaptcha, thread, _, _ref, _ref2; + var c, id, recaptcha, thread, _, _ref; if (recaptcha = $('#recaptcha_response_field')) { $.bind(recaptcha, 'keydown', Recaptcha.listener); return; @@ -1189,9 +1189,10 @@ if (c.nodeType === 8) { _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; if (thread === '0') { - _ref2 = $('meta', d).content.match(/4chan.org\/(\w+)\//), _ = _ref2[0], board = _ref2[1]; - window.location = "http://boards.4chan.org/" + board + "/res/" + id + "#watch"; + window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; return; + } else { + window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id; } } /* @@ -1202,8 +1203,8 @@ in the global context. */ return $.globalEval(function() { - var data, _ref3; - data = ((_ref3 = document.querySelector('table font b')) != null ? _ref3.firstChild.textContent : void 0) || ''; + var data, _ref2; + data = ((_ref2 = document.querySelector('table font b')) != null ? _ref2.firstChild.textContent : void 0) || ''; return parent.postMessage(data, '*'); }); } diff --git a/script.coffee b/script.coffee index 6a39a79c7..1c1d71cb9 100644 --- a/script.coffee +++ b/script.coffee @@ -963,9 +963,11 @@ qr = if c.nodeType is 8 #comment node [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) if thread is '0' - [_, board] = $('meta', d).content.match(/4chan.org\/(\w+)\//) - window.location = "http://boards.4chan.org/#{board}/res/#{id}#watch" + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" return + else + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}" + ### http://code.google.com/p/chromium/issues/detail?id=20773 From 19e92b32252f83e2ea198ea74ebb4b3d3a9e4dbd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 23 May 2011 21:02:14 +0200 Subject: [PATCH 2/2] Safety measures. --- 4chan_x.js | 25 ++++++++++++------------- script.coffee | 18 ++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 48decdcc1..f6bda84c9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1185,16 +1185,6 @@ $.bind(recaptcha, 'keydown', Recaptcha.listener); return; } - c = $('b').lastChild; - if (c.nodeType === 8) { - _ref = c.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], id = _ref[2]; - if (thread === '0') { - window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; - return; - } else { - window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id; - } - } /* http://code.google.com/p/chromium/issues/detail?id=20773 Let content scripts see other frames (instead of them being undefined) @@ -1202,11 +1192,20 @@ To access the parent, we have to break out of the sandbox and evaluate in the global context. */ - return $.globalEval(function() { - var data, _ref2; - data = ((_ref2 = document.querySelector('table font b')) != null ? _ref2.firstChild.textContent : void 0) || ''; + $.globalEval(function() { + var data, _ref; + data = ((_ref = document.querySelector('table font b')) != null ? _ref.firstChild.textContent : void 0) || ''; 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]; + if (thread === '0') { + return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + id + "#watch"; + } else { + return window.location = "http://boards.4chan.org/" + g.BOARD + "/res/" + thread + "#" + id; + } + } } }; threading = { diff --git a/script.coffee b/script.coffee index 1c1d71cb9..d0fe0ae60 100644 --- a/script.coffee +++ b/script.coffee @@ -959,16 +959,6 @@ qr = $.bind recaptcha, 'keydown', Recaptcha.listener return - c = $('b').lastChild - if c.nodeType is 8 #comment node - [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) - if thread is '0' - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" - return - else - window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}" - - ### http://code.google.com/p/chromium/issues/detail?id=20773 Let content scripts see other frames (instead of them being undefined) @@ -980,6 +970,14 @@ qr = data = document.querySelector('table font b')?.firstChild.textContent or '' parent.postMessage data, '*' + c = $('b').lastChild + if c.nodeType is 8 #comment node + [_, thread, id] = c.textContent.match(/thread:(\d+),no:(\d+)/) + if thread is '0' + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{id}#watch" + else + window.location = "http://boards.4chan.org/#{g.BOARD}/res/#{thread}##{id}" + threading = init: -> # don't thread image controls