Fix Pixiv support

This commit is contained in:
Les De Ridder 2016-05-05 17:14:33 +02:00
parent 7d5e229317
commit ee3a9988a2
1 changed files with 17 additions and 7 deletions

View File

@ -124,15 +124,25 @@ function getBetterUrl(url, callback) {
var match = regex.exec(pageRequest.responseText);
var imageUrl = 'http://i3.pixiv.net/img-original/' + match[1] + match[2];
var imageUrl = 'http://i3.pixiv.net/img-original/' + match[1];
var imageRequest = new XMLHttpRequest();
imageRequest.open('GET', imageUrl, true);
imageRequest.setRequestHeader('X-Pixiv-Referer', url);
imageRequest.onload = function () {
callback(imageUrl);
var onload = function (imageRequest, extension) {
if(imageRequest.status == 404 && extension == "jpg") {
makerequest("png");
} else {
callback(imageUrl + "." + extension);
}
};
imageRequest.send();
var makerequest = function(extension) {
var imageRequest = new XMLHttpRequest();
imageRequest.open('GET', imageUrl + "." + extension, true);
imageRequest.setRequestHeader('X-Pixiv-Referer', url);
imageRequest.onload = function() { onload(imageRequest, extension); };
imageRequest.send();
};
makerequest("jpg");
};
pageRequest.send();
} else {