Revert "cleanup, should work in chrome"

This reverts commit 3faa0b314001d71da308958f954df2555ccf53e2.
This commit is contained in:
James Campos 2011-08-15 22:13:35 -07:00
parent d6bed73c32
commit 827d1f0987
2 changed files with 76 additions and 53 deletions

View File

@ -1416,7 +1416,20 @@
submit: function(e) { submit: function(e) {
var data, el, id, msg, op, _i, _len, _ref; var data, el, id, msg, op, _i, _len, _ref;
e.preventDefault(); e.preventDefault();
data = {
board: g.BOARD
};
_ref = $$('[name]', qr.el);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
el = _ref[_i];
if (el.value) {
data[el.name] = el.value;
}
}
$('iframe').contentWindow.postMessage(JSON.stringify(data), '*');
return;
if (msg = qr.postInvalid()) { if (msg = qr.postInvalid()) {
e.preventDefault();
alert(msg); alert(msg);
if (msg === 'You forgot to type in the verification.') { if (msg === 'You forgot to type in the verification.') {
$('#recaptcha_response_field', qr.el).focus(); $('#recaptcha_response_field', qr.el).focus();
@ -1434,22 +1447,17 @@
} }
} }
} }
if (this.id !== 'qr_form') {
return;
}
if (!e) {
this.submit();
}
$('#error', qr.el).textContent = ''; $('#error', qr.el).textContent = '';
if (conf['Auto Hide QR']) { if (conf['Auto Hide QR']) {
$('#autohide', qr.el).checked = true; $('#autohide', qr.el).checked = true;
} }
qr.sage = /sage/i.test($('input[name=email]', this).value); return qr.sage = /sage/i.test($('input[name=email]', this).value);
data = {
board: g.BOARD
};
_ref = $$('[name]', qr.el);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
el = _ref[_i];
if (el.value) {
data[el.name] = el.value;
}
}
return $('iframe').contentWindow.postMessage(JSON.stringify(data), '*');
}, },
foo: function() { foo: function() {
var body, data, href, node, textContent, _ref; var body, data, href, node, textContent, _ref;
@ -1465,18 +1473,7 @@
} else { } else {
data = ''; data = '';
} }
$('#error').textContent = data; return parent.postMessage(data, '*');
return $.globalEval(function() {
data = document.getElementById('error').textContent;
return parent.postMessage(data, '*');
});
/*
http://code.google.com/p/chromium/issues/detail?id=20773
Let content scripts see other frames (instead of them being undefined)
To access the parent, we have to break out of the sandbox and evaluate
in the global context.
*/
}, },
sysMessage: function(e) { sysMessage: function(e) {
var board, data, formData, key, val, x; var board, data, formData, key, val, x;
@ -1491,16 +1488,33 @@
return x = $.xhr("http://sys.4chan.org/" + board + "/post", qr.foo, formData); return x = $.xhr("http://sys.4chan.org/" + board + "/post", qr.foo, formData);
}, },
sys: function() { sys: function() {
var c, duration, error, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref, _ref2; var c, duration, id, noko, recaptcha, sage, search, thread, url, watch, _, _ref, _ref2;
$.bind(window, 'message', qr.sysMessage);
return;
if (recaptcha = $('#recaptcha_response_field')) { if (recaptcha = $('#recaptcha_response_field')) {
$.bind(recaptcha, 'keydown', Recaptcha.listener); $.bind(recaptcha, 'keydown', Recaptcha.listener);
return; return;
} }
$.bind(window, 'message', qr.sysMessage); /*
error = $.el('span', { http://code.google.com/p/chromium/issues/detail?id=20773
id: 'error' Let content scripts see other frames (instead of them being undefined)
To access the parent, we have to break out of the sandbox and evaluate
in the global context.
*/
$.globalEval(function() {
var data, href, node, textContent, _ref;
if (node = (_ref = document.querySelector('table font b')) != null ? _ref.firstChild : void 0) {
textContent = node.textContent, href = node.href;
data = JSON.stringify({
textContent: textContent,
href: href
});
} else {
data = '';
}
return parent.postMessage(data, '*');
}); });
$.append(d.body, error);
c = (_ref = $('b')) != null ? _ref.lastChild : void 0; c = (_ref = $('b')) != null ? _ref.lastChild : void 0;
if (!(c && c.nodeType === 8)) { if (!(c && c.nodeType === 8)) {
return; return;

View File

@ -1163,7 +1163,18 @@ qr =
submit: (e) -> submit: (e) ->
e.preventDefault() e.preventDefault()
data =
board: g.BOARD
for el in $$ '[name]', qr.el when el.value
data[el.name] = el.value
$('iframe').contentWindow.postMessage JSON.stringify(data), '*'
return
if msg = qr.postInvalid() if msg = qr.postInvalid()
e.preventDefault()
alert msg alert msg
if msg is 'You forgot to type in the verification.' if msg is 'You forgot to type in the verification.'
$('#recaptcha_response_field', qr.el).focus() $('#recaptcha_response_field', qr.el).focus()
@ -1178,18 +1189,13 @@ qr =
if $('img.favicon', op).src is Favicon.empty if $('img.favicon', op).src is Favicon.empty
watcher.watch op, id watcher.watch op, id
return unless @id is 'qr_form'
if !e then @submit()
$('#error', qr.el).textContent = '' $('#error', qr.el).textContent = ''
$('#autohide', qr.el).checked = true if conf['Auto Hide QR'] $('#autohide', qr.el).checked = true if conf['Auto Hide QR']
qr.sage = /sage/i.test $('input[name=email]', @).value qr.sage = /sage/i.test $('input[name=email]', @).value
data =
board: g.BOARD
for el in $$ '[name]', qr.el when el.value
data[el.name] = el.value
$('iframe').contentWindow.postMessage JSON.stringify(data), '*'
foo: -> foo: ->
body = $.el 'body', body = $.el 'body',
innerHTML: @responseText innerHTML: @responseText
@ -1199,19 +1205,7 @@ qr =
data = JSON.stringify {textContent, href} data = JSON.stringify {textContent, href}
else else
data = '' data = ''
$('#error').textContent = data parent.postMessage data, '*'
$.globalEval ->
data = document.getElementById('error').textContent
parent.postMessage data, '*'
###
http://code.google.com/p/chromium/issues/detail?id=20773
Let content scripts see other frames (instead of them being undefined)
To access the parent, we have to break out of the sandbox and evaluate
in the global context.
###
sysMessage: (e) -> sysMessage: (e) ->
data = JSON.parse e.data data = JSON.parse e.data
@ -1225,13 +1219,28 @@ qr =
x = $.xhr "http://sys.4chan.org/#{board}/post", qr.foo, formData x = $.xhr "http://sys.4chan.org/#{board}/post", qr.foo, formData
sys: -> sys: ->
$.bind window, 'message', qr.sysMessage
return
if recaptcha = $ '#recaptcha_response_field' #post reporting if recaptcha = $ '#recaptcha_response_field' #post reporting
$.bind recaptcha, 'keydown', Recaptcha.listener $.bind recaptcha, 'keydown', Recaptcha.listener
return return
$.bind window, 'message', qr.sysMessage ###
error = $.el 'span', id: 'error' http://code.google.com/p/chromium/issues/detail?id=20773
$.append d.body, error Let content scripts see other frames (instead of them being undefined)
To access the parent, we have to break out of the sandbox and evaluate
in the global context.
###
$.globalEval ->
if node = document.querySelector('table font b')?.firstChild
{textContent, href} = node
data = JSON.stringify {textContent, href}
else
data = ''
parent.postMessage data, '*'
c = $('b')?.lastChild c = $('b')?.lastChild