diff --git a/4chan_x.user.js b/4chan_x.user.js index f7a873007..a4f1dc60d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1853,7 +1853,7 @@ init: function() { return g.callbacks.push(function(root) { var board, img, nb, _, _ref; - if (!(img = $('img[alt^=Spoiler]', root) || root.className === 'inline')) { + if (!(img = $('img[alt^=Spoiler]', root)) || root.className === 'inline') { return; } img.removeAttribute('height'); @@ -2040,7 +2040,7 @@ }); }, toggle: function(e) { - var el, id, inline, inlined, pathname, root, table, threadID, _i, _len, _ref; + var el, hidden, id, inline, inlined, pathname, root, table, threadID, _i, _len, _ref; e.preventDefault(); id = this.hash.slice(1); if (table = $("#i" + id, $.x('ancestor::td[1]', this))) { @@ -2049,7 +2049,9 @@ _ref = $$('input', table); for (_i = 0, _len = _ref.length; _i < _len; _i++) { inlined = _ref[_i]; - $.show($.x('ancestor::table[1]', d.getElementById(inlined.name))); + if (hidden = d.getElementById(inlined.name)) { + $.show($.x('ancestor::table[1]', hidden)); + } } return; } @@ -2079,6 +2081,9 @@ }, parse: function(req, pathname, id, threadID, inline) { var body, html, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2; + if (!inline.parentNode) { + return; + } if (req.status !== 200) { inline.innerHTML = "" + req.status + " " + req.statusText; return; @@ -2177,8 +2182,7 @@ }, parse: function(req, id, threadID) { var body, html, op, qp, reply, _i, _len, _ref; - qp = $('#qp'); - if (qp.innerHTML !== ("Loading " + id + "...")) { + if (!(qp = ui.el || ui.el.innerHTML === ("Loading " + id + "..."))) { return; } if (req.status !== 200) { diff --git a/script.coffee b/script.coffee index 9d5a0355e..4a3eb0c24 100644 --- a/script.coffee +++ b/script.coffee @@ -1483,7 +1483,7 @@ sauce = revealSpoilers = init: -> g.callbacks.push (root) -> - return if not img = $('img[alt^=Spoiler]', root) or root.className is 'inline' + return if not (img = $ 'img[alt^=Spoiler]', root) or root.className is 'inline' img.removeAttribute 'height' img.removeAttribute 'width' [_, board, nb] = img.parentNode.href.match /(\w+)\/src\/(\d+)/ @@ -1602,7 +1602,8 @@ quoteInline = $.rm table $.removeClass @, 'inlined' for inlined in $$ 'input', table - $.show $.x 'ancestor::table[1]', d.getElementById inlined.name + if hidden = d.getElementById inlined.name + $.show $.x 'ancestor::table[1]', hidden return root = if @parentNode.nodeName is 'FONT' then @parentNode else if @nextSibling then @nextSibling else @ if el = d.getElementById id @@ -1623,6 +1624,8 @@ quoteInline = $.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline) $.addClass @, 'inlined' parse: (req, pathname, id, threadID, inline) -> + return unless inline.parentNode + if req.status isnt 200 inline.innerHTML = "#{req.status} #{req.statusText}" return @@ -1681,8 +1684,7 @@ quotePreview = $.removeClass el, 'qphl' if el = d.getElementById @hash[1..] ui.hoverend() parse: (req, id, threadID) -> - qp = $ '#qp' - return unless qp.innerHTML is "Loading #{id}..." + return unless qp = ui.el or ui.el.innerHTML is "Loading #{id}..." if req.status isnt 200 qp.innerHTML = "#{req.status} #{req.statusText}"