From 7caebdd102c40027548c3b79bc5d58bfd5a48478 Mon Sep 17 00:00:00 2001 From: jesus2099 Date: Wed, 1 May 2024 23:51:50 +0200 Subject: [PATCH] fix(inline recs): Crash when no existing div.ars 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 --- mb_qol_inline_recording_tracks.user.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mb_qol_inline_recording_tracks.user.js b/mb_qol_inline_recording_tracks.user.js index 99c76a82..bc7113e6 100644 --- a/mb_qol_inline_recording_tracks.user.js +++ b/mb_qol_inline_recording_tracks.user.js @@ -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 @@ -84,8 +84,13 @@ function insertRows(recordingTd, recordingInfo) { .map(formatRow) .map(row => '
appears on:
' + row + '
') .join('\n'); - recordingTd.querySelector('div.ars') - .insertAdjacentHTML('beforebegin', '
' + rowElements + '
'); + rowElements = '
' + rowElements + '
'; + let existingArs = recordingTd.querySelector('div.ars'); + if (existingArs) { + existingArs.insertAdjacentHTML('beforebegin', rowElements); + } else { + recordingTd.insertAdjacentHTML('beforeend', rowElements); + } } function loadAndInsert() {