Fool the browser cache and CloudFlare's cache when trying to reload a picture from 4chan.
This commit is contained in:
parent
0ccacc490f
commit
25276b5aac
@ -3005,9 +3005,10 @@
|
|||||||
},
|
},
|
||||||
expand: function(thumb, url) {
|
expand: function(thumb, url) {
|
||||||
var a, filesize, img, max;
|
var a, filesize, img, max;
|
||||||
|
if (thumb.hidden) return;
|
||||||
a = thumb.parentNode;
|
a = thumb.parentNode;
|
||||||
img = $.el('img', {
|
img = $.el('img', {
|
||||||
src: url ? url : a.href
|
src: url || a.href
|
||||||
});
|
});
|
||||||
if (engine === 'gecko' && a.parentNode.className !== 'op') {
|
if (engine === 'gecko' && a.parentNode.className !== 'op') {
|
||||||
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent;
|
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent;
|
||||||
@ -3019,28 +3020,29 @@
|
|||||||
return $.add(a, img);
|
return $.add(a, img);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
var req, src, thumb, url;
|
var href, req, src, thumb, url;
|
||||||
|
href = this.parentNode.href;
|
||||||
thumb = this.previousSibling;
|
thumb = this.previousSibling;
|
||||||
imgExpand.contract(thumb);
|
imgExpand.contract(thumb);
|
||||||
src = this.src.split('/');
|
src = href.split('/');
|
||||||
if (src[2] === 'images.4chan.org' && (url = redirect.image(src[3], src[5]))) {
|
if (src[2] === 'images.4chan.org' && (url = redirect.image(src[3], src[5]))) {
|
||||||
return setTimeout(imgExpand.expand, 10000, thumb, url);
|
setTimeout(imgExpand.expand, 10000, thumb, url);
|
||||||
} else if (engine === 'webkit') {
|
return;
|
||||||
|
}
|
||||||
|
url = href + '?' + Date.now();
|
||||||
|
if (engine === 'webkit') {
|
||||||
return req = $.ajax(this.src, (function() {
|
return req = $.ajax(this.src, (function() {
|
||||||
if (this.status !== 404) {
|
if (this.status !== 404) {
|
||||||
return setTimeout(imgExpand.retry, 10000, thumb);
|
return setTimeout(imgExpand.expand, 10000, thumb, url);
|
||||||
}
|
}
|
||||||
}), {
|
}), {
|
||||||
type: 'head',
|
type: 'head',
|
||||||
event: 'onreadystatechange'
|
event: 'onreadystatechange'
|
||||||
});
|
});
|
||||||
} else if (!g.dead) {
|
} else if (!g.dead) {
|
||||||
return setTimeout(imgExpand.retry, 10000, thumb);
|
return setTimeout(imgExpand.expand, 10000, thumb, url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
retry: function(thumb) {
|
|
||||||
if (!thumb.hidden) return imgExpand.expand(thumb);
|
|
||||||
},
|
|
||||||
dialog: function() {
|
dialog: function() {
|
||||||
var controls, form, imageType, select;
|
var controls, form, imageType, select;
|
||||||
controls = $.el('div', {
|
controls = $.el('div', {
|
||||||
|
|||||||
@ -2325,9 +2325,10 @@ imgExpand =
|
|||||||
$.rm thumb.nextSibling
|
$.rm thumb.nextSibling
|
||||||
|
|
||||||
expand: (thumb, url) ->
|
expand: (thumb, url) ->
|
||||||
|
return if thumb.hidden
|
||||||
a = thumb.parentNode
|
a = thumb.parentNode
|
||||||
img = $.el 'img',
|
img = $.el 'img',
|
||||||
src: if url then url else a.href
|
src: url or a.href
|
||||||
if engine is 'gecko' and a.parentNode.className isnt 'op'
|
if engine is 'gecko' and a.parentNode.className isnt 'op'
|
||||||
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent
|
filesize = $.x('preceding-sibling::span[@class="filesize"]', a).textContent
|
||||||
max = filesize.match /(\d+)x/
|
max = filesize.match /(\d+)x/
|
||||||
@ -2337,22 +2338,23 @@ imgExpand =
|
|||||||
$.add a, img
|
$.add a, img
|
||||||
|
|
||||||
error: ->
|
error: ->
|
||||||
|
href = @parentNode.href
|
||||||
thumb = @previousSibling
|
thumb = @previousSibling
|
||||||
imgExpand.contract thumb
|
imgExpand.contract thumb
|
||||||
src = @src.split '/'
|
src = href.split '/'
|
||||||
if src[2] is 'images.4chan.org' and url = redirect.image src[3], src[5]
|
if src[2] is 'images.4chan.org' and url = redirect.image src[3], src[5]
|
||||||
setTimeout imgExpand.expand, 10000, thumb, url
|
setTimeout imgExpand.expand, 10000, thumb, url
|
||||||
|
return
|
||||||
|
url = href + '?' + Date.now()
|
||||||
#navigator.online is not x-browser/os yet
|
#navigator.online is not x-browser/os yet
|
||||||
else if engine is 'webkit'
|
if engine is 'webkit'
|
||||||
req = $.ajax @src, (->
|
req = $.ajax @src, (->
|
||||||
setTimeout imgExpand.retry, 10000, thumb if @status isnt 404
|
setTimeout imgExpand.expand, 10000, thumb, url if @status isnt 404
|
||||||
), type: 'head', event: 'onreadystatechange'
|
), type: 'head', event: 'onreadystatechange'
|
||||||
#Firefox returns a status code of 0 because of the same origin policy
|
#Firefox returns a status code of 0 because of the same origin policy
|
||||||
#Oprah doesn't send any request
|
#Oprah doesn't send any request
|
||||||
else unless g.dead
|
else unless g.dead
|
||||||
setTimeout imgExpand.retry, 10000, thumb
|
setTimeout imgExpand.expand, 10000, thumb, url
|
||||||
retry: (thumb) ->
|
|
||||||
imgExpand.expand thumb unless thumb.hidden
|
|
||||||
|
|
||||||
dialog: ->
|
dialog: ->
|
||||||
controls = $.el 'div',
|
controls = $.el 'div',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user