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

**URL:** <https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264>\
**Category:** Community Support\
**Tags:** rocketchat-apps\
**Created:** [March 20, 2023, 7:10pm UTC](https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264 "2023-03-20T19:10:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doelaji](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@doelaji](https://forums.rocket.chat/u/doelaji)\
**Post date:** [March 20, 2023, 7:10pm UTC](https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264/1 "2023-03-20T19:10:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [March 21, 2023, 6:37pm UTC](https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264/2 "2023-03-21T18:37:57Z")

</div>

Hi!

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

---

<div class="post-metadata">

**Author:** ![doelaji](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@doelaji](https://forums.rocket.chat/u/doelaji)\
**Post date:** [March 23, 2023, 8:26am UTC](https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264/3 "2023-03-23T08:26:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Riko\_Nev](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@Riko\_Nev](https://forums.rocket.chat/u/Riko_Nev)\
**Post date:** [March 31, 2023, 10:11am UTC](https://forums.rocket.chat/t/layout-custom-scripts-custom-script-for-logged-in-users-problem/16264/4 "2023-03-31T10:11:21Z")

</div>

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