Add Skype support

This commit is contained in:
Les De Ridder 2016-05-26 01:15:32 +02:00
parent 3e86ee7bd5
commit 4a06ac67f2
2 changed files with 19 additions and 5 deletions

View File

@ -92,15 +92,15 @@ function getBetterUrl(url, callback) {
url = url.replace("gifv", "mp4"); url = url.replace("gifv", "mp4");
} }
if(url.indexOf('pbs.twimg.com/media/') != -1 && url.indexOf(':orig') == -1) { if(isTwitterUrl(url)) {
if(url.indexOf(':') != url.lastIndexOf(':')) { //Match if there are occurences of ':' other than the ':' in 'https://', such as in '.jpg:large' if(url.indexOf(':') != url.lastIndexOf(':')) { //Match if there are occurences of ':' other than the ':' in 'https://', such as in '.jpg:large'
url = url.substr(0, url.lastIndexOf(':')); url = url.substr(0, url.lastIndexOf(':'));
} }
url = url + ':orig'; url = url + ':orig';
}
if(isInstagramUrl(url)) { callback(url);
} else if(isInstagramUrl(url)) {
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open('GET', 'https://api.instagram.com/oembed/?callback=&url=' + url, true); request.open('GET', 'https://api.instagram.com/oembed/?callback=&url=' + url, true);
request.onload = function () { request.onload = function () {
@ -145,6 +145,11 @@ function getBetterUrl(url, callback) {
makerequest("jpg"); makerequest("jpg");
}; };
pageRequest.send(); pageRequest.send();
} else if(isTwitterUrl(url)) {
url = url.substr(0, url.lastIndexOf('/'));
url = url + '/imgpsh_fullsize';
callback(url);
} else { } else {
callback(url); callback(url);
} }
@ -185,6 +190,10 @@ function cleanExtension(url) {
return url; return url;
} }
function isTwitterUrl(url) {
return url.indexOf('pbs.twimg.com/media/') != -1;
}
function isInstagramUrl(url) { function isInstagramUrl(url) {
return url.indexOf('instagram.com/p') != -1; return url.indexOf('instagram.com/p') != -1;
} }
@ -193,6 +202,10 @@ function isPixivUrl(url) {
return url.indexOf('pixiv.net/member_illust.php') != -1; return url.indexOf('pixiv.net/member_illust.php') != -1;
} }
function isSkypeUrl(url) {
return url.indexOf('api.asm.skype.com/v1/objects/') != -1;
}
function isCoolUrl(url, callback) { function isCoolUrl(url, callback) {
url = url.toLowerCase(); url = url.toLowerCase();
@ -211,8 +224,8 @@ function isCoolUrl(url, callback) {
} else { } else {
console.log('blacklist disabled!'); console.log('blacklist disabled!');
} }
callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url)); callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isSkypeUrl(url));
}); });
} }

View File

@ -53,6 +53,7 @@
* Add gfycat support * Add gfycat support
* Option to download a copy (checkbox) * Option to download a copy (checkbox)
* Error checks and messages * Error checks and messages
* Context menu item
--> -->
<button id="save">Save</button> <button id="save">Save</button>