Use closures for sauces, small improvement for image spoiler revealer, fix sauces using thumbnails in case of spoiled image.
This commit is contained in:
parent
eb0b2399b6
commit
658ebb26c0
@ -2629,40 +2629,46 @@
|
|||||||
|
|
||||||
sauce = {
|
sauce = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var domain, fc, link, links, _i, _len;
|
var link, _i, _len, _ref;
|
||||||
links = conf['sauces'].match(/^[^#].+$/gm);
|
|
||||||
if (!links.length) return;
|
|
||||||
this.links = [];
|
this.links = [];
|
||||||
for (_i = 0, _len = links.length; _i < _len; _i++) {
|
_ref = conf['sauces'].match(/^[^#].+$/gm);
|
||||||
link = links[_i];
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
domain = link.match(/(\w+)\.\w+\//)[1];
|
link = _ref[_i];
|
||||||
fc = link.replace(/\$\d/, function(fragment) {
|
this.links.push(this.funk(link));
|
||||||
switch (fragment) {
|
|
||||||
case '$1':
|
|
||||||
return "' + img.src + '";
|
|
||||||
case '$2':
|
|
||||||
return "' + img.parentNode.href + '";
|
|
||||||
case '$3':
|
|
||||||
return "' + img.getAttribute('md5').replace(/\=*$/, '') + '";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.links.push([Function('img', "return '" + fc + "'"), domain]);
|
|
||||||
}
|
}
|
||||||
|
if (!this.links.length) return;
|
||||||
return g.callbacks.push(this.node);
|
return g.callbacks.push(this.node);
|
||||||
},
|
},
|
||||||
|
funk: function(link) {
|
||||||
|
var domain, href;
|
||||||
|
domain = link.match(/(\w+)\.\w+\//)[1];
|
||||||
|
href = link.replace(/(\$\d)/, function(fragment) {
|
||||||
|
switch (fragment) {
|
||||||
|
case '$1':
|
||||||
|
return "http://thumbs.4chan.org' + img.parentNode.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '";
|
||||||
|
case '$2':
|
||||||
|
return "' + img.parentNode.href + '";
|
||||||
|
case '$3':
|
||||||
|
return "' + img.getAttribute('md5').replace(/\=*$/, '') + '";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
href = Function('img', "return '" + href + "'");
|
||||||
|
return function(img) {
|
||||||
|
return $.el('a', {
|
||||||
|
href: href(img),
|
||||||
|
target: '_blank',
|
||||||
|
textContent: domain
|
||||||
|
});
|
||||||
|
};
|
||||||
|
},
|
||||||
node: function(root) {
|
node: function(root) {
|
||||||
var a, img, link, span, _i, _len, _ref;
|
var img, link, span, _i, _len, _ref;
|
||||||
if (root.className === 'inline' || !(span = $('.filesize', root))) return;
|
if (root.className === 'inline' || !(span = $('.filesize', root))) return;
|
||||||
img = $('img', root);
|
img = $('img', root);
|
||||||
_ref = sauce.links;
|
_ref = sauce.links;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
link = _ref[_i];
|
link = _ref[_i];
|
||||||
a = $.el('a', {
|
$.add(span, $.tn(' '), link(img));
|
||||||
href: link[0](img),
|
|
||||||
target: '_blank',
|
|
||||||
textContent: link[1]
|
|
||||||
});
|
|
||||||
$.add(span, $.tn(' '), a);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2672,14 +2678,13 @@
|
|||||||
return g.callbacks.push(this.node);
|
return g.callbacks.push(this.node);
|
||||||
},
|
},
|
||||||
node: function(root) {
|
node: function(root) {
|
||||||
var board, img, imgID, _, _ref;
|
var img;
|
||||||
if (!(img = $('img[alt^=Spoiler]', root)) || root.className === 'inline') {
|
if (!(img = $('img[alt^=Spoil]', root)) || root.className === 'inline') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
img.removeAttribute('height');
|
img.removeAttribute('height');
|
||||||
img.removeAttribute('width');
|
img.removeAttribute('width');
|
||||||
_ref = img.parentNode.href.match(/(\w+)\/src\/(\d+)/), _ = _ref[0], board = _ref[1], imgID = _ref[2];
|
return img.src = "http://thumbs.4chan.org" + (img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg'));
|
||||||
return img.src = "http://0.thumbs.4chan.org/" + board + "/thumb/" + imgID + "s.jpg";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
master
|
master
|
||||||
- Mayhem
|
- Mayhem
|
||||||
You can now drag replies in the dump list to reorder them.
|
You can now drag replies in the dump list to reorder them.
|
||||||
|
Fix sauce links for spoiler thumbnails.
|
||||||
|
|
||||||
2.26.0
|
2.26.0
|
||||||
- desuwa
|
- desuwa
|
||||||
|
|||||||
@ -2085,41 +2085,44 @@ anonymize =
|
|||||||
|
|
||||||
sauce =
|
sauce =
|
||||||
init: ->
|
init: ->
|
||||||
links = conf['sauces'].match /^[^#].+$/gm
|
|
||||||
return unless links.length
|
|
||||||
@links = []
|
@links = []
|
||||||
for link in links
|
for link in conf['sauces'].match /^[^#].+$/gm
|
||||||
domain = link.match(/(\w+)\.\w+\//)[1]
|
@links.push @funk link
|
||||||
fc = link.replace /\$\d/, (fragment) ->
|
return unless @links.length
|
||||||
switch fragment
|
|
||||||
when '$1'
|
|
||||||
"' + img.src + '"
|
|
||||||
when '$2'
|
|
||||||
"' + img.parentNode.href + '"
|
|
||||||
when '$3'
|
|
||||||
"' + img.getAttribute('md5').replace(/\=*$/, '') + '"
|
|
||||||
@links.push [Function('img', "return '#{fc}'"), domain]
|
|
||||||
g.callbacks.push @node
|
g.callbacks.push @node
|
||||||
|
|
||||||
|
funk: (link) ->
|
||||||
|
domain = link.match(/(\w+)\.\w+\//)[1]
|
||||||
|
href = link.replace /(\$\d)/, (fragment) ->
|
||||||
|
switch fragment
|
||||||
|
when '$1'
|
||||||
|
"http://thumbs.4chan.org' + img.parentNode.pathname.replace(/src(\\/\\d+).+$/, 'thumb$1s.jpg') + '"
|
||||||
|
when '$2'
|
||||||
|
"' + img.parentNode.href + '"
|
||||||
|
when '$3'
|
||||||
|
"' + img.getAttribute('md5').replace(/\=*$/, '') + '"
|
||||||
|
href = Function 'img', "return '#{href}'"
|
||||||
|
(img) ->
|
||||||
|
$.el 'a',
|
||||||
|
href: href img
|
||||||
|
target: '_blank'
|
||||||
|
textContent: domain
|
||||||
|
|
||||||
node: (root) ->
|
node: (root) ->
|
||||||
return if root.className is 'inline' or not span = $ '.filesize', root
|
return if root.className is 'inline' or not span = $ '.filesize', root
|
||||||
img = $ 'img', root
|
img = $ 'img', root
|
||||||
for link in sauce.links
|
for link in sauce.links
|
||||||
a = $.el 'a',
|
$.add span, $.tn(' '), link img
|
||||||
href: link[0] img
|
|
||||||
target: '_blank'
|
|
||||||
textContent: link[1]
|
|
||||||
$.add span, $.tn(' '), a
|
|
||||||
return
|
return
|
||||||
|
|
||||||
revealSpoilers =
|
revealSpoilers =
|
||||||
init: ->
|
init: ->
|
||||||
g.callbacks.push @node
|
g.callbacks.push @node
|
||||||
node: (root) ->
|
node: (root) ->
|
||||||
return if not (img = $ 'img[alt^=Spoiler]', root) or root.className is 'inline'
|
return if not (img = $ 'img[alt^=Spoil]', root) or root.className is 'inline'
|
||||||
img.removeAttribute 'height'
|
img.removeAttribute 'height'
|
||||||
img.removeAttribute 'width'
|
img.removeAttribute 'width'
|
||||||
[_, board, imgID] = img.parentNode.href.match /(\w+)\/src\/(\d+)/
|
img.src = "http://thumbs.4chan.org#{img.parentNode.pathname.replace(/src(\/\d+).+$/, 'thumb$1s.jpg')}"
|
||||||
img.src = "http://0.thumbs.4chan.org/#{board}/thumb/#{imgID}s.jpg"
|
|
||||||
|
|
||||||
Time =
|
Time =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user