Skip to content

Commit 75502d6

Browse files
🤖 mb_caa_dimensions 2022.8.8
refactor: more TypeScript migration (#499)
1 parent 798966f commit 75502d6

File tree

4 files changed

+30
-42
lines changed

4 files changed

+30
-42
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.8.8**: Internal changes: more TypeScript migration ([#499](https://github.com/ROpdebee/mb-userscripts/pull/499))
12
- **2022.7.27.2**: Bug fix: separate cache key from full-size URL ([#518](https://github.com/ROpdebee/mb-userscripts/pull/518))
23
- **2022.7.27**: Internal changes: automatically insert logger boilerplate config ([#514](https://github.com/ROpdebee/mb-userscripts/pull/514))
34
- **2022.7.3**: New feature: PDF dimensions and page count ([#496](https://github.com/ROpdebee/mb-userscripts/pull/496))

‎mb_caa_dimensions.meta.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
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.7.27.2
4+
// @version 2022.8.8
55
// @author ROpdebee
66
// @license MIT; https://opensource.org/licenses/MIT
77
// @namespace https://github.com/ROpdebee/mb-userscripts
88
// @homepageURL https://github.com/ROpdebee/mb-userscripts
99
// @supportURL https://github.com/ROpdebee/mb-userscripts/issues
1010
// @downloadURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.user.js
1111
// @updateURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.meta.js
12-
// @match *://*.musicbrainz.org/release/*
13-
// @match *://*.musicbrainz.org/release-group/*
14-
// @match *://*.musicbrainz.org/edit/*
15-
// @match *://*.musicbrainz.org/*/edits*
16-
// @match *://*.musicbrainz.org/user/*/votes
17-
// @match *://*.musicbrainz.org/*/open_edits
18-
// @exclude *://*.musicbrainz.org/release/*/edit
19-
// @exclude *://*.musicbrainz.org/release/*/edit-relationships
20-
// @exclude *://*.musicbrainz.org/release-group/*/edit
12+
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/\d+([?#]|$)/
13+
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/(open|subscribed(_editors)?)([?#]|$)/
14+
// @include /^https?://(\w+\.)?musicbrainz\.org/(area|artist|collection|event|instrument|label|place|recording|release|release-group|series|work|url)/[a-f\d-]{36}/(open_)?edits([?#]|$)/
15+
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/edits(/\w+)?([?#]|$)/
16+
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/votes([?#]|$)/
17+
// @include /^https?://(\w+\.)?musicbrainz\.org/search/edits\?.+?(#.+?)?$/
18+
// @include /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}(/.+?)?([?#]|$)/
19+
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}/edit([?#]|$)/
20+
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release-group/[a-f\d-]{36}/edit-relationships([?#]|$)/
2121
// @run-at document-start
2222
// @grant none
2323
// ==/UserScript==
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"2022.7.27.2"}
1+
{"version":"2022.8.8"}

‎mb_caa_dimensions.user.js‎

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
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.7.27.2
4+
// @version 2022.8.8
55
// @author ROpdebee
66
// @license MIT; https://opensource.org/licenses/MIT
77
// @namespace https://github.com/ROpdebee/mb-userscripts
88
// @homepageURL https://github.com/ROpdebee/mb-userscripts
99
// @supportURL https://github.com/ROpdebee/mb-userscripts/issues
1010
// @downloadURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.user.js
1111
// @updateURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.meta.js
12-
// @match *://*.musicbrainz.org/release/*
13-
// @match *://*.musicbrainz.org/release-group/*
14-
// @match *://*.musicbrainz.org/edit/*
15-
// @match *://*.musicbrainz.org/*/edits*
16-
// @match *://*.musicbrainz.org/user/*/votes
17-
// @match *://*.musicbrainz.org/*/open_edits
18-
// @exclude *://*.musicbrainz.org/release/*/edit
19-
// @exclude *://*.musicbrainz.org/release/*/edit-relationships
20-
// @exclude *://*.musicbrainz.org/release-group/*/edit
12+
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/\d+([?#]|$)/
13+
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/(open|subscribed(_editors)?)([?#]|$)/
14+
// @include /^https?://(\w+\.)?musicbrainz\.org/(area|artist|collection|event|instrument|label|place|recording|release|release-group|series|work|url)/[a-f\d-]{36}/(open_)?edits([?#]|$)/
15+
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/edits(/\w+)?([?#]|$)/
16+
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/votes([?#]|$)/
17+
// @include /^https?://(\w+\.)?musicbrainz\.org/search/edits\?.+?(#.+?)?$/
18+
// @include /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}(/.+?)?([?#]|$)/
19+
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}/edit([?#]|$)/
20+
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release-group/[a-f\d-]{36}/edit-relationships([?#]|$)/
2121
// @run-at document-start
2222
// @grant none
2323
// ==/UserScript==
@@ -535,32 +535,19 @@
535535
})();
536536

537537
function setupExports(cachePromise) {
538-
const loadImageDimensions = _async(function (imgUrl) {
539-
return _await(getCAAImageInfo(imgUrl), function (imageInfo) {
540-
var _imageInfo$dimensions;
541-
542-
return _objectSpread2(_objectSpread2({
543-
url: imgUrl
544-
}, (_imageInfo$dimensions = imageInfo.dimensions) !== null && _imageInfo$dimensions !== void 0 ? _imageInfo$dimensions : {
545-
width: 0,
546-
height: 0
547-
}), {}, {
548-
size: imageInfo.size,
549-
format: imageInfo.fileType
550-
});
538+
const getImageDimensions = function getImageDimensions(imgUrl) {
539+
return _await(cachePromise, function (cache) {
540+
const image = new CAAImage(imgUrl, cache);
541+
return image.getDimensions();
551542
});
552-
});
553-
554-
const getCAAImageInfo = _async(function (imgUrl) {
555-
if (new URL(imgUrl).hostname !== 'archive.org') {
556-
throw new Error('Unsupported URL: Need direct image URL');
557-
}
543+
};
558544

545+
const getCAAImageInfo = function getCAAImageInfo(imgUrl) {
559546
return _await(cachePromise, function (cache) {
560547
const image = new CAAImage(imgUrl, cache);
561548
return image.getImageInfo();
562549
});
563-
});
550+
};
564551

565552
function getDimensionsWhenInView(imgElement) {
566553
logFailure(cachePromise.then(cache => {
@@ -570,7 +557,7 @@
570557
}
571558

572559
window.ROpdebee_getDimensionsWhenInView = getDimensionsWhenInView;
573-
window.ROpdebee_loadImageDimensions = loadImageDimensions;
560+
window.ROpdebee_getImageDimensions = getImageDimensions;
574561
window.ROpdebee_getCAAImageInfo = getCAAImageInfo;
575562
}
576563

0 commit comments

Comments
 (0)