Skip to content

Commit

Permalink
Merge pull request #827 from GrosPoulet/master
Browse files Browse the repository at this point in the history
New plug-in : ImageBam (#824)
  • Loading branch information
GrosPoulet authored Dec 4, 2021
2 parents 2f26a7a + da47ae4 commit 70d82df
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
"plugins/cloudfront_a.js",
"plugins/squarespace_a.js",
"plugins/alicdn_a.js",
"plugins/aws_a.js"
"plugins/aws_a.js",
"plugins/imagebam_a.js"
],
"matches": ["<all_urls>"],
"all_frames": true
Expand Down
43 changes: 43 additions & 0 deletions plugins/imagebam_a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name: 'imagebam_a',
version: '0.1',
prepareImgLinks: function(callback) {
var res = [];

// sample
// thumbnail: https://thumbs.imagebam.com/17/ca/06/206f23635328743.jpg
// page with fullsize img embeded: https://www.imagebam.com/image/206f23635328743.jpg
// only fullsize img: https://images.imagebam.com/aa/dd/98/206f23635328743.jpg

// sample gallery: https://www.imagebam.com/gallery/ltximpfxaf8gzebp8uymdvhtglhdfxg0
// https://www.imagebam.com/gallery/bf2ify3sx8bpqnvslhppghdt9h9z56zh

$('img[src*="imagebam"]:not(.hoverZoomMouseover)').addClass('hoverZoomMouseover').filter(function() { return /thumb/.test(this.src) }).one('mouseover', function() {

var href = this.src.replace(/.*\/(.*)/, 'https://www.imagebam.com/image/$1');

hoverZoom.prepareFromDocument($(this), href, function(doc, callback) {

// 1st try
findUrl(doc, callback);

// 2nd try (fullsize img is displayed after some wait time)
setTimeout(function() {

findUrl(doc, callback);

}, 5000);

}, true); //async
});

function findUrl(doc, callback) {
let innerHTML = doc.documentElement.innerHTML;
let m = innerHTML.match(/src=\"(https?:\/\/images.*?)\"/);
if (!m) return;
let fullsizeUrl = m[1];
callback(fullsizeUrl);
}
}
});

0 comments on commit 70d82df

Please sign in to comment.