Ah! I got it!
This was very tricky. The basic way this works is to first write out a new url pattern for the new site. This gets us past the first redirect. The second redirect was trickier. I had to start up an AJAX request to get the second URL. Then I had to read the header response in the second page to get the third url. Then the third url is requeued.
mypublicpix.com seems to now be entirely defunct so this new search pattern might as well replace the existing one.
<host id="mypublicpix">
<urlpattern>^http:\/\/www\d*\.mypublicpix\.com\/index\.php\?img=.+</urlpattern>
<searchpattern><![CDATA[function(pageData, pageUrl) {
var retVal = new Object();
var newUrl;
var req = new XMLHttpRequest()
newUrl = pageUrl.replace(/(http:\/\/www\d*\.mypublicpix\.com\/index\.php)(.+)/, "http://imagearn.com/imagearn.php$2");
req.open("GET", newUrl, false);
req.send(null);
newUrl = req.getResponseHeader("refresh");
newUrl = newUrl.match(/url=(http:\/\/[^:"'<>]+)/i);
if (!newUrl)
{
retVal.imgUrl = null;
retVal.status = "ABORT";
}
else
{
retVal.imgUrl = newUrl[1];
retVal.status = "REQUEUE";
}
return retVal;
}]]></searchpattern>
</host>