From f24825c740761e134c6aed7699e7ec94423aec01 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 18 Dec 2010 23:29:47 -0800 Subject: [PATCH] keybind: m - expand image --- 4chan_x.coffee | 15 ++++++++++++--- 4chan_x.js | 22 ++++++++++++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index edbf027b0..ee50d7a26 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -371,7 +371,11 @@ iframeLoad = -> imageClick = (e) -> return if e.shiftKey or e.altKey or e.ctrlKey e.preventDefault() - thumb = @firstChild + imageToggle this + +imageToggle = (image) -> + # 'image' is actually the container + thumb = image.firstChild if thumb.className is 'hide' imageThumb thumb else @@ -528,12 +532,17 @@ keypress = (e) -> temp = g.PAGENUM + count if temp > 15 then temp = 15 location.pathname = "/#{g.BOARD}/#{temp}#0" + when "M" + [thread] = getThread() + unless image = $ 'td.replyhl span.filesize ~ a[target]', thread + image = $ 'span.filesize ~ a[target]', thread + imageToggle image when "O" href = $("#{hash} ~ span[id] a:last-of-type").href GM_openInTab href when "W" - img = $("#{hash} ~ img") - watch.call img + watchButton = $("#{hash} ~ img") + watch.call watchButton nodeInserted = (e) -> target = e.target diff --git a/4chan_x.js b/4chan_x.js index c0d753012..380e4f4d3 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1,5 +1,5 @@ (function() { - var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, img, inAfter, inBefore, input, inputs, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4; + var $, $$, AEOS, DAY, a, addTo, arr, as, autoWatch, autohide, b, board, callback, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpandClick, imageFull, imageThumb, imageToggle, img, inAfter, inBefore, input, inputs, keydown, keypress, l1, lastChecked, m, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, options, optionsClose, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, remove, replace, replyNav, report, scroll, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, up, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _fn, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _ref, _ref2, _ref3, _ref4; var __slice = Array.prototype.slice, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (this[i] === item) return i; @@ -473,12 +473,15 @@ return recaptchaReload(); }; imageClick = function(e) { - var thumb; if (e.shiftKey || e.altKey || e.ctrlKey) { return; } e.preventDefault(); - thumb = this.firstChild; + return imageToggle(this); + }; + imageToggle = function(image) { + var thumb; + thumb = image.firstChild; if (thumb.className === 'hide') { return imageThumb(thumb); } else { @@ -530,7 +533,7 @@ return g.char = char; }; keypress = function(e) { - var bot, char, count, hash, height, href, i, img, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, _i, _j, _len, _len2, _len3, _len4, _ref, _ref2; + var bot, char, count, hash, height, href, i, image, next, prev, qrLink, rect, replies, reply, td, temp, thread, top, watchButton, _i, _j, _len, _len2, _len3, _len4, _ref, _ref2; if (!(char = g.char)) { return; } @@ -693,13 +696,20 @@ } return location.pathname = "/" + g.BOARD + "/" + temp + "#0"; break; + case "M": + thread = getThread()[0]; + if (!(image = $('td.replyhl span.filesize ~ a[target]', thread))) { + image = $('span.filesize ~ a[target]', thread); + } + return imageToggle(image); + break; case "O": href = $("" + hash + " ~ span[id] a:last-of-type").href; return GM_openInTab(href); break; case "W": - img = $("" + hash + " ~ img"); - return watch.call(img); + watchButton = $("" + hash + " ~ img"); + return watch.call(watchButton); } } };