"Layout > Custom Scripts > Custom Script for Logged In Users" problem

Trying to use “Layout > Custom Scripts > Custom Script for Logged In Users” on the admin page while using rocketchat. However, even if I enter the JavaScript code, I have to refresh the page for it to work.
For example
if(window.location.pathname == ‘/account/profile’){ alert(“Welcome”)
} code, it doesn’t work when you move to the page. It works only when I refresh the page. How to solve this problem?

Server Setup Information:

  • Version of Rocket.Chat Server: 4.7.0
  • Operating System: ubuntu 20.04
  • Deployment Method: tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog: enable oplog
  • NodeJS Version: 14.18.3
  • MongoDB Version: 5.0.15

Hi!

I believe this working as expected. That script will only run after the first log in, not on all page changes.

For that reason, the code I entered doesn’t seem to work.
For example “document.querySelectorAll(”.rcx-css-1twyb0g").forEach(a => {
a.onclick = function(){
a.style.color = “red”;
};
});"
If I want this code to work, is there a way to get it to work without using the “Custom Script for Logged In Users” menu?

1 Like

Hello :slight_smile: I have the same problem or question. I am also very interested in a solution.