Skip to content

Commit

Permalink
direct gif links on gfycat now become html5 video
Browse files Browse the repository at this point in the history
direct gif links on imgur now become html5 video also
  • Loading branch information
honestbleeps committed Oct 12, 2014
1 parent df233b4 commit 48b5fe1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/modules/showImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ modules['showImages'] = {
'default': {
domains: [],
acceptRegex: /^[^#]+?\.(gif|jpe?g|png)(?:[?&#_].*|$)/i,
rejectRegex: /(?:wikipedia\.org\/wiki|(?:i\.|m\.)?imgur\.com|photobucket\.com|gifsound\.com|mediacru\.sh|\/wiki\/File:.*|reddit\.com|onedrive\.live\.com|500px\.(?:com|net|org)|(?:www\.|share\.)?gifyoutube\.com)/i,
rejectRegex: /(?:wikipedia\.org\/wiki|(?:i\.|m\.)?imgur\.com|photobucket\.com|gifsound\.com|mediacru\.sh|gfycat\.com|\/wiki\/File:.*|reddit\.com|onedrive\.live\.com|500px\.(?:com|net|org)|(?:www\.|share\.)?gifyoutube\.com)/i,
detect: function(href, elem) {
var siteMod = modules['showImages'].siteModules['default'];
return (siteMod.acceptRegex.test(href) && !siteMod.rejectRegex.test(href));
Expand Down Expand Up @@ -2084,7 +2084,7 @@ modules['showImages'] = {
// removed caption API calls as they don't seem to exist/matter for single images, only albums...
//If we don't show captions, then we can skip the API call.
extension = groups[2] || '.jpg';
if (extension === '.gifv') {
if (extension === '.gifv' || extension === '.gif') {
def.resolve(elem, {
gifv: {
webmUrl: location.protocol + '//i.imgur.com/' + groups[1] + '.webm',
Expand Down Expand Up @@ -2276,13 +2276,15 @@ modules['showImages'] = {
return href.indexOf('gfycat.com') !== -1 && href.substring(-1) !== '+';
},
handleLink: function(elem) {
var hashRe = /^https?:\/\/[a-zA-Z0-9\-\.]*gfycat\.com\/(\w+)\.?/i;
var hashRe = /^https?:\/\/(?:[\w]+.)?gfycat\.com\/(\w+)(?:\.gif)?/i;
var def = $.Deferred();
var groups = hashRe.exec(elem.href);

console.log(groups, elem.href);
if (!groups) return def.reject();
var href = elem.href.toLowerCase();


var siteMod = modules['showImages'].siteModules['gfycat'];
var apiURL = location.protocol + '//gfycat.com/cajax/get/' + encodeURIComponent(groups[1]);

Expand Down

0 comments on commit 48b5fe1

Please sign in to comment.