From 19e92b32252f83e2ea198ea74ebb4b3d3a9e4dbd Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 23 May 2011 21:02:14 +0200 Subject: [PATCH] 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