From 8c31785b0e4a4eb4d26cffb22b873285b43cffbf Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 12 Mar 2011 08:20:48 -0800 Subject: [PATCH] auto gif --- 4chan_x.js | 14 ++++++++++++++ script.coffee | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/4chan_x.js b/4chan_x.js index c0acd8a3f..695b7f0fa 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -66,6 +66,7 @@ 'Anonymize': [false, 'Make everybody anonymous'], 'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)'], 'Comment Expansion': [true, 'Expand too long comments'], + 'Image Auto-Gif': [false, 'Animate gif thumbnails'], 'Image Expansion': [true, 'Expand images'], 'Image Preloading': [false, 'Preload Images'], 'Keybinds': [false, 'Binds actions to keys'], @@ -1588,6 +1589,19 @@ return _results; }); } + if (getConfig('Image Auto-Gif')) { + g.callbacks.push(function(root) { + var src, thumb, thumbs, _i, _len, _results; + thumbs = $$('img[md5]', root); + _results = []; + for (_i = 0, _len = thumbs.length; _i < _len; _i++) { + thumb = thumbs[_i]; + src = thumb.parentNode.href; + _results.push(/gif$/.test(src) ? thumb.src = src : void 0); + } + return _results; + }); + } if (getConfig('Localize Time')) { g.callbacks.push(function(root) { var date, day, dotw, hour, min_sec, month, s, span, spans, year, _i, _len, _ref, _results; diff --git a/script.coffee b/script.coffee index b0766578e..bd625892c 100644 --- a/script.coffee +++ b/script.coffee @@ -12,6 +12,7 @@ config = 'Anonymize': [false, 'Make everybody anonymous'] 'Auto Watch': [true, 'Automatically watch threads that you start (Firefox only)'] 'Comment Expansion': [true, 'Expand too long comments'] + 'Image Auto-Gif': [false, 'Animate gif thumbnails'] 'Image Expansion': [true, 'Expand images'] 'Image Preloading': [false, 'Preload Images'] 'Keybinds': [false, 'Binds actions to keys'] @@ -1211,6 +1212,14 @@ if getConfig 'Image Expansion' thumb.parentNode.addEventListener 'click', imageClick, true if g.expand then imageToggle thumb.parentNode +if getConfig 'Image Auto-Gif' + g.callbacks.push (root) -> + thumbs = $$ 'img[md5]', root + for thumb in thumbs + src = thumb.parentNode.href + if /gif$/.test src + thumb.src = src + if getConfig 'Localize Time' g.callbacks.push (root) -> spans = $$ 'span[id^=no]', root