Fix Pixiv support
This commit is contained in:
parent
7d5e229317
commit
ee3a9988a2
|
@ -124,16 +124,26 @@ function getBetterUrl(url, callback) {
|
||||||
|
|
||||||
var match = regex.exec(pageRequest.responseText);
|
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();
|
var onload = function (imageRequest, extension) {
|
||||||
imageRequest.open('GET', imageUrl, true);
|
if(imageRequest.status == 404 && extension == "jpg") {
|
||||||
imageRequest.setRequestHeader('X-Pixiv-Referer', url);
|
makerequest("png");
|
||||||
imageRequest.onload = function () {
|
} else {
|
||||||
callback(imageUrl);
|
callback(imageUrl + "." + extension);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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();
|
imageRequest.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
makerequest("jpg");
|
||||||
|
};
|
||||||
pageRequest.send();
|
pageRequest.send();
|
||||||
} else {
|
} else {
|
||||||
callback(url);
|
callback(url);
|
||||||
|
|
Loading…
Reference in New Issue