Add support for 500px.com

This commit is contained in:
Les De Ridder 2016-07-15 20:07:18 +02:00
parent e370002163
commit c76b5016ae
1 changed files with 23 additions and 1 deletions

View File

@ -176,6 +176,24 @@ function getBetterUrl(url, callback) {
var base = 'https://ixquick.com/cgi-bin/serveimage';
callback(base + "?url=" + encodeURI(query.oiu) + "&sp=" + query.sp);
} else if(is500pxUrl(url)) {
//TODO: Use a content script instead of re-fetching the page
var pageRequest = new XMLHttpRequest();
pageRequest.open('GET', url, true);
pageRequest.onload = function () {
var regex = /window.PxPreloadedData = (.*);/g;
var match = regex.exec(pageRequest.responseText);
var json = match[1];
var object = JSON.parse(json);
var imageUrl = object.photo.images.filter(function (image) { return image.size >= 2048; })[0].https_url;
callback(imageUrl);
};
pageRequest.send();
} else {
callback(url);
}
@ -269,6 +287,10 @@ function isIxquickProxyUrl(url) {
return url.indexOf('ixquick-proxy.com/do/spg/show_picture.pl') != -1;
}
function is500pxUrl(url) {
return url.indexOf('500px.com/photo/') != -1;
}
function isCoolUrl(url, callback) {
var proxiedUrl = getProxiedUrl(url);
if(proxiedUrl != null) {
@ -293,7 +315,7 @@ function isCoolUrl(url, callback) {
console.log('blacklist disabled!');
}
callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isPixivUrl(url) || isSkypeUrl(url) || isGfycatUrl(url) || isIxquickProxyUrl(url));
callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isPixivUrl(url) || isSkypeUrl(url) || isGfycatUrl(url) || isIxquickProxyUrl(url) || is500pxUrl(url));
});
}