Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug-ins enhancements + 1 new plug-in: Medium_a #682

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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_urls>"],
"all_frames": true
Expand Down
40 changes: 38 additions & 2 deletions plugins/flixster.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
11 changes: 9 additions & 2 deletions plugins/fotolog.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
23 changes: 18 additions & 5 deletions plugins/google_a.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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/"]',
Expand All @@ -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
Expand All @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions plugins/gravatar_a.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
});
22 changes: 22 additions & 0 deletions plugins/medium_a.js
Original file line number Diff line number Diff line change
@@ -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);
}
});