Skip to content

Commit

Permalink
🤖 mb_caa_dimensions 2022.8.8
Browse files Browse the repository at this point in the history
refactor: more TypeScript migration (#499)
  • Loading branch information
github-actions[bot] committed Aug 8, 2022
1 parent 798966f commit 75502d6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 42 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.8.8**: Internal changes: more TypeScript migration ([#499](https://github.com/ROpdebee/mb-userscripts/pull/499))
- **2022.7.27.2**: Bug fix: separate cache key from full-size URL ([#518](https://github.com/ROpdebee/mb-userscripts/pull/518))
- **2022.7.27**: Internal changes: automatically insert logger boilerplate config ([#514](https://github.com/ROpdebee/mb-userscripts/pull/514))
- **2022.7.3**: New feature: PDF dimensions and page count ([#496](https://github.com/ROpdebee/mb-userscripts/pull/496))
Expand Down
20 changes: 10 additions & 10 deletions mb_caa_dimensions.meta.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// ==UserScript==
// @name MB: Display CAA image dimensions
// @description Displays the dimensions and size of images in the cover art archive.
// @version 2022.7.27.2
// @version 2022.8.8
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
// @namespace https://github.com/ROpdebee/mb-userscripts
// @homepageURL https://github.com/ROpdebee/mb-userscripts
// @supportURL https://github.com/ROpdebee/mb-userscripts/issues
// @downloadURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.user.js
// @updateURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.meta.js
// @match *://*.musicbrainz.org/release/*
// @match *://*.musicbrainz.org/release-group/*
// @match *://*.musicbrainz.org/edit/*
// @match *://*.musicbrainz.org/*/edits*
// @match *://*.musicbrainz.org/user/*/votes
// @match *://*.musicbrainz.org/*/open_edits
// @exclude *://*.musicbrainz.org/release/*/edit
// @exclude *://*.musicbrainz.org/release/*/edit-relationships
// @exclude *://*.musicbrainz.org/release-group/*/edit
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/\d+([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/(open|subscribed(_editors)?)([?#]|$)/
// @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([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/edits(/\w+)?([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/votes([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/search/edits\?.+?(#.+?)?$/
// @include /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}(/.+?)?([?#]|$)/
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}/edit([?#]|$)/
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release-group/[a-f\d-]{36}/edit-relationships([?#]|$)/
// @run-at document-start
// @grant none
// ==/UserScript==
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.7.27.2"}
{"version":"2022.8.8"}
49 changes: 18 additions & 31 deletions mb_caa_dimensions.user.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// ==UserScript==
// @name MB: Display CAA image dimensions
// @description Displays the dimensions and size of images in the cover art archive.
// @version 2022.7.27.2
// @version 2022.8.8
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
// @namespace https://github.com/ROpdebee/mb-userscripts
// @homepageURL https://github.com/ROpdebee/mb-userscripts
// @supportURL https://github.com/ROpdebee/mb-userscripts/issues
// @downloadURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.user.js
// @updateURL https://raw.github.com/ROpdebee/mb-userscripts/dist/mb_caa_dimensions.meta.js
// @match *://*.musicbrainz.org/release/*
// @match *://*.musicbrainz.org/release-group/*
// @match *://*.musicbrainz.org/edit/*
// @match *://*.musicbrainz.org/*/edits*
// @match *://*.musicbrainz.org/user/*/votes
// @match *://*.musicbrainz.org/*/open_edits
// @exclude *://*.musicbrainz.org/release/*/edit
// @exclude *://*.musicbrainz.org/release/*/edit-relationships
// @exclude *://*.musicbrainz.org/release-group/*/edit
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/\d+([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/edit/(open|subscribed(_editors)?)([?#]|$)/
// @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([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/edits(/\w+)?([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/user/[^/]+/votes([?#]|$)/
// @include /^https?://(\w+\.)?musicbrainz\.org/search/edits\?.+?(#.+?)?$/
// @include /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}(/.+?)?([?#]|$)/
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release(-group)?/[a-f\d-]{36}/edit([?#]|$)/
// @exclude /^https?://(\w+\.)?musicbrainz\.org/release-group/[a-f\d-]{36}/edit-relationships([?#]|$)/
// @run-at document-start
// @grant none
// ==/UserScript==
Expand Down Expand Up @@ -535,32 +535,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 @@ -570,7 +557,7 @@
}

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

Expand Down

0 comments on commit 75502d6

Please sign in to comment.