From 4e37bd796136f567900642f3ec340a6f33396c3e Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 5 Sep 2011 20:29:15 -0700 Subject: [PATCH] noko --- 4chan_x.user.js | 19 ++++++++++++++++--- script.coffee | 14 +++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 534835a5c..5d21e061f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1306,7 +1306,6 @@ }, attach: function() { var div, file, files; - $('#autopost', QR.qr).checked = true; files = $('#files', QR.qr); div = $.el('div', { innerHTML: "click hereX" @@ -1490,6 +1489,10 @@ row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0; data = e.data; if (data) { + if (QR.op) { + window.location = data; + } + return; data = JSON.parse(data); $.extend($('a.error', QR.qr), data); tc = data.textContent; @@ -1563,8 +1566,12 @@ $('#qr_form', qr).submit(); } QR.sage = /sage/i.test($('[name=email]', qr).value); + id = $('input[name=resto]', qr).value; + QR.op = !id; + if (QR.op) { + $('[name=email]', qr).value = 'noko'; + } if (conf['Thread Watcher'] && conf['Auto Watch Reply']) { - id = $('input[name=resto]', qr.el).value; op = $.id(id); if ($('img.favicon', op).src === Favicon.empty) { return watcher.watch(op, id); @@ -1579,12 +1586,18 @@ } return $.globalEval(function() { var data, href, node, textContent, _ref; - if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) { + $ = function(css) { + return document.querySelector(css); + }; + if (node = (_ref = $('table font b')) != null ? _ref.firstChild : void 0) { textContent = node.textContent, href = node.href; + alert(textContent); data = JSON.stringify({ textContent: textContent, href: href }); + } else if (node = $('meta')) { + data = node.content.match(/url=(.+)/)[1]; } return parent.postMessage(data, '*'); }); diff --git a/script.coffee b/script.coffee index 41387feee..e93a81441 100644 --- a/script.coffee +++ b/script.coffee @@ -993,7 +993,7 @@ QR = if conf['Auto Hide QR'] $('#autohide', QR.qr).checked = true attach: -> - $('#autopost', QR.qr).checked = true + #$('#autopost', QR.qr).checked = true files = $ '#files', QR.qr div = $.el 'div', innerHTML: "click hereX" @@ -1156,6 +1156,8 @@ QR = row = $('#files input[form]', qr)?.parentNode {data} = e if data + window.location = data if QR.op + return data = JSON.parse data $.extend $('a.error', QR.qr), data tc = data.textContent @@ -1201,8 +1203,10 @@ QR = input.setAttribute 'form', 'qr_form' $('#qr_form', qr).submit() if not e QR.sage = /sage/i.test $('[name=email]', qr).value + id = $('input[name=resto]', qr).value + QR.op = not id + $('[name=email]', qr).value = 'noko' if QR.op if conf['Thread Watcher'] and conf['Auto Watch Reply'] - id = $('input[name=resto]', qr.el).value op = $.id id if $('img.favicon', op).src is Favicon.empty watcher.watch op, id @@ -1211,9 +1215,13 @@ QR = $.bind recaptcha, 'keydown', Recaptcha.listener return $.globalEval -> - if node = document.querySelector('table font b')?.firstChild + $ = (css) -> document.querySelector css + if node = $('table font b')?.firstChild {textContent, href} = node + alert textContent data = JSON.stringify {textContent, href} + else if node = $ 'meta' + data = node.content.match(/url=(.+)/)[1] parent.postMessage data, '*' #parent will blank us on message receival; #if we're not an iframe, we won't get blanked