Skip to content

Commit

Permalink
Merge pull request #1421 from GrosPoulet/master
Browse files Browse the repository at this point in the history
New plug-in for: lummi.ai
  • Loading branch information
GrosPoulet authored Sep 29, 2024
2 parents 3b0af43 + 38c3d51 commit 81d0c1e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,10 @@
{
"js": ["plugins/meiye.js"],
"matches": ["*://*.meiye.art/*"]
},
{
"js": ["plugins/lummi.js"],
"matches": ["*://*.lummi.ai/*"]
}
]
}
49 changes: 49 additions & 0 deletions plugins/lummi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'lummi',
version:'0.1',
prepareImgLinks:function (callback) {
var res = [];

// sample: https://assets.lummi.ai/assets/Qmbk569usQHq44j6vqugBoLSaiof2xJ7CFmo51o7J9kVCs?auto=format&w=1500
// -> https://assets.lummi.ai/assets/Qmbk569usQHq44j6vqugBoLSaiof2xJ7CFmo51o7J9kVCs?auto=format&w=9999 => max w = 4991 px

const reFind = /(.*\.lummi\.ai\/.*)\?.*/;
const reReplace = '$1?auto=format&w=9999';

$('a').one('mouseover', function() {

const link = $(this);

if (link.data().hoverZoomMouseOver) return;
link.data().hoverZoomMouseOver = true;

var img = undefined;

if (link.find('a').length == 0) {
img = link.find('img[src]')[0]; // img is under link
if (img == undefined) {
img = link.siblings().find('img').filter(function() { return $(this).parents('a').length == 0 })[0]; // img is next to link
}
}
if (img == undefined) return;

let fullsizeUrl = img.src.replace(reFind, reReplace);

link.addClass('hoverZoomLink');
link.data().hoverZoomSrc = [fullsizeUrl];
// Image is displayed iff the cursor is still over the image
if (link.data().hoverZoomMouseOver) {
hoverZoom.displayPicFromElement(link);
}

}).one('mouseleave', function () {
const link = $(this);
link.data().hoverZoomMouseOver = false;
});

if (res.length) {
callback($(res), this.name);
}
}
});

0 comments on commit 81d0c1e

Please sign in to comment.