Fix #517
This commit is contained in:
parent
55a036708e
commit
daac7ce5ee
@ -3620,12 +3620,11 @@
|
||||
return location.href = url;
|
||||
}
|
||||
},
|
||||
image: function(href) {
|
||||
href = href.split('/');
|
||||
image: function(board, filename) {
|
||||
if (!Conf['404 Redirect']) {
|
||||
return;
|
||||
}
|
||||
switch (href[3]) {
|
||||
switch (board) {
|
||||
case 'a':
|
||||
case 'co':
|
||||
case 'jp':
|
||||
@ -3633,7 +3632,7 @@
|
||||
case 'tg':
|
||||
case 'u':
|
||||
case 'vg':
|
||||
return "http://archive.foolz.us/" + href[3] + "/full_image/" + href[5];
|
||||
return "http://archive.foolz.us/" + board + "/full_image/" + filename;
|
||||
}
|
||||
},
|
||||
thread: function(board, id, mode) {
|
||||
@ -3712,6 +3711,7 @@
|
||||
});
|
||||
$.add(d.body, el);
|
||||
$.on(el, 'load', ImageHover.load);
|
||||
$.on(el, 'error', ImageHover.error);
|
||||
$.on(this, 'mousemove', UI.hover);
|
||||
return $.on(this, 'mouseout', ImageHover.mouseout);
|
||||
},
|
||||
@ -3726,6 +3726,32 @@
|
||||
clientY: 120 + parseInt(style.top)
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
var src, timeoutID, url,
|
||||
_this = this;
|
||||
src = this.src.replace(/\?\d+$/, '').split('/');
|
||||
if (!(src[2] === 'images.4chan.org' && (url = Redirect.image(src[3], src[5])))) {
|
||||
if (g.dead) {
|
||||
return;
|
||||
}
|
||||
url = "//images.4chan.org/" + src[3] + "/src/" + src[5] + "?" + (Date.now());
|
||||
}
|
||||
timeoutID = setTimeout((function() {
|
||||
return _this.src = url;
|
||||
}), 3000);
|
||||
if (!($.engine === 'webkit' && src[2] === 'images.4chan.org')) {
|
||||
return;
|
||||
}
|
||||
return $.ajax(url, {
|
||||
onreadystatechange: (function() {
|
||||
if (this.status === 404) {
|
||||
return clearTimeout(timeoutID);
|
||||
}
|
||||
})
|
||||
}, {
|
||||
type: 'head'
|
||||
});
|
||||
},
|
||||
mouseout: function() {
|
||||
UI.hoverend();
|
||||
$.off(this, 'mousemove', UI.hover);
|
||||
@ -3883,16 +3909,16 @@
|
||||
return $.add(a, img);
|
||||
},
|
||||
error: function() {
|
||||
var href, thumb, timeoutID, url;
|
||||
href = this.parentNode.href;
|
||||
var src, thumb, timeoutID, url;
|
||||
thumb = this.previousSibling;
|
||||
ImageExpand.contract(thumb);
|
||||
$.rm(this);
|
||||
if (!(this.src.split('/')[2] === 'images.4chan.org' && (url = Redirect.image(href)))) {
|
||||
src = this.src.replace(/\?\d+$/, '').split('/');
|
||||
if (!(src[2] === 'images.4chan.org' && (url = Redirect.image(src[3], src[5])))) {
|
||||
if (g.dead) {
|
||||
return;
|
||||
}
|
||||
url = href + '?' + Date.now();
|
||||
url = "//images.4chan.org/" + src[3] + "/src/" + src[5] + "?" + (Date.now());
|
||||
}
|
||||
timeoutID = setTimeout(ImageExpand.expand, 10000, thumb, url);
|
||||
if (!($.engine === 'webkit' && url.split('/')[2] === 'images.4chan.org')) {
|
||||
|
||||
@ -2767,13 +2767,12 @@ Redirect =
|
||||
else if /^\d+$/.test g.THREAD_ID
|
||||
@thread()
|
||||
location.href = url if url
|
||||
image: (href) ->
|
||||
href = href.split '/'
|
||||
image: (board, filename) ->
|
||||
# Do not use g.BOARD, the image url can originate from a cross-quote.
|
||||
return unless Conf['404 Redirect']
|
||||
switch href[3]
|
||||
switch board
|
||||
when 'a', 'co', 'jp', 'm', 'tg', 'u', 'vg'
|
||||
"http://archive.foolz.us/#{href[3]}/full_image/#{href[5]}"
|
||||
"http://archive.foolz.us/#{board}/full_image/#{filename}"
|
||||
thread: (board=g.BOARD, id=g.THREAD_ID, mode='thread') ->
|
||||
return unless Conf['404 Redirect'] or mode is 'post'
|
||||
switch board
|
||||
@ -2817,6 +2816,7 @@ ImageHover =
|
||||
src: @parentNode.href
|
||||
$.add d.body, el
|
||||
$.on el, 'load', ImageHover.load
|
||||
$.on el, 'error', ImageHover.error
|
||||
$.on @, 'mousemove', UI.hover
|
||||
$.on @, 'mouseout', ImageHover.mouseout
|
||||
load: ->
|
||||
@ -2826,6 +2826,20 @@ ImageHover =
|
||||
UI.hover
|
||||
clientX: - 45 + parseInt style.left
|
||||
clientY: 120 + parseInt style.top
|
||||
error: ->
|
||||
src = @src.replace(/\?\d+$/, '').split '/'
|
||||
unless src[2] is 'images.4chan.org' and url = Redirect.image src[3], src[5]
|
||||
return if g.dead
|
||||
# CloudFlare may cache banned pages instead of images.
|
||||
# This will fool CloudFlare's cache.
|
||||
url = "//images.4chan.org/#{src[3]}/src/#{src[5]}?#{Date.now()}"
|
||||
# navigator.online is not x-browser/os yet
|
||||
timeoutID = setTimeout (=> @src = url), 3000
|
||||
# Only Chrome let userscript break through cross domain requests.
|
||||
# Don't check it 404s in the archivers.
|
||||
return unless $.engine is 'webkit' and src[2] is 'images.4chan.org'
|
||||
$.ajax url, onreadystatechange: (-> clearTimeout timeoutID if @status is 404),
|
||||
type: 'head'
|
||||
mouseout: ->
|
||||
UI.hoverend()
|
||||
$.off @, 'mousemove', UI.hover
|
||||
@ -2931,15 +2945,15 @@ ImageExpand =
|
||||
$.add a, img
|
||||
|
||||
error: ->
|
||||
href = @parentNode.href
|
||||
thumb = @previousSibling
|
||||
ImageExpand.contract thumb
|
||||
$.rm @
|
||||
unless @src.split('/')[2] is 'images.4chan.org' and url = Redirect.image href
|
||||
src = @src.replace(/\?\d+$/, '').split '/'
|
||||
unless src[2] is 'images.4chan.org' and url = Redirect.image src[3], src[5]
|
||||
return if g.dead
|
||||
# CloudFlare may cache banned pages instead of images.
|
||||
# This will fool CloudFlare's cache.
|
||||
url = href + '?' + Date.now()
|
||||
url = "//images.4chan.org/#{src[3]}/src/#{src[5]}?#{Date.now()}"
|
||||
#navigator.online is not x-browser/os yet
|
||||
timeoutID = setTimeout ImageExpand.expand, 10000, thumb, url
|
||||
# Only Chrome let userscript break through cross domain requests.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user