diff --git a/4chan_x.user.js b/4chan_x.user.js index e580fbda6..e2a3e241c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2445,20 +2445,15 @@ }; imgHover = { init: function() { - imgHover.el = $.el('div', { - id: 'iHover' + return g.callbacks.push(function(root) { + var thumb; + if (!(thumb = $('img[md5]', root))) { + return; + } + $.bind(thumb, 'mouseover', imgHover.mouseover); + $.bind(thumb, 'mousemove', ui.hover); + return $.bind(thumb, 'mouseout', imgHover.mouseout); }); - $.append(d.body, imgHover.el); - return g.callbacks.push(imgHover.node); - }, - node: function(root) { - var thumb; - if (!(thumb = $('img[md5]', root))) { - return; - } - $.bind(thumb, 'mouseover', imgHover.mouseover); - $.bind(thumb, 'mousemove', ui.hover); - return $.bind(thumb, 'mouseout', imgHover.mouseout); }, mouseover: function(e) { /* @@ -2468,13 +2463,15 @@ instead of manipulating src, we manipulate the entire img */ var img; img = $.el('img', { + id: 'iHover', src: this.parentNode.href }); - $.append(imgHover.el, img); - return ui.el = imgHover.el; + imgHover.img = img; + ui.el = img; + return $.append(d.body, img); }, mouseout: function(e) { - return $.rm(imgHover.el.firstChild); + return $.rm(imgHover.img); } }; imgPreloading = { diff --git a/script.coffee b/script.coffee index 191518f55..80d9f696f 100644 --- a/script.coffee +++ b/script.coffee @@ -1847,14 +1847,11 @@ nodeInserted = (e) -> imgHover = init: -> - imgHover.el = $.el 'div', id: 'iHover' - $.append d.body, imgHover.el - g.callbacks.push imgHover.node - node: (root) -> - return unless thumb = $ 'img[md5]', root - $.bind thumb, 'mouseover', imgHover.mouseover - $.bind thumb, 'mousemove', ui.hover - $.bind thumb, 'mouseout', imgHover.mouseout + g.callbacks.push (root) -> + return unless thumb = $ 'img[md5]', root + $.bind thumb, 'mouseover', imgHover.mouseover + $.bind thumb, 'mousemove', ui.hover + $.bind thumb, 'mouseout', imgHover.mouseout mouseover: (e) -> ### http://code.google.com/p/chromium/issues/detail?id=36142 @@ -1862,11 +1859,14 @@ imgHover = instead of manipulating src, we manipulate the entire img ### - img = $.el 'img', src: @parentNode.href - $.append imgHover.el, img - ui.el = imgHover.el + img = $.el 'img' + id: 'iHover' + src: @parentNode.href + imgHover.img = img + ui.el = img + $.append d.body, img mouseout: (e) -> - $.rm imgHover.el.firstChild + $.rm imgHover.img imgPreloading = init: ->