Cache sauce functions.
This commit is contained in:
parent
7a2eee99f7
commit
3a13f86258
@ -2588,12 +2588,24 @@
|
|||||||
|
|
||||||
sauce = {
|
sauce = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var link, links, _i, _len;
|
var domain, fc, link, links, _i, _len;
|
||||||
links = conf['sauces'].match(/^[^#].+$/gm);
|
links = conf['sauces'].match(/^[^#].+$/gm);
|
||||||
|
if (!links.length) return;
|
||||||
this.links = [];
|
this.links = [];
|
||||||
for (_i = 0, _len = links.length; _i < _len; _i++) {
|
for (_i = 0, _len = links.length; _i < _len; _i++) {
|
||||||
link = links[_i];
|
link = links[_i];
|
||||||
this.links.push([link, link.match(/(\w+)\.\w+\//)[1]]);
|
domain = link.match(/(\w+)\.\w+\//)[1];
|
||||||
|
fc = link.replace(/\$\d/, function(fragment) {
|
||||||
|
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]);
|
||||||
}
|
}
|
||||||
return g.callbacks.push(this.node);
|
return g.callbacks.push(this.node);
|
||||||
},
|
},
|
||||||
@ -2605,24 +2617,12 @@
|
|||||||
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', {
|
a = $.el('a', {
|
||||||
textContent: link[1],
|
href: link[0](img),
|
||||||
href: sauce.href(link[0], img),
|
target: '_blank',
|
||||||
target: '_blank'
|
textContent: link[1]
|
||||||
});
|
});
|
||||||
$.add(span, $.tn(' '), a);
|
$.add(span, $.tn(' '), a);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
href: function(link, img) {
|
|
||||||
return link.replace(/\$\d/, function(fragment) {
|
|
||||||
switch (fragment) {
|
|
||||||
case '$1':
|
|
||||||
return img.src;
|
|
||||||
case '$2':
|
|
||||||
return img.parentNode.href;
|
|
||||||
case '$3':
|
|
||||||
return img.getAttribute('md5').replace(/\=+$/, '');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2051,31 +2051,31 @@ anonymize =
|
|||||||
|
|
||||||
sauce =
|
sauce =
|
||||||
init: ->
|
init: ->
|
||||||
# return unless
|
|
||||||
links = conf['sauces'].match /^[^#].+$/gm
|
links = conf['sauces'].match /^[^#].+$/gm
|
||||||
|
return unless links.length
|
||||||
@links = []
|
@links = []
|
||||||
for link in links
|
for link in links
|
||||||
@links.push [link, link.match(/(\w+)\.\w+\//)[1]]
|
domain = link.match(/(\w+)\.\w+\//)[1]
|
||||||
|
fc = link.replace /\$\d/, (fragment) ->
|
||||||
|
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
|
||||||
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',
|
a = $.el 'a',
|
||||||
textContent: link[1]
|
href: link[0] img
|
||||||
href: sauce.href link[0], img
|
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
|
textContent: link[1]
|
||||||
$.add span, $.tn(' '), a
|
$.add span, $.tn(' '), a
|
||||||
return
|
return
|
||||||
href: (link, img) ->
|
|
||||||
link.replace /\$\d/, (fragment) ->
|
|
||||||
switch fragment
|
|
||||||
when '$1'
|
|
||||||
img.src
|
|
||||||
when '$2'
|
|
||||||
img.parentNode.href
|
|
||||||
when '$3'
|
|
||||||
img.getAttribute('md5').replace /\=+$/, ''
|
|
||||||
|
|
||||||
revealSpoilers =
|
revealSpoilers =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user