Customer portal hide home button, change button text and landing should be ticket listing page

Hi team,

Good day

one of the Freshdesk customers the below things are ask to do.

  1. To hide the ‘Home’ link/button from the portal.
  2. The landing page for customers will be the Ticket list page.
  3. Change the Submit a ticket button text to Submit Request button in the header(Customer portal)

I am using javascript to hide the button and change the button text to submit a ticket to submit a request as of now it ok, working fine. you can see in the below screenshot.


code:

	const navEle=document.getElementById("ulEle");
 	console.log("navEle", navEle);
  const btnEle=document.getElementsByClassName("btn fw-secondary-button")
console.log("idEle",btnEle[0])
btnEle[0].innerText="Submit Request"

function hidehome() {
    let home = document.getElementById("ulEle");
    let allnav = document.querySelectorAll("a[href='/en/support/home']");
  console.log("all nav" ,allnav[0], allnav[1]) 
    allnav[1].style.display = "none";
  }
  
  hidehome()

When i am adding the redirection redirecting to the ticket listing page everything it resetting, button is showing and button text also changing. you can see in the below screenshot

code:

const navEle=document.getElementById("ulEle");
 	console.log("navEle", navEle);
  const btnEle=document.getElementsByClassName("btn fw-secondary-button")
console.log("idEle",btnEle[0])
btnEle[0].innerText="Submit Request"

function hidehome() {
    let home = document.getElementById("ulEle");
    let allnav = document.querySelectorAll("a[href='/en/support/home']");
  console.log("all nav" ,allnav[0], allnav[1]) 
    allnav[1].style.display = "none";
  }
  
  hidehome()
  
  // Redirecting to the ticket listing page
  window.location.replace('https://spritlesoftware.freshdesk.com/support/tickets');

could you please explain about this why it is happing, and what is the workaround we can do?

Thanks in advance.

When implementing a script, it’s important to ensure that you have added it to the appropriate sections such as the Header, Layout, or the required page. If you are testing the script in preview mode, please note that its location will be replaced and moved to the published page, preventing it from being hidden.

To avoid this, make sure to publish your theme first and then verify the behavior of the script.