From 047f056c4ccf140c4fdd678d80d47ad7958d027b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 29 Jan 2012 03:19:54 +0100 Subject: [PATCH] Fix 4chan X on /f/. Small optimizations while I'm at it. Close #129 --- 4chan_x.user.js | 9 +++++---- changelog | 2 ++ script.coffee | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 821f2eab4..cb7551372 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2276,9 +2276,9 @@ return g.callbacks.push(Time.node); }, node: function(root) { - var node, posttime, time; + var node, time; if (root.className === 'inline') return; - node = (posttime = $('.posttime', root)) ? posttime : $('span[id]', root).previousSibling; + node = $('.posttime', root) || $('span[id]', root).previousSibling; Time.date = Time.parse(node); time = $.el('time', { textContent: ' ' + Time.funk(Time) + ' ' @@ -3165,7 +3165,8 @@ if (conf['Comment Expansion']) expandComment.init(); if (conf['Index Navigation']) nav.init(); } - nodes = $$('.op, a + table'); + form = $('body > form'); + nodes = $$('.op, a + table', form); _ref = g.callbacks; for (_i = 0, _len = _ref.length; _i < _len; _i++) { callback = _ref[_i]; @@ -3178,7 +3179,7 @@ alert(err); } } - return $.on($('form[name=delform]'), 'DOMNodeInserted', Main.node); + return $.on(form, 'DOMNodeInserted', Main.node); }, message: function(e) { var data, origin; diff --git a/changelog b/changelog index 83fb8f7e9..cde88ebe9 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ master +- Mayhem + Fix 4chan X on /f/. 2.24.5 - Mayhem diff --git a/script.coffee b/script.coffee index 3fba9ad66..817a1069b 100644 --- a/script.coffee +++ b/script.coffee @@ -1824,7 +1824,7 @@ Time = g.callbacks.push Time.node node: (root) -> return if root.className is 'inline' - node = if posttime = $('.posttime', root) then posttime else $('span[id]', root).previousSibling + node = $('.posttime', root) or $('span[id]', root).previousSibling Time.date = Time.parse node time = $.el 'time', textContent: ' ' + Time.funk(Time) + ' ' @@ -2532,14 +2532,15 @@ Main = nav.init() - nodes = $$ '.op, a + table' + form = $ 'body > form' + nodes = $$ '.op, a + table', form for callback in g.callbacks try for node in nodes callback node catch err alert err - $.on $('form[name=delform]'), 'DOMNodeInserted', Main.node + $.on form, 'DOMNodeInserted', Main.node message: (e) -> {origin, data} = e