Skip to content

Commit a1e77ef

Browse files
🤖 mb_caa_dimensions 2022.6.17
refactor: more TypeScript migration (#499)
1 parent 16af9b1 commit a1e77ef

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

‎mb_caa_dimensions.changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- **2022.6.17**: Internal changes: more TypeScript migration ([#499](https://github.com/ROpdebee/mb-userscripts/pull/499))
12
- **2022.6.16**: Bug fix: fix order of dimensions ([#495](https://github.com/ROpdebee/mb-userscripts/pull/495))
23
- **2022.6.13**: Internal changes: allow tree-shaking the prototype input setter ([#477](https://github.com/ROpdebee/mb-userscripts/pull/477))
34
- **2022.6.12.2**: Internal changes: rewrite "MB: Paste multiple external links" to TypeScript, fix shortcomings ([#473](https://github.com/ROpdebee/mb-userscripts/pull/473))

‎mb_caa_dimensions.meta.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name MB: Display CAA image dimensions
33
// @description Displays the dimensions and size of images in the cover art archive.
4-
// @version 2022.6.16
4+
// @version 2022.6.17
55
// @author ROpdebee
66
// @license MIT; https://opensource.org/licenses/MIT
77
// @namespace https://github.com/ROpdebee/mb-userscripts
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"2022.6.16"}
1+
{"version":"2022.6.17"}

‎mb_caa_dimensions.user.js‎

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name MB: Display CAA image dimensions
33
// @description Displays the dimensions and size of images in the cover art archive.
4-
// @version 2022.6.16
4+
// @version 2022.6.17
55
// @author ROpdebee
66
// @license MIT; https://opensource.org/licenses/MIT
77
// @namespace https://github.com/ROpdebee/mb-userscripts
@@ -480,32 +480,19 @@
480480
})();
481481

482482
function setupExports(cachePromise) {
483-
const loadImageDimensions = _async(function (imgUrl) {
484-
return _await(getCAAImageInfo(imgUrl), function (imageInfo) {
485-
var _imageInfo$dimensions;
486-
487-
return _objectSpread2(_objectSpread2({
488-
url: imgUrl
489-
}, (_imageInfo$dimensions = imageInfo.dimensions) !== null && _imageInfo$dimensions !== void 0 ? _imageInfo$dimensions : {
490-
width: 0,
491-
height: 0
492-
}), {}, {
493-
size: imageInfo.size,
494-
format: imageInfo.fileType
495-
});
483+
const getImageDimensions = function getImageDimensions(imgUrl) {
484+
return _await(cachePromise, function (cache) {
485+
const image = new CAAImage(imgUrl, cache);
486+
return image.getDimensions();
496487
});
497-
});
498-
499-
const getCAAImageInfo = _async(function (imgUrl) {
500-
if (new URL(imgUrl).hostname !== 'archive.org') {
501-
throw new Error('Unsupported URL: Need direct image URL');
502-
}
488+
};
503489

490+
const getCAAImageInfo = function getCAAImageInfo(imgUrl) {
504491
return _await(cachePromise, function (cache) {
505492
const image = new CAAImage(imgUrl, cache);
506493
return image.getImageInfo();
507494
});
508-
});
495+
};
509496

510497
function getDimensionsWhenInView(imgElement) {
511498
logFailure(cachePromise.then(cache => {
@@ -515,7 +502,7 @@
515502
}
516503

517504
window.ROpdebee_getDimensionsWhenInView = getDimensionsWhenInView;
518-
window.ROpdebee_loadImageDimensions = loadImageDimensions;
505+
window.ROpdebee_getImageDimensions = getImageDimensions;
519506
window.ROpdebee_getCAAImageInfo = getCAAImageInfo;
520507
}
521508

0 commit comments

Comments
 (0)