Add experimental Instagram support
This commit is contained in:
parent
8cbbf0f9f2
commit
8c3a4c3f15
|
@ -99,6 +99,22 @@ function getBetterUrl(url) {
|
|||
url = url + ':orig';
|
||||
}
|
||||
|
||||
|
||||
if(isInstagramUrl(url)) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', 'https://api.instagram.com/oembed/?callback=&url=' + url, false); //TODO: Make this asynchronous somehow
|
||||
request.send(null);
|
||||
|
||||
var json = JSON.parse(request.responseText);
|
||||
|
||||
var filename = json.thumbnail_url.substr(json.thumbnail_url.lastIndexOf('/') + 1);
|
||||
filename = filename.substr(0, filename.indexOf('?'));
|
||||
|
||||
var baseurl = 'https://scontent-amt2-1.cdninstagram.com/';
|
||||
|
||||
return baseurl + '/' + filename;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
@ -114,6 +130,10 @@ function cleanExtension(url) {
|
|||
return url;
|
||||
}
|
||||
|
||||
function isInstagramUrl(url) {
|
||||
return url.indexOf('instagram.com/p') != -1;
|
||||
}
|
||||
|
||||
function isCoolUrl(url) {
|
||||
url = url.toLowerCase();
|
||||
|
||||
|
@ -122,7 +142,7 @@ function isCoolUrl(url) {
|
|||
|
||||
var validExtensions = ["jpg", "jpeg", "png", "gif", "webm", "gifv", "mp4", "mp3", "ogg", "opus"];
|
||||
|
||||
return validExtensions.indexOf(extension) != -1;
|
||||
return validExtensions.indexOf(extension) != -1 || isInstagramUrl(url);
|
||||
}
|
||||
|
||||
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
* Add pixiv support
|
||||
* Add progress/status messages
|
||||
* Add imageboard thread archival support
|
||||
* Add instagram support
|
||||
* Add booru support
|
||||
* Add imgur album support
|
||||
* Add gfycat support
|
||||
|
|
Loading…
Reference in New Issue