From 0e076a1bcfaa65866bb6afc93059e0327ba1eb82 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 29 Nov 2011 07:07:21 +0100 Subject: [PATCH] Firefox returns status code 0 for cross domain requests, don't reload pictures only in 404'd threads. Close #22 --- 4chan_x.user.js | 4 ++-- changelog | 1 + script.coffee | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 6ddebda98..da7a1f526 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2876,7 +2876,7 @@ img = $.el('img', { src: a.href }); - if (engine === "gecko" && a.parentNode.className !== 'op') { + if (engine === 'gecko' && a.parentNode.className !== 'op') { filesize = $('.filesize', a.parentNode); _ref = filesize.textContent.match(/(\d+)x/), _ = _ref[0], max = _ref[1]; img.style.maxWidth = "" + max + "px"; @@ -2889,7 +2889,7 @@ var req, thumb; thumb = this.previousSibling; imgExpand.contract(thumb); - if (navigator.appName !== 'Opera') { + if (engine === 'webkit') { req = $.ajax(this.src, null, 'head'); return req.onreadystatechange = function() { if (this.status !== 404) { diff --git a/changelog b/changelog index 6735dd549..6499d7fb6 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ master - mayhem new Indicate Duckrolls feature put regex.info sauce back - disabled by default + fix for auto image reloading in 404'd threads on Firefox 2.21.4 - mayhem diff --git a/script.coffee b/script.coffee index aedae8e9a..17f2c9fc8 100644 --- a/script.coffee +++ b/script.coffee @@ -2203,7 +2203,7 @@ imgExpand = a = thumb.parentNode img = $.el 'img', src: a.href - if engine is "gecko" and a.parentNode.className isnt 'op' + if engine is 'gecko' and a.parentNode.className isnt 'op' filesize = $ '.filesize', a.parentNode [_, max] = filesize.textContent.match /(\d+)x/ img.style.maxWidth = "#{max}px" @@ -2215,9 +2215,11 @@ imgExpand = thumb = @previousSibling imgExpand.contract thumb #navigator.online is not x-browser/os yet - if navigator.appName isnt 'Opera' + if engine is 'webkit' req = $.ajax @src, null, 'head' req.onreadystatechange = -> setTimeout imgExpand.retry, 10000, thumb if @status isnt 404 + #Firefox returns a status code of 0 because of the same origin policy + #Oprah doesn't send any request else unless g.dead setTimeout imgExpand.retry, 10000, thumb retry: (thumb) ->