From 06d7b49eec886d9ef0388bb0f0c5a1caf93ca297 Mon Sep 17 00:00:00 2001 From: moon-0xff Date: Fri, 6 Aug 2021 22:27:29 -0400 Subject: [PATCH] Prevent artist and song names from being cut off mid senten... --- extension.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/extension.js b/extension.js index 4a2b4c1..4a6ed7e 100644 --- a/extension.js +++ b/extension.js @@ -233,11 +233,15 @@ function parseSpotifyData(data) { title = title.replace("- ", "(") + ")"; //If the name of either string is too long, cut off and add '...' - if (artist.length > this.settings.get_int('max-string-length')) - artist = artist.substring(0, this.settings.get_int('max-string-length')) + "..."; + if (artist.length > this.settings.get_int('max-string-length')){ + artist = artist.substring(0, this.settings.get_int('max-string-length')); + artist = artist.substring(0, artist.lastIndexOf(" ")) + "..."; + } - if (title.length > this.settings.get_int('max-string-length')) - title = title.substring(0, this.settings.get_int('max-string-length')) + "..."; + if (title.length > this.settings.get_int('max-string-length')){ + title = title.substring(0, this.settings.get_int('max-string-length')); + title = title.substring(0, title.lastIndexOf(" ")) + "..."; + } if (title.includes("xesam") || artist.includes("xesam")) return "Loading..."