From 0df39c402a3789e27a0d5e6a1351265889d8507f Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 18 Nov 2010 19:26:04 -0800 Subject: [PATCH] g.startup; better qr keybind --- 4chan_x.coffee | 8 ++++---- 4chan_x.js | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index 9d0c3454e..ab26dca39 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -407,8 +407,6 @@ keypress = (e) -> when "I" qrLink = $ "#{hash} ~ span[id] a:not(:first-child)" quickReply.call qrLink - ta = $ '#qr textarea' - ta.focus() when "J" temp = position + count if temp > 9 then temp = 9 @@ -577,8 +575,8 @@ quickReply = (e) -> inBefore submit, auto addTo qr, clone addTo d.body, qr - if e - e.preventDefault() + unless g.startup + e?.preventDefault() $('input[title=autohide]:checked', qr)?.click() selection = window.getSelection() id = x('preceding::span[@id][1]', selection.anchorNode)?.id @@ -723,6 +721,7 @@ g = 'http://saucenao.com/search.php?db=999&url=' 'http://tineye.com/search?url=' ].join '\n' + startup: true pathname = location.pathname.substring(1).split('/') [g.BOARD, temp] = pathname if temp is 'res' @@ -1042,3 +1041,4 @@ else #not reply callback() for callback in g.callbacks d.body.addEventListener('DOMNodeInserted', nodeInserted, true) +g.startup = false diff --git a/4chan_x.js b/4chan_x.js index c9f1f3e72..68dcaf3bc 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -447,7 +447,7 @@ return recaptchaReload(); }; keypress = function(e) { - var _i, _len, char, count, hash, href, img, kc, position, qrLink, ta, temp; + var _i, _len, char, count, hash, href, img, kc, position, qrLink, temp; kc = g.keyCode; if (kc === -1) { return null; @@ -506,8 +506,6 @@ case "I": qrLink = $("" + (hash) + " ~ span[id] a:not(:first-child)"); quickReply.call(qrLink); - ta = $('#qr textarea'); - ta.focus(); break; case "J": temp = position + count; @@ -747,8 +745,8 @@ addTo(qr, clone); addTo(d.body, qr); } - if (e) { - e.preventDefault(); + if (!(g.startup)) { + (typeof e === "undefined" || e === null) ? undefined : e.preventDefault(); (typeof (_ref2 = ((_ref = $('input[title=autohide]:checked', qr)))) === "undefined" || _ref2 === null) ? undefined : _ref2.click(); selection = window.getSelection(); id = (typeof (_ref2 = ((_ref = x('preceding::span[@id][1]', selection.anchorNode)))) === "undefined" || _ref2 === null) ? undefined : _ref2.id; @@ -921,7 +919,8 @@ watched: JSON.parse(GM_getValue('watched', '{}')), favEmpty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw==', favNormal: ((typeof (_ref2 = ((_ref = $('link[rel="shortcut icon"]', $('head', d))))) === "undefined" || _ref2 === null) ? undefined : _ref2.href) || 'http://static.4chan.org/image/favicon.ico', - flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://saucenao.com/search.php?db=999&url=', 'http://tineye.com/search?url='].join('\n') + flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://saucenao.com/search.php?db=999&url=', 'http://tineye.com/search?url='].join('\n'), + startup: true }; pathname = location.pathname.substring(1).split('/'); _ref = pathname; @@ -1350,4 +1349,5 @@ callback(); } d.body.addEventListener('DOMNodeInserted', nodeInserted, true); + g.startup = false; }).call(this);