MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / magnifyImage

Function magnifyImage

scripts/magnify_image.js:338–377  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

336}
337
338function magnifyImage(x, y) {
339 let mouse = validateMouse(x, y);
340 let removeLoading,
341 loaded = false;
342
343 setTimeout(() => {
344 if (!loaded)
345 removeLoading = addLoadingAnimationAtPos(
346 mouse.x,
347 mouse.y,
348 40,
349 "",
350 `background: #eee9;`
351 );
352 }, 100);
353
354 getImagesAtPos(x, y).then((imgs) => {
355 loaded = true;
356 removeLoading?.();
357
358 if (!imgs?.length) {
359 UfsGlobal.DOM.notify({
360 msg: "Useful-script: No image found",
361 x: mouse.x,
362 y: mouse.y,
363 align: "left",
364 });
365 } else if (imgs?.length === 1) {
366 console.log(imgs);
367 let src = imgs[0].src;
368 createPreview(src, mouse.x, mouse.y);
369 } else {
370 chooseImg(
371 imgs.map((img) => img.src),
372 mouse.x,
373 mouse.y
374 );
375 }
376 });
377}
378
379// #region get image src at mouse
380

Callers 2

clickToMagnifyFunction · 0.85
magnify_image.jsFile · 0.85

Calls 5

validateMouseFunction · 0.85
addLoadingAnimationAtPosFunction · 0.85
getImagesAtPosFunction · 0.85
createPreviewFunction · 0.85
chooseImgFunction · 0.85

Tested by

no test coverage detected