diff --git a/web/static/js/BareRTC.js b/web/static/js/BareRTC.js index 1fec4fb..417c5f3 100644 --- a/web/static/js/BareRTC.js +++ b/web/static/js/BareRTC.js @@ -669,6 +669,9 @@ const app = Vue.createApp({ // Responsive CSS: switch back to chat panel upon selecting a channel. this.openChatPanel(); + + // Edit hyperlinks to open in a new window. + this.makeLinksExternal(); }, hasUnread(channel) { if (this.channels[channel] == undefined) { @@ -957,6 +960,9 @@ const app = Vue.createApp({ this.channels[channel].unread++; } } + + // Edit hyperlinks to open in a new window. + this.makeLinksExternal(); }, scrollHistory() { @@ -1088,6 +1094,19 @@ const app = Vue.createApp({ // Store the user's setting in localStorage. localStorage[`sound:${event}`] = this.config.sounds.settings[event]; }, + + makeLinksExternal() { + window.requestAnimationFrame(() => { + let $history = document.querySelector("#chatHistory"); + // Make all links appearing in chat into external links. + ($history.querySelectorAll("a") || []).forEach(node => { + let href = node.attributes.href, + target = node.attributes.target; + if (href == undefined || target != undefined) return; + node.target = "_blank"; + }); + }) + }, } });