I'm trying to customize my tribe community by using some custom javascript.

I'm building a separate app that I want to connect to my Tribe community and therefore I've inserted a javascript code that would redirect all the testcommunity.pierresn.com/user/username to testsite.pierresn.com/username

I've added some javascript (code below) which seems to work (screenshot below) but there seems that Tribe has its own javascript which override mine since when I click the link it still goes to the original link. Would somebody be able to help me to see how I can make my original redirect?


<script>
    window.Tribe = {
	onPageChange: function (pathname) {
		// With querySelectorAll you can target all a elements with href value starting with "/user"
		const userLinks = document.querySelectorAll("a[href^='/user/']");
		// Now for each userLink, you retrieve the username value and replace the href value with the newly constructed url
		for (const userLink of userLinks) {
			const hrefValue = userLink.attributes.href.value
			const username = hrefValue.substring(hrefValue.lastIndexOf("/") + 1)
			userLink.href = `https://testsite.pierresn.com/${username}`
		}
	}
}
</script>