Skip to content

Commit

Permalink
🤖 mb_caa_dimensions 2022.6.17
Browse files Browse the repository at this point in the history
refactor: more TypeScript migration (#499)
  • Loading branch information
github-actions[bot] committed Jun 17, 2022
1 parent 16af9b1 commit a1e77ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
1 change: 1 addition & 0 deletions mb_caa_dimensions.changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- **2022.6.17**: Internal changes: more TypeScript migration ([#499](https://github.com/ROpdebee/mb-userscripts/pull/499))
- **2022.6.16**: Bug fix: fix order of dimensions ([#495](https://github.com/ROpdebee/mb-userscripts/pull/495))
- **2022.6.13**: Internal changes: allow tree-shaking the prototype input setter ([#477](https://github.com/ROpdebee/mb-userscripts/pull/477))
- **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))
Expand Down
2 changes: 1 addition & 1 deletion mb_caa_dimensions.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name MB: Display CAA image dimensions
// @description Displays the dimensions and size of images in the cover art archive.
// @version 2022.6.16
// @version 2022.6.17
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
// @namespace https://github.com/ROpdebee/mb-userscripts
Expand Down
2 changes: 1 addition & 1 deletion mb_caa_dimensions.metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2022.6.16"}
{"version":"2022.6.17"}
31 changes: 9 additions & 22 deletions mb_caa_dimensions.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name MB: Display CAA image dimensions
// @description Displays the dimensions and size of images in the cover art archive.
// @version 2022.6.16
// @version 2022.6.17
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
// @namespace https://github.com/ROpdebee/mb-userscripts
Expand Down Expand Up @@ -480,32 +480,19 @@
})();

function setupExports(cachePromise) {
const loadImageDimensions = _async(function (imgUrl) {
return _await(getCAAImageInfo(imgUrl), function (imageInfo) {
var _imageInfo$dimensions;

return _objectSpread2(_objectSpread2({
url: imgUrl
}, (_imageInfo$dimensions = imageInfo.dimensions) !== null && _imageInfo$dimensions !== void 0 ? _imageInfo$dimensions : {
width: 0,
height: 0
}), {}, {
size: imageInfo.size,
format: imageInfo.fileType
});
const getImageDimensions = function getImageDimensions(imgUrl) {
return _await(cachePromise, function (cache) {
const image = new CAAImage(imgUrl, cache);
return image.getDimensions();
});
});

const getCAAImageInfo = _async(function (imgUrl) {
if (new URL(imgUrl).hostname !== 'archive.org') {
throw new Error('Unsupported URL: Need direct image URL');
}
};

const getCAAImageInfo = function getCAAImageInfo(imgUrl) {
return _await(cachePromise, function (cache) {
const image = new CAAImage(imgUrl, cache);
return image.getImageInfo();
});
});
};

function getDimensionsWhenInView(imgElement) {
logFailure(cachePromise.then(cache => {
Expand All @@ -515,7 +502,7 @@
}

window.ROpdebee_getDimensionsWhenInView = getDimensionsWhenInView;
window.ROpdebee_loadImageDimensions = loadImageDimensions;
window.ROpdebee_getImageDimensions = getImageDimensions;
window.ROpdebee_getCAAImageInfo = getCAAImageInfo;
}

Expand Down

0 comments on commit a1e77ef

Please sign in to comment.