New-UDButton not keeping state between sessions

Hi @Zuldan and welcome to the UD forums! As far as I understand refreshing the browser page will clear the session variable. I did publish a couple of loading buttons on the marketplace here:-
https://marketplace.universaldashboard.io/Dashboard/UniversalDashboard.UDButtonLoader
demo here:- New dynamic button for universal dashboard

and here:-
https://marketplace.universaldashboard.io/Dashboard/UniversalDashboard.UDButtonParticle
demo here:- https://github.com/psDevUK/UD-ButtonParticle/blob/master/DEMO.ps1

From your code you kindly shared I just see you in essence want some sort of loading button?