From ecf3e67bdf5c91a1e1acabf444133da04cdfabeb Mon Sep 17 00:00:00 2001 From: Kalila L Date: Sun, 20 Sep 2020 00:44:40 -0400 Subject: [PATCH] Improve URL formatting and refactor. --- scripts/communityScripts/chat/FloofChat.html | 60 +++++++++++--------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/scripts/communityScripts/chat/FloofChat.html b/scripts/communityScripts/chat/FloofChat.html index b493b05090..7c6d54f608 100644 --- a/scripts/communityScripts/chat/FloofChat.html +++ b/scripts/communityScripts/chat/FloofChat.html @@ -160,7 +160,7 @@ return elContent; } - + // For any URLs present, unless they are already identified within // an `a` element, linkify them. function _linkifyUrls(matches, $el) { @@ -181,23 +181,28 @@ case ext == "JPG": case ext == "GIF": case ext == "JPEG": - elContent = elContent.replace(this, "

" + this - + "📲"); + var replaceWith = "
"; + replaceWith += "
"; + replaceWith += "" + this + ""; + replaceWith += "📲"; + + elContent = elContent.replace(this, replaceWith); break; case ext == "iframe": - elContent = elContent.replace(this, "
"); + var replaceWith = "
"; + replaceWith += ""; + + elContent = elContent.replace(this, replaceWith); break; case ext == "webm": - elContent = elContent.replace(this, "

" + this - + "📲"); + var replaceWith = "
"; + replaceWith += "
"; + replaceWith += "" + this + ""; + replaceWith += "📲"; + + elContent = elContent.replace(this, replaceWith); break; case protocol === "HIFI": case protocol === "hifi": @@ -206,22 +211,25 @@ case !!this.match(/(https?:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g): var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/); if (youtubeMatch && youtubeMatch[2].length == 11) { - elContent = "

" + this - + "📲"; + var replaceWith = "
"; + replaceWith += "