Storing the output of a script in a macro variable

DBG

New Member
VIP
Joined
Mar 2, 2021
Messages
12
Reaction score
0
Achievement
Hello!

I am new to javascript and trying to store the result of a javascript script in a variable in my macro.
I have tried several ways, but never make it.
The idea would be something like this macro:

JavaScript:
await WaitForLoading();
await Delay(2000);
var weekday = await EvaluateScript ('var d=new Date(); var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); document.write("Today is " + weekday[d.getDay()])');
Alert (weekday);
await Delay(50000)
Exit();

The obvious intent is to have something like "Today is Tuesday" stored in "weekday" if the macro is executed on a tuesday.

Is there a way to get that done?

Thanks for your help in advance!!
 

opsfafsme

Well-Known Member
Rule The Universe
VIP
Joined
Jul 2, 2018
Messages
243
Reaction score
91
Website
OnlinePiercingShop.com
Achievement
slightly different syntax

var weekday = "Today is " + await EvaluateScript ('var d=new Date(); var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); weekday[d.getDay()]');
 

DBG

New Member
VIP
Joined
Mar 2, 2021
Messages
12
Reaction score
0
Achievement
Wonderful!! Thank you!!
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu