Here’s the rough idea. You’d need to get the actual time from the system. One way to get that is with the JavaScript Date.now() which gives the number of milliseconds from some fixed date.
Here I specified that clicking a button will make the timer last 5 seconds.
Then you can do a comparison to see if the timer has passed the endtime.
All that’s left is to save and load the endtime to local storage when the game starts and closes. You’ll have to consult some docs how that’s done as I haven’t messed with it in a while.
var endtime = 0
On start of layout
— set endtime to webstorage.at(“endtime”)
On button clicked
— set endtime to browser.execjs(“Date.now()”)/1000+5
endtime >= browser.execjs(“Date.now()”)/1000
Trigger once
— do something
On end of layout
— web storage save endtime to key “endtime”