MCPcopy Create free account
hub / github.com/hoothin/UserScripts / updateGalleryHeaderSize

Function updateGalleryHeaderSize

Picviewer CE+/dist.user.js:12193–12211  ·  view source on GitHub ↗
(gallery, img, strategy)

Source from the content-addressed store, hash-verified

12191 }
12192
12193 function updateGalleryHeaderSize(gallery, img, strategy) {
12194 if (!gallery || !gallery.eleMaps || !gallery.eleMaps['head-left-img-info-size']) return;
12195 const sizeSpan = gallery.eleMaps['head-left-img-info-size'];
12196 sizeSpan.textContent = "";
12197 sizeSpan.title = "";
12198 if (!img || img.nodeName !== 'IMG') return;
12199 const sizeUrl = img.src;
12200 if (!sizeUrl) return;
12201 imageSizeFetcher.getSize(sizeUrl, { strategy: strategy || 'auto' }).then(size => {
12202 if (size === null) return;
12203 if (gallery.img !== img || img.src !== sizeUrl) return;
12204 if (img.naturalWidth && img.naturalHeight) {
12205 gallery.eleMaps['head-left-img-info-resolution'].textContent = img.naturalWidth + " x " + img.naturalHeight;
12206 }
12207 const sizeText = formatBytes(size);
12208 sizeSpan.textContent = "(" + sizeText + ")";
12209 sizeSpan.title = sizeText;
12210 });
12211 }
12212
12213 function updateViewmoreSizeLabel(labelNode, baseText, url, strategy, baseTextGetter) {
12214 if (!labelNode || !url) return;

Callers 1

initFunction · 0.70

Calls 2

formatBytesFunction · 0.70
getSizeMethod · 0.45

Tested by

no test coverage detected