From 4a06ac67f250bada3415923fde1ff8348e49228e Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Thu, 26 May 2016 01:15:32 +0200 Subject: [PATCH] Add Skype support --- background.js | 23 ++++++++++++++++++----- options.html | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/background.js b/background.js index 600fc60..445d9ae 100644 --- a/background.js +++ b/background.js @@ -92,15 +92,15 @@ function getBetterUrl(url, callback) { 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' url = url.substr(0, url.lastIndexOf(':')); } url = url + ':orig'; - } - if(isInstagramUrl(url)) { + callback(url); + } else if(isInstagramUrl(url)) { var request = new XMLHttpRequest(); request.open('GET', 'https://api.instagram.com/oembed/?callback=&url=' + url, true); request.onload = function () { @@ -145,6 +145,11 @@ function getBetterUrl(url, callback) { makerequest("jpg"); }; pageRequest.send(); + } else if(isTwitterUrl(url)) { + url = url.substr(0, url.lastIndexOf('/')); + url = url + '/imgpsh_fullsize'; + + callback(url); } else { callback(url); } @@ -185,6 +190,10 @@ function cleanExtension(url) { return url; } +function isTwitterUrl(url) { + return url.indexOf('pbs.twimg.com/media/') != -1; +} + function isInstagramUrl(url) { return url.indexOf('instagram.com/p') != -1; } @@ -193,6 +202,10 @@ function isPixivUrl(url) { 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) { url = url.toLowerCase(); @@ -211,8 +224,8 @@ function isCoolUrl(url, callback) { } else { console.log('blacklist disabled!'); } - - callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url)); + + callback(validExtensions.indexOf(extension) != -1 || isInstagramUrl(url) || isSkypeUrl(url)); }); } diff --git a/options.html b/options.html index 1a207d1..582e955 100644 --- a/options.html +++ b/options.html @@ -53,6 +53,7 @@ * Add gfycat support * Option to download a copy (checkbox) * Error checks and messages + * Context menu item -->