Skip to content

Commit

Permalink
fix(inline recs): Crash when no existing div.ars
Browse files Browse the repository at this point in the history
Example release with no ARs
https://musicbrainz.org/release/1f3a402f-7265-42ea-803a-f3cf8c508e7c

Or any other releases with credits at bottom and no mb_INLINE-STUFF running
https://musicbrainz.org/release/b4e8f7f4-e35c-42eb-a043-9605e4784aff
  • Loading branch information
jesus2099 committed May 1, 2024
1 parent 68c9883 commit 7caebdd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mb_qol_inline_recording_tracks.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name MB: QoL: Inline all recording's tracks on releases
// @version 2022.6.14
// @version 2024.5.1
// @description Display all tracks and releases on which a recording appears from the release page.
// @author ROpdebee
// @license MIT; https://opensource.org/licenses/MIT
Expand Down Expand Up @@ -84,8 +84,13 @@ function insertRows(recordingTd, recordingInfo) {
.map(formatRow)
.map(row => '<dl class="ars"><dt>appears on:</dt><dd>' + row + '</dd></dl>')
.join('\n');
recordingTd.querySelector('div.ars')
.insertAdjacentHTML('beforebegin', '<div class="ars ROpdebee_inline_tracks">' + rowElements + '</div>');
rowElements = '<div class="ars ROpdebee_inline_tracks">' + rowElements + '</div>';
let existingArs = recordingTd.querySelector('div.ars');
if (existingArs) {
existingArs.insertAdjacentHTML('beforebegin', rowElements);
} else {
recordingTd.insertAdjacentHTML('beforeend', rowElements);
}
}

function loadAndInsert() {
Expand Down

0 comments on commit 7caebdd

Please sign in to comment.