Skip to content

Commit

Permalink
Merge pull request #591 from GrosPoulet/master
Browse files Browse the repository at this point in the history
New plug-in : photo-forum.net
  • Loading branch information
GrosPoulet authored Sep 10, 2020
2 parents b9e67d1 + 580150f commit 8edd41b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,10 @@
{
"js": ["plugins/photoforum.js"],
"matches": ["*://*.photoforum.ru/*"]
},
{
"js": ["plugins/photo-forum.js"],
"matches": ["*://*.photo-forum.net/*"]
}
]
}
44 changes: 44 additions & 0 deletions plugins/photo-forum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'photo-forum.net',
version:'2.0',
prepareImgLinks:function (callback) {

var res = [];

hoverZoom.urlReplace(res,
'img[src]',
['_small', '_middle'],
['_original', '_original']
);

hoverZoom.urlReplace(res,
'img[src]',
['/site_thumbs/', '/imgs_thumbs/', '/imgs_thumbs_200/', '/imgs_thumbs_big/', '/thumbs/', '_thumb'],
['/site_pics/', '/static/site_pics/', '/static/site_pics/', '/static/site_pics/', '', '_big']
);

$('[style*=background]').each(function() {
// 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(/['"]+$/,"");

var fullsizeUrl = backgroundImageUrl.replace('/site_thumbs/', '/site_pics/').replace('/imgs_thumbs/', '/static/site_pics/').replace('/imgs_thumbs_200/', '/static/site_pics/').replace('/imgs_thumbs_big/', '/static/site_pics/').replace('/thumbs/', '').replace('_thumb.', '_big.');
if (fullsizeUrl != backgroundImageUrl) {
var link = $(this);
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);
}
});

0 comments on commit 8edd41b

Please sign in to comment.