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

Method getSize

Picviewer CE+/dist.user.js:12069–12097  ·  view source on GitHub ↗
(url, options = {})

Source from the content-addressed store, hash-verified

12067 }
12068
12069 async getSize(url, options = {}) {
12070 const { force = false, strategy = 'auto' } = options;
12071 if (!url) return null;
12072
12073 if (!force && this.cache.has(url)) {
12074 return this.cache.get(url);
12075 }
12076
12077 if (url.startsWith('data:')) {
12078 const size = this._calculateBase64Size(url);
12079 this.cache.set(url, size);
12080 return size;
12081 }
12082
12083 if (url.startsWith('blob:')) {
12084 return this._getBlobSize(url);
12085 }
12086
12087 if (strategy === 'local-only' || strategy === 'auto') {
12088 const perfSize = this._getFromPerformance(url);
12089 if (perfSize !== null) {
12090 this.cache.set(url, perfSize);
12091 return perfSize;
12092 }
12093 if (strategy === 'local-only') return null;
12094 }
12095
12096 return this._scheduleRequest(url);
12097 }
12098
12099 _calculateBase64Size(dataUrl) {
12100 const base64Str = dataUrl.split(',')[1];

Callers 3

updateGalleryHeaderSizeFunction · 0.45
updateViewmoreSizeLabelFunction · 0.45
initFunction · 0.45

Calls 4

_calculateBase64SizeMethod · 0.95
_getBlobSizeMethod · 0.95
_getFromPerformanceMethod · 0.95
_scheduleRequestMethod · 0.95

Tested by

no test coverage detected