From d70c47cd6e57b79bb9d094036e52edb9d947180a Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 13:26:08 -0700 Subject: [PATCH 01/10] don't need style.className anymore --- 4chan_x.user.js | 3 +-- script.coffee | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 72ceb39d7..6068010db 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2500,8 +2500,7 @@ g.callbacks.push(imgExpand.node); imgExpand.dialog(); $.bind(window, 'resize', imgExpand.resize); - imgExpand.style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); - return imgExpand.style.className = 'height'; + return imgExpand.style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); }, node: function(root) { var a, thumb; diff --git a/script.coffee b/script.coffee index 6f9312029..3d271b86c 100644 --- a/script.coffee +++ b/script.coffee @@ -1882,7 +1882,6 @@ imgExpand = imgExpand.dialog() $.bind window, 'resize', imgExpand.resize imgExpand.style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" - imgExpand.style.className = 'height' node: (root) -> return unless thumb = $ 'img[md5]', root From aa182036f61952d03fbea31e6af2b4ddc5e0d2f3 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 13:27:15 -0700 Subject: [PATCH 02/10] better comment --- 4chan_x.user.js | 2 +- script.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6068010db..7f6d9820f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2460,8 +2460,8 @@ }, mouseover: function(e) { /* - img.src = null doesn't work on Chrome http://code.google.com/p/chromium/issues/detail?id=36142 + img.src = null doesn't work on Chrome, use it anyway for other browsers */ imageHover.img.src = null; imageHover.img.src = this.parentNode.href; return ui.el = imageHover.img; diff --git a/script.coffee b/script.coffee index 3d271b86c..92d3b0f3c 100644 --- a/script.coffee +++ b/script.coffee @@ -1854,8 +1854,8 @@ imageHover = $.bind thumb, 'mouseout', ui.hoverend mouseover: (e) -> ### - img.src = null doesn't work on Chrome http://code.google.com/p/chromium/issues/detail?id=36142 + img.src = null doesn't work on Chrome, use it anyway for other browsers ### imageHover.img.src = null imageHover.img.src = @parentNode.href From bd693030fbacded7a79f668f1c5a4ce0e5551e04 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 13:32:22 -0700 Subject: [PATCH 03/10] remove bug link --- script.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script.coffee b/script.coffee index 92d3b0f3c..6b77a3ce5 100644 --- a/script.coffee +++ b/script.coffee @@ -1854,8 +1854,7 @@ imageHover = $.bind thumb, 'mouseout', ui.hoverend mouseover: (e) -> ### - http://code.google.com/p/chromium/issues/detail?id=36142 - img.src = null doesn't work on Chrome, use it anyway for other browsers + `img.src = null` doesn't actually null the previous image on chrom. ### imageHover.img.src = null imageHover.img.src = @parentNode.href From 3f325c6ee5cd947278ed963df1f5d1f6f152dd1f Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:00:57 -0700 Subject: [PATCH 04/10] alphabetize options --- 4chan_x.user.js | 69 ++++++++++++++++++++++++------------------------- script.coffee | 58 ++++++++++++++++++++--------------------- 2 files changed, 63 insertions(+), 64 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7f6d9820f..c800a412a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -63,6 +63,39 @@ var __slice = Array.prototype.slice; config = { main: { + Enhancing: { + '404 Redirect': [true, 'Redirect dead threads'], + 'Anonymize': [false, 'Make everybody anonymous'], + 'Keybinds': [false, 'Binds actions to keys'], + 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], + 'Report Button': [true, 'Add report buttons'], + 'Comment Expansion': [true, 'Expand too long comments'], + 'Thread Expansion': [true, 'View all replies'], + 'Index Navigation': [true, 'Navigate to previous / next thread'], + 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] + }, + Hiding: { + 'Reply Hiding': [true, 'Hide single replies'], + 'Thread Hiding': [true, 'Hide entire threads'], + 'Show Stubs': [true, 'Of hidden threads / replies'] + }, + Imaging: { + 'Image Auto-Gif': [false, 'Animate gif thumbnails'], + 'Image Expansion': [true, 'Expand images'], + 'Image Hover': [false, 'Show full image on mouseover'], + 'Image Preloading': [false, 'Preload Images'], + 'Sauce': [true, 'Add sauce to images'], + 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] + }, + Monitoring: { + 'Thread Updater': [true, 'Update threads'], + 'Unread Count': [true, 'Show unread post count in tab title'], + 'Post in Title': [true, 'Show the op\'s post in the tab title'], + 'Thread Stats': [true, 'Display reply and image count'], + 'Thread Watcher': [true, 'Bookmark threads'], + 'Auto Watch': [true, 'Automatically watch threads that you start'], + 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] + }, Posting: { 'Auto Noko': [true, 'Always redirect to your post'], 'Cooldown': [true, 'Prevent \'flood detected\' errors'], @@ -76,39 +109,6 @@ 'Quote Inline': [true, 'Show quoted post inline on quote click'], 'Quote Preview': [true, 'Show quote content on hover'], 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] - }, - Monitoring: { - 'Thread Updater': [true, 'Update threads'], - 'Unread Count': [true, 'Show unread post count in tab title'], - 'Post in Title': [true, 'Show the op\'s post in the tab title'], - 'Thread Stats': [true, 'Display reply and image count'], - 'Thread Watcher': [true, 'Bookmark threads'], - 'Auto Watch': [true, 'Automatically watch threads that you start'], - 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] - }, - Imaging: { - 'Image Auto-Gif': [false, 'Animate gif thumbnails'], - 'Image Expansion': [true, 'Expand images'], - 'Image Hover': [false, 'Show full image on mouseover'], - 'Image Preloading': [false, 'Preload Images'], - 'Sauce': [true, 'Add sauce to images'], - 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] - }, - Hiding: { - 'Reply Hiding': [true, 'Hide single replies'], - 'Thread Hiding': [true, 'Hide entire threads'], - 'Show Stubs': [true, 'Of hidden threads / replies'] - }, - Enhancing: { - '404 Redirect': [true, 'Redirect dead threads'], - 'Anonymize': [false, 'Make everybody anonymous'], - 'Keybinds': [false, 'Binds actions to keys'], - 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'], - 'Report Button': [true, 'Add report buttons'], - 'Comment Expansion': [true, 'Expand too long comments'], - 'Thread Expansion': [true, 'View all replies'], - 'Index Navigation': [true, 'Navigate to previous / next thread'], - 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] } }, flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n'), @@ -2460,8 +2460,7 @@ }, mouseover: function(e) { /* - http://code.google.com/p/chromium/issues/detail?id=36142 - img.src = null doesn't work on Chrome, use it anyway for other browsers + `img.src = null` doesn't actually null the previous image on chrom. */ imageHover.img.src = null; imageHover.img.src = this.parentNode.href; return ui.el = imageHover.img; diff --git a/script.coffee b/script.coffee index 6b77a3ce5..b25dba969 100644 --- a/script.coffee +++ b/script.coffee @@ -1,5 +1,34 @@ config = main: + Enhancing: + '404 Redirect': [true, 'Redirect dead threads'] + 'Anonymize': [false, 'Make everybody anonymous'] + 'Keybinds': [false, 'Binds actions to keys'] + 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] + 'Report Button': [true, 'Add report buttons'] + 'Comment Expansion': [true, 'Expand too long comments'] + 'Thread Expansion': [true, 'View all replies'] + 'Index Navigation': [true, 'Navigate to previous / next thread'] + 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] + Hiding: + 'Reply Hiding': [true, 'Hide single replies'] + 'Thread Hiding': [true, 'Hide entire threads'] + 'Show Stubs': [true, 'Of hidden threads / replies'] + Imaging: + 'Image Auto-Gif': [false, 'Animate gif thumbnails'] + 'Image Expansion': [true, 'Expand images'] + 'Image Hover': [false, 'Show full image on mouseover'] + 'Image Preloading': [false, 'Preload Images'] + 'Sauce': [true, 'Add sauce to images'] + 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] + Monitoring: + 'Thread Updater': [true, 'Update threads'] + 'Unread Count': [true, 'Show unread post count in tab title'] + 'Post in Title': [true, 'Show the op\'s post in the tab title'] + 'Thread Stats': [true, 'Display reply and image count'] + 'Thread Watcher': [true, 'Bookmark threads'] + 'Auto Watch': [true, 'Automatically watch threads that you start'] + 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] Posting: 'Auto Noko': [true, 'Always redirect to your post'] 'Cooldown': [true, 'Prevent \'flood detected\' errors'] @@ -12,35 +41,6 @@ config = 'Quote Inline': [true, 'Show quoted post inline on quote click'] 'Quote Preview': [true, 'Show quote content on hover'] 'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes'] - Monitoring: - 'Thread Updater': [true, 'Update threads'] - 'Unread Count': [true, 'Show unread post count in tab title'] - 'Post in Title': [true, 'Show the op\'s post in the tab title'] - 'Thread Stats': [true, 'Display reply and image count'] - 'Thread Watcher': [true, 'Bookmark threads'] - 'Auto Watch': [true, 'Automatically watch threads that you start'] - 'Auto Watch Reply': [false, 'Automatically watch threads that you reply to'] - Imaging: - 'Image Auto-Gif': [false, 'Animate gif thumbnails'] - 'Image Expansion': [true, 'Expand images'] - 'Image Hover': [false, 'Show full image on mouseover'] - 'Image Preloading': [false, 'Preload Images'] - 'Sauce': [true, 'Add sauce to images'] - 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] - Hiding: - 'Reply Hiding': [true, 'Hide single replies'] - 'Thread Hiding': [true, 'Hide entire threads'] - 'Show Stubs': [true, 'Of hidden threads / replies'] - Enhancing: - '404 Redirect': [true, 'Redirect dead threads'] - 'Anonymize': [false, 'Make everybody anonymous'] - 'Keybinds': [false, 'Binds actions to keys'] - 'Time Formatting': [true, 'Arbitrarily formatted timestamps, using your local time'] - 'Report Button': [true, 'Add report buttons'] - 'Comment Expansion': [true, 'Expand too long comments'] - 'Thread Expansion': [true, 'View all replies'] - 'Index Navigation': [true, 'Navigate to previous / next thread'] - 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] flavors: [ 'http://regex.info/exif.cgi?url=' 'http://iqdb.org/?url=' From a2e6d2da24a259ae9fa10d820df6142e524c387a Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:05:28 -0700 Subject: [PATCH 05/10] IRC Updating --- 4chan_x.user.js | 10 ++++++---- script.coffee | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c800a412a..c7972c2b2 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -89,6 +89,7 @@ }, Monitoring: { 'Thread Updater': [true, 'Update threads'], + 'IRC Updating': [false, 'Scroll updated posts into view'], 'Unread Count': [true, 'Show unread post count in tab title'], 'Post in Title': [true, 'Show the op\'s post in the tab title'], 'Thread Stats': [true, 'Display reply and image count'], @@ -1617,7 +1618,7 @@ } }, update: function(e) { - var arr, body, br, id, input, replies, reply, _i, _len, _ref, _ref2, _results; + var arr, body, br, id, input, replies, reply, _i, _len, _ref, _ref2; if (this.status === 404) { updater.timer.textContent = ''; updater.count.textContent = 404; @@ -1653,11 +1654,12 @@ updater.count.className = 'new'; } } - _results = []; while (reply = arr.pop()) { - _results.push($.before(br, reply)); + $.before(br, reply); + } + if ($.config('IRC Updating')) { + return scrollTo(0, d.body.scrollHeight); } - return _results; } }, timeout: function() { diff --git a/script.coffee b/script.coffee index b25dba969..6e4b4b10b 100644 --- a/script.coffee +++ b/script.coffee @@ -23,6 +23,7 @@ config = 'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'] Monitoring: 'Thread Updater': [true, 'Update threads'] + 'IRC Updating': [false, 'Scroll updated posts into view'] 'Unread Count': [true, 'Show unread post count in tab title'] 'Post in Title': [true, 'Show the op\'s post in the tab title'] 'Thread Stats': [true, 'Display reply and image count'] @@ -1348,9 +1349,11 @@ updater = else updater.count.className = 'new' - #XXX add replies in correct order so /b/acklinks resolve + #XXX add replies in correct order so backlinks resolve while reply = arr.pop() $.before br, reply + if $.config 'IRC Updating' + scrollTo 0, d.body.scrollHeight timeout: -> n = Number updater.timer.textContent From 20429670b849c8c7b9a9c46e5d9d31e67ceb4a60 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:06:54 -0700 Subject: [PATCH 06/10] imageHover -> imgHover --- 4chan_x.user.js | 20 ++++++++++---------- script.coffee | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c7972c2b2..df548664e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -59,7 +59,7 @@ */ (function() { - var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, config, cooldown, d, expandComment, expandThread, firstRun, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref; + var $, $$, Favicon, NAMESPACE, Recaptcha, Time, anonymize, config, cooldown, d, expandComment, expandThread, firstRun, g, imgExpand, imgGif, imgHover, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref; var __slice = Array.prototype.slice; config = { main: { @@ -2443,29 +2443,29 @@ return _results; } }; - imageHover = { + imgHover = { init: function() { - imageHover.img = $.el('img', { + imgHover.img = $.el('img', { id: 'iHover' }); - $.append(d.body, imageHover.img); - return g.callbacks.push(imageHover.node); + $.append(d.body, imgHover.img); + return g.callbacks.push(imgHover.node); }, node: function(root) { var thumb; if (!(thumb = $('img[md5]', root))) { return; } - $.bind(thumb, 'mouseover', imageHover.mouseover); + $.bind(thumb, 'mouseover', imgHover.mouseover); $.bind(thumb, 'mousemove', ui.hover); return $.bind(thumb, 'mouseout', ui.hoverend); }, mouseover: function(e) { /* `img.src = null` doesn't actually null the previous image on chrom. - */ imageHover.img.src = null; - imageHover.img.src = this.parentNode.href; - return ui.el = imageHover.img; + */ imgHover.img.src = null; + imgHover.img.src = this.parentNode.href; + return ui.el = imgHover.img; } }; imgPreloading = { @@ -2718,7 +2718,7 @@ anonymize.init(); } if ($.config('Image Hover')) { - imageHover.init(); + imgHover.init(); } if ($.config('Reply Hiding')) { replyHiding.init(); diff --git a/script.coffee b/script.coffee index 6e4b4b10b..0498f6f8a 100644 --- a/script.coffee +++ b/script.coffee @@ -1845,23 +1845,23 @@ nodeInserted = (e) -> for callback in g.callbacks callback target -imageHover = +imgHover = init: -> - imageHover.img = $.el 'img', id: 'iHover' - $.append d.body, imageHover.img - g.callbacks.push imageHover.node + imgHover.img = $.el 'img', id: 'iHover' + $.append d.body, imgHover.img + g.callbacks.push imgHover.node node: (root) -> return unless thumb = $ 'img[md5]', root - $.bind thumb, 'mouseover', imageHover.mouseover + $.bind thumb, 'mouseover', imgHover.mouseover $.bind thumb, 'mousemove', ui.hover $.bind thumb, 'mouseout', ui.hoverend mouseover: (e) -> ### `img.src = null` doesn't actually null the previous image on chrom. ### - imageHover.img.src = null - imageHover.img.src = @parentNode.href - ui.el = imageHover.img + imgHover.img.src = null + imgHover.img.src = @parentNode.href + ui.el = imgHover.img imgPreloading = init: -> @@ -2122,7 +2122,7 @@ main = anonymize.init() if $.config 'Image Hover' - imageHover.init() + imgHover.init() if $.config 'Reply Hiding' replyHiding.init() From 703bd033f6f18f8fbc4d19d3a88d5f124499b909 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:17:16 -0700 Subject: [PATCH 07/10] fix chrom memory leak --- 4chan_x.user.js | 23 ++++++++++++++++------- script.coffee | 19 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index df548664e..1f026ffe7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2445,10 +2445,10 @@ }; imgHover = { init: function() { - imgHover.img = $.el('img', { + imgHover.el = $.el('div', { id: 'iHover' }); - $.append(d.body, imgHover.img); + $.append(d.body, imgHover.el); return g.callbacks.push(imgHover.node); }, node: function(root) { @@ -2458,14 +2458,23 @@ } $.bind(thumb, 'mouseover', imgHover.mouseover); $.bind(thumb, 'mousemove', ui.hover); - return $.bind(thumb, 'mouseout', ui.hoverend); + return $.bind(thumb, 'mouseout', imgHover.mouseout); }, mouseover: function(e) { /* - `img.src = null` doesn't actually null the previous image on chrom. - */ imgHover.img.src = null; - imgHover.img.src = this.parentNode.href; - return ui.el = imgHover.img; + http://code.google.com/p/chromium/issues/detail?id=36142 + manipulating img src via javascript will generate a massive memory leak + + instead of manipulating src, we manipulate the entire img + */ var img; + img = $.el('img', { + src: this.parentNode.href + }); + $.append(imgHover.el, img); + return ui.el = imgHover.el; + }, + mouseout: function(e) { + return $.rm(imgHover.el.firstChild); } }; imgPreloading = { diff --git a/script.coffee b/script.coffee index 0498f6f8a..a3f58bd3a 100644 --- a/script.coffee +++ b/script.coffee @@ -1847,21 +1847,26 @@ nodeInserted = (e) -> imgHover = init: -> - imgHover.img = $.el 'img', id: 'iHover' - $.append d.body, imgHover.img + 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', ui.hoverend + $.bind thumb, 'mouseout', imgHover.mouseout mouseover: (e) -> ### - `img.src = null` doesn't actually null the previous image on chrom. + http://code.google.com/p/chromium/issues/detail?id=36142 + manipulating img src via javascript will generate a massive memory leak + + instead of manipulating src, we manipulate the entire img ### - imgHover.img.src = null - imgHover.img.src = @parentNode.href - ui.el = imgHover.img + img = $.el 'img', src: @parentNode.href + $.append imgHover.el, img + ui.el = imgHover.el + mouseout: (e) -> + $.rm imgHover.el.firstChild imgPreloading = init: -> From a064101244e368812b05094f1843ec8a581ebaeb Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:19:43 -0700 Subject: [PATCH 08/10] don't repeat yourself --- 4chan_x.user.js | 3 ++- script.coffee | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 1f026ffe7..e580fbda6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2510,7 +2510,8 @@ g.callbacks.push(imgExpand.node); imgExpand.dialog(); $.bind(window, 'resize', imgExpand.resize); - return imgExpand.style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); + imgExpand.style = $.addStyle(''); + return imgExpand.resize(); }, node: function(root) { var a, thumb; diff --git a/script.coffee b/script.coffee index a3f58bd3a..191518f55 100644 --- a/script.coffee +++ b/script.coffee @@ -1888,7 +1888,8 @@ imgExpand = g.callbacks.push imgExpand.node imgExpand.dialog() $.bind window, 'resize', imgExpand.resize - imgExpand.style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" + imgExpand.style = $.addStyle '' + imgExpand.resize() node: (root) -> return unless thumb = $ 'img[md5]', root From db856d775b8b9b57c077979d5445d0f0751e628e Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:24:21 -0700 Subject: [PATCH 09/10] no iHover container div --- 4chan_x.user.js | 29 +++++++++++++---------------- script.coffee | 24 ++++++++++++------------ 2 files changed, 25 insertions(+), 28 deletions(-) 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: -> From 0a0e102aea570980ad975b6ba3baa03beede8910 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Jul 2011 14:26:53 -0700 Subject: [PATCH 10/10] derp --- 4chan_x.user.js | 3 +-- script.coffee | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e2a3e241c..5a90d6700 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2466,12 +2466,11 @@ id: 'iHover', src: this.parentNode.href }); - imgHover.img = img; ui.el = img; return $.append(d.body, img); }, mouseout: function(e) { - return $.rm(imgHover.img); + return $.rm(ui.el); } }; imgPreloading = { diff --git a/script.coffee b/script.coffee index 80d9f696f..d49ebb756 100644 --- a/script.coffee +++ b/script.coffee @@ -1862,11 +1862,10 @@ imgHover = img = $.el 'img' id: 'iHover' src: @parentNode.href - imgHover.img = img ui.el = img $.append d.body, img mouseout: (e) -> - $.rm imgHover.img + $.rm ui.el imgPreloading = init: ->