Skip to content

Commit 693e7ec

Browse files
committed
Merge branch 'master' into fix/narrow-down-bandcamp-importer
2 parents aebe7dd + b1f1773 commit 693e7ec

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

bandcamp_importer.user.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,27 @@ if (window.location.hostname === 'web.archive.org') {
291291
});
292292
}
293293

294+
/**
295+
* Bandcamp URLs can be relative or absolute. This function normalizes them to always be relative to the hostname.
296+
*/
297+
const getPathName = url => {
298+
if (url.startsWith('/')) {
299+
return url.split('?')[0].split('#')[0];
300+
} else if (url.startsWith('http')) {
301+
const parsed = new URL(url);
302+
return parsed.pathname;
303+
}
304+
return null;
305+
};
306+
307+
const getHostname = url => {
308+
if (url.startsWith('http')) {
309+
const parsed = new URL(url);
310+
return `${parsed.protocol}//${parsed.hostname}`;
311+
}
312+
return null;
313+
};
314+
294315
$(document).ready(function () {
295316
/* keep the following line as first, it is required to skip
296317
* pages which aren't actually a bandcamp page, since we support
@@ -310,9 +331,13 @@ $(document).ready(function () {
310331
$('ol#music-grid > li > a').each(function () {
311332
const $link = $(this);
312333
const bandcampReleaseUrl = $link.attr('href');
334+
const pathName = getPathName(bandcampReleaseUrl);
335+
336+
if (pathName && pathName.match(/^(\/album|\/track)/)) {
337+
const isRelative = bandcampReleaseUrl.startsWith('/');
338+
const linkHostname = isRelative ? hostname : getHostname(bandcampReleaseUrl);
339+
const full_url = linkHostname + pathName;
313340

314-
if (bandcampReleaseUrl && bandcampReleaseUrl.match(/^(\/album|\/track)/)) {
315-
const full_url = hostname + bandcampReleaseUrl;
316341
urls_data.push({
317342
url: full_url,
318343
mb_type: 'release',

discogs_importer.user.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// @name Import Discogs releases to MusicBrainz
44
// @description Add a button to import Discogs releases to MusicBrainz and add links to matching MusicBrainz entities for various Discogs entities (artist,release,master,label)
5-
// @version 2025.07.01.1
5+
// @version 2025.08.13
66
// @namespace http://userscripts.org/users/22504
77
// @downloadURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/discogs_importer.user.js
88
// @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/discogs_importer.user.js
@@ -469,6 +469,14 @@ function insertMBSection(release, current_page_key) {
469469
$('form.musicbrainz_import_search').css({ float: 'right' });
470470
$('form.musicbrainz_import > button').css({ width: '100%', 'box-sizing': 'border-box' });
471471

472+
// Fix tracklist with long credits text overlap issue by setting track height to auto
473+
const tracklistCss = `
474+
[class*="trackCredits"][class*="expanded"] {
475+
height: auto !important;
476+
}
477+
`;
478+
document.head.insertAdjacentHTML('beforeend', `<style>${tracklistCss}</style>`);
479+
472480
mbUI.slideDown();
473481
}
474482

0 commit comments

Comments
 (0)