diff --git a/manifest.json b/manifest.json index 036d3eca5..8fbcab777 100644 --- a/manifest.json +++ b/manifest.json @@ -78,7 +78,8 @@ "plugins/cloudapp_a.js", "plugins/google_a.js", "plugins/facebook_a.js", - "plugins/bing_a.js" + "plugins/bing_a.js", + "plugins/medium_a.js" ], "matches": [""], "all_frames": true diff --git a/plugins/flixster.js b/plugins/flixster.js index 7d01b1d99..eb41b0211 100644 --- a/plugins/flixster.js +++ b/plugins/flixster.js @@ -1,14 +1,50 @@ var hoverZoomPlugins = hoverZoomPlugins || []; hoverZoomPlugins.push({ name:'Flixster', - version:'0.1', + version:'0.2', prepareImgLinks:function (callback) { var res = []; + hoverZoom.urlReplace(res, 'a img[src*="_tmb."]:not([src*="/critic/"]), a img[src*="_msq."], a img[src*="_pro."]', /_(tmb|msq|pro)\./, '_gal.' ); - callback($(res)); + + //sample url: https://resizing.flixster.com/IaXbRF4gIPh9jireK_4VCPNfdKc=/300x0/v2/https://flxt.tmsimg.com/v9/AllPhotos/488370/488370_v9_ba.jpg + // -> https://flxt.tmsimg.com/v9/AllPhotos/488370/488370_v9_ba.jpg + var reShorten = /(.*)http(.*)/; + hoverZoom.urlReplace(res, + 'img[src]', + reShorten, + 'http$2' + ); + + $('[style*=background]').each(function() { + var link = $(this); + // extract url from style + var backgroundImage = this.style.backgroundImage; + if (backgroundImage.indexOf("url") != -1) { + var reUrl = /.*url\s*\(\s*(.*)\s*\).*/i + backgroundImage = backgroundImage.replace(reUrl, '$1'); + // remove leading & trailing quotes + var backgroundImageUrl = backgroundImage.replace(/^['"]/,"").replace(/['"]+$/,""); + + $([reShorten]).each(function() { + + var fullsizeUrl = backgroundImageUrl.replace(this, 'http$2'); + if (fullsizeUrl != backgroundImageUrl) { + + if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] } + if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) { + link.data().hoverZoomSrc.unshift(fullsizeUrl); + res.push(link); + } + } + }); + } + }); + + callback($(res), this.name); } }); \ No newline at end of file diff --git a/plugins/fotolog.js b/plugins/fotolog.js index 94f2520b9..ccbea6024 100644 --- a/plugins/fotolog.js +++ b/plugins/fotolog.js @@ -1,13 +1,20 @@ var hoverZoomPlugins = hoverZoomPlugins || []; hoverZoomPlugins.push({ name:'Fotolog', - version:'0.1', + version:'0.2', prepareImgLinks:function (callback) { var res = [], filter = 'img[src*="_t."], img[src*="_m."]', search = /_(t|m)\./; hoverZoom.urlReplace(res, filter, search, '.'); hoverZoom.urlReplace(res, filter, search, '_f.'); - callback($(res)); + + hoverZoom.urlReplace(res, + 'img[src]', + /-\d+x\d+/, + '' + ); + + callback($(res), this.name); } }); diff --git a/plugins/google_a.js b/plugins/google_a.js index c757d5615..9f10f7ec9 100644 --- a/plugins/google_a.js +++ b/plugins/google_a.js @@ -8,6 +8,8 @@ hoverZoomPlugins.push({ //sample url: https://lh3.googleusercontent.com/oAO8qHLtaT5JHCvojKRL0IvjoXPM1aR22eDXh17eCsCgjeCL1_A6mIIUQD19kF3kVg=w192-c-h192-fcrop64=1,00000b5cffffdde9-rw-v1 // -> https://lh3.googleusercontent.com/oAO8qHLtaT5JHCvojKRL0IvjoXPM1aR22eDXh17eCsCgjeCL1_A6mIIUQD19kF3kVg=s0 + //sample url: https://yt3.ggpht.com/ytc/AAUvwngFPLZ-IsxaXxKW1fFJ1aI34VnPWiCCH8kKRauw=s68-c-k-c0x00ffffff-no-rj + // -> https://yt3.ggpht.com/ytc/AAUvwngFPLZ-IsxaXxKW1fFJ1aI34VnPWiCCH8kKRauw=s0 var regex1 = /(.*?=)(.*)/; var patch1 = '$1s0'; @@ -18,10 +20,15 @@ hoverZoomPlugins.push({ var regex2 = /(.*)\/.*\//; var patch2 = '$1/s0/'; + //sample url: https://lh5.googleusercontent.com/-qnv3HcOTfdU/AAAAAAAAAAI/AAAAAAAAECY/LDjaha4DLVQ/photo.jpg?sz=64 + // -> https://lh5.googleusercontent.com/-qnv3HcOTfdU/AAAAAAAAAAI/AAAAAAAAECY/LDjaha4DLVQ/photo.jpg + var regex3 = /(.*photo.jpg)\?.*/; + var patch3 = '$1'; + //sample url: http://geo3.ggpht.com/cbk?panoid=50XRgCiXEq6wuqYWcGQ3BQ&output=thumbnail&cb_client=search.gws-prod.gps&thumb=0&w=100&h=100&yaw=277.2657&pitch=0&thumbfov=100 // -> http://geo3.ggpht.com/cbk?panoid=50XRgCiXEq6wuqYWcGQ3BQ&output=thumbnail&cb_client=search.gws-prod.gps&thumb=0&w=9999&h=9999&yaw=277.2657&pitch=0&thumbfov=100 - var regex3 = /(&[hw]{1})=\d+/g; - var patch3 = '$1=9999'; + var regex4 = /(&[hw]{1})=\d+/g; + var patch4 = '$1=9999'; hoverZoom.urlReplace(res, 'img[src*=".googleusercontent.com/"], img[src*=".ggpht.com/"]', @@ -30,17 +37,23 @@ hoverZoomPlugins.push({ ); hoverZoom.urlReplace(res, - 'img[src*=".googleusercontent.com/"], img[src*=".ggpht.com/"]', + 'img[src*=".googleusercontent.com/"]:not([src*="="])', regex2, patch2 ); hoverZoom.urlReplace(res, - 'img[src*=".googleusercontent.com/"], img[src*=".ggpht.com/"]', + 'img[src*=".googleusercontent.com/"]', regex3, patch3 ); + hoverZoom.urlReplace(res, + 'img[src*=".googleusercontent.com/"], img[src*=".ggpht.com/"]', + regex4, + patch4 + ); + $('[style*=url]').each(function() { var link = $(this); // extract url from style @@ -51,7 +64,7 @@ hoverZoomPlugins.push({ // remove leading & trailing quotes var backgroundImageUrl = backgroundImage.replace(/^['"]/, "").replace(/['"]+$/, ""); - $([{r:regex1, p:patch1},{r:regex2, p:patch2},{r:regex3, p:patch3}]).each(function() { + $([{r:regex1, p:patch1},{r:regex2, p:patch2},{r:regex3, p:patch3},{r:regex4, p:patch4}]).each(function() { var fullsizeUrl = backgroundImageUrl.replace(this.r, this.p); if (fullsizeUrl != backgroundImageUrl) { diff --git a/plugins/gravatar_a.js b/plugins/gravatar_a.js index c7b52e28a..99d86d476 100644 --- a/plugins/gravatar_a.js +++ b/plugins/gravatar_a.js @@ -1,24 +1,25 @@ var hoverZoomPlugins = hoverZoomPlugins || []; hoverZoomPlugins.push({ name:'Gravatar', + version:'0.3', prepareImgLinks:function (callback) { var i, url, res = [], img, imgs = qsa('img[src*="gravatar.com/avatar/"]'); for (i = 0; i < imgs.length; i++) { img = imgs[i]; if (img.src.indexOf('?') == -1) { - url = img.src + '?s=420'; + url = img.src + '?s=512'; } else if (img.src.indexOf('s=') > -1) { - url = img.src.replace(/s=\d+/, 's=420'); + url = img.src.replace(/s=\d+/, 's=512'); } else { - url = img.src + '&s=420'; + url = img.src + '&s=512'; } img = $(img); img.data().hoverZoomSrc = [url]; res.push(img); } if (res.length) { - callback($(res)); + callback($(res), this.name); } } }); diff --git a/plugins/medium_a.js b/plugins/medium_a.js new file mode 100644 index 000000000..8a7c428aa --- /dev/null +++ b/plugins/medium_a.js @@ -0,0 +1,22 @@ +var hoverZoomPlugins = hoverZoomPlugins || []; +hoverZoomPlugins.push({ + name:'Medium_a', + version:'1.0', + prepareImgLinks:function (callback) { + + var name = this.name; + var res = []; + + // samples: + // https://cdn-images-1.medium.com/fit/t/800/240/1*CWl19R2s2gM5u5NcMEP8oA.jpeg -> https://cdn-images-1.medium.com/1*CWl19R2s2gM5u5NcMEP8oA.jpeg + // https://miro.medium.com/max/700/1*tNWGLkRt1qW3_aW5WiGb5Q.jpeg -> https://miro.medium.com/1*tNWGLkRt1qW3_aW5WiGb5Q.jpeg + + hoverZoom.urlReplace(res, + 'img[src*="medium.com/"]', + /\/(max|fit)\/.*\//, + '/' + ); + + callback($(res), name); + } +});