Image spoiler revealer. Close #187

This commit is contained in:
Nicolas Stepien 2011-06-25 00:17:58 +02:00
parent cd20db879e
commit 5431fd5311
2 changed files with 38 additions and 2 deletions

View File

@ -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, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
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 __slice = Array.prototype.slice;
if (typeof console !== "undefined" && console !== null) {
log = function(arg) {
@ -95,7 +95,8 @@
'Image Expansion': [true, 'Expand images'],
'Image Hover': [false, 'Show full image on mouseover'],
'Image Preloading': [false, 'Preload Images'],
'Sauce': [true, 'Add sauce to images']
'Sauce': [true, 'Add sauce to images'],
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
},
Hiding: {
'Reply Hiding': [true, 'Hide single replies'],
@ -1817,6 +1818,23 @@
}
}
};
revealSpoilers = {
init: function() {
return g.callbacks.push(revealSpoilers.cb.node);
},
cb: {
node: function(root) {
var board, img, nb, _, _ref;
if (root.className === 'inline' || !(img = $('img[alt^=Spoiler]', root))) {
return;
}
img.removeAttribute('height');
img.removeAttribute('width');
_ref = img.parentNode.href.match(/(\w+)\/src\/(\d+)/), _ = _ref[0], board = _ref[1], nb = _ref[2];
return img.src = "http://0.thumbs.4chan.org/" + board + "/thumb/" + nb + "s.jpg";
}
}
};
Time = {
init: function() {
Time.foo();
@ -2679,6 +2697,9 @@
if ($.config('Sauce')) {
sauce.init();
}
if ($.config('Reveal Spoilers')) {
revealSpoilers.init();
}
if ($.config('Anonymize')) {
anonymize.init();
}

View File

@ -30,6 +30,7 @@ config =
'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']
@ -1463,6 +1464,17 @@ sauce =
href: prefix + suffix
$.append span, $.tn(' '), link
revealSpoilers =
init: ->
g.callbacks.push revealSpoilers.cb.node
cb:
node: (root) ->
return if root.className is 'inline' or not img = $('img[alt^=Spoiler]', root)
img.removeAttribute 'height'
img.removeAttribute 'width'
[_, board, nb] = img.parentNode.href.match /(\w+)\/src\/(\d+)/
img.src = "http://0.thumbs.4chan.org/#{board}/thumb/#{nb}s.jpg"
Time =
init: ->
Time.foo()
@ -2099,6 +2111,9 @@ main =
if $.config 'Sauce'
sauce.init()
if $.config 'Reveal Spoilers'
revealSpoilers.init()
if $.config 'Anonymize'
anonymize.init()