From 7badaa927c6b2a6bb8e7c3b1bd99741fa1fa3fa0 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Sun, 4 May 2025 18:48:33 -0400 Subject: [PATCH] Embedded links open in new tab --- www/js/channel/chatPostprocessor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/www/js/channel/chatPostprocessor.js b/www/js/channel/chatPostprocessor.js index 818c533..4b8759d 100644 --- a/www/js/channel/chatPostprocessor.js +++ b/www/js/channel/chatPostprocessor.js @@ -116,6 +116,7 @@ class chatPostprocessor{ const link = document.createElement('a'); link.classList.add('chat-link', ...wordObj.filterClasses); link.href = wordObj.link; + link.target = "_blank"; //Use textContent to be safe since links can't be escaped serverside link.textContent = wordObj.link; @@ -126,6 +127,7 @@ class chatPostprocessor{ const badLink = document.createElement('a'); badLink.classList.add('chat-dead-link', 'danger-link', ...wordObj.filterClasses); badLink.href = wordObj.link; + badLink.target = "_blank"; //Use textContent to be safe since links can't be escaped serverside badLink.textContent = wordObj.link; @@ -213,6 +215,7 @@ class chatPostprocessor{ link.classList.add('chat-link', ...wordObj.filterClasses); //Set href and inner text link.href = `/c/${wordObj.chan}`; + link.target = "_blank" link.textContent = wordObj.string; //We don't have to worry about injecting this into whitespace since there shouldn't be any here.