Jump to content
UBot Underground

JavaScript and UBot Variables


Recommended Posts

Hello.

 

I'm currently playing around with javascript a little bit. But I don't understand how and when Ubot assigns results from javascript to ubot variables.

 

So basically we have two functions in ubot:

1. run javascript

2. $eval()

 

 

Questions:

1. Is it possible with "run javascript" to return values to ubot studio? Probably not right?

2. Where are variables to I use within "run javascript" are stored? Are the per browser instance? So when I run multiple browsers, are they unique for each browser?

 

 

3. How exactly does the $eval() command work? can I put multiple javascript commands in there? Or is that only used to execute a single line of code?

 

4. Is it possible to return multiple parameters with eval()? 

 

5. Which parameter is returned with eval() exactly?

 

Not working:
set(#test$eval("var firstname = \"Peter\";"), "Global")

 

Working:
set(#test$eval("var firstname; 
firstname = \"Peter\";"), "Global")

 

That's a little bit confusing.

 

Thanks in advance for your help.

Dan

 

Link to post
Share on other sites

Hello.

 

I'm currently playing around with javascript a little bit. But I don't understand how and when Ubot assigns results from javascript to ubot variables.

 

So basically we have two functions in ubot:

1. run javascript

2. $eval()

 

 

Questions:

1. Is it possible with "run javascript" to return values to ubot studio? Probably not right?

2. Where are variables to I use within "run javascript" are stored? Are the per browser instance? So when I run multiple browsers, are they unique for each browser?

 

 

3. How exactly does the $eval() command work? can I put multiple javascript commands in there? Or is that only used to execute a single line of code?

 

4. Is it possible to return multiple parameters with eval()? 

 

5. Which parameter is returned with eval() exactly?

 

Not working:

set(#test$eval("var firstname = \"Peter\";"), "Global")

 

Working:

set(#test$eval("var firstname; 

firstname = \"Peter\";"), "Global")

 

That's a little bit confusing.

 

Thanks in advance for your help.

Dan

 

1. No, you should use eval: http://www.ubotstudio.com/forum/index.php?/topic/15120-javascript-question/&do=findComment&comment=85947 and "echo" the JS variable value at the end of your JS code so it get's returned to UBot.

 

2.) I think they are stored per browser, since you are executing them inside the browser, so I think they should be unique for each browser.

 

3.) Read above....and yes, you can execute multpiple commands with eval as well as run javascript.

 

4.) as far as I know it's only possible to return 1 variable/the last one "echoed".

 

5) as said above, the last one you "echo".

 

Here is an example:

set(#test, $eval("var counter = 0;
counter++;
var firstname = \"Peter\";
firstname;
counter++;
counter;"), "Global")

As you can see although not all JS variables are returned back, the code is still executed...

 

You should also know that you can run your JS code by parts...for example use "run javascript" to load some JS code inside the browser then you can use multiple evals to get data from JS.

Link to post
Share on other sites

Awesome! Thanks a lot UbotDev.

Are there any specifics to javascript objects in ubot?

 

I try the following:

run javascript("var crypt = new JSEncrypt();
crypt.setKey({#rsa});
var enc = crypt.encrypt(\'Das ist ein Test\');
document.write(enc);")

 

But this doesn't work at all. 

 

Just want to ensure that I'm not running into some ubot specific stuff here.

 

Dan

  • Like 1
Link to post
Share on other sites

This has done wonders for me Dan

 

http://www.youtube.com/watch?v=eZ8VXDZZvfk

 

TC

 

Thats a great method.

Now I am wondering if the &table format can be used to load a csv to table script like:

https://code.google.com/p/js-tables/

or

https://code.google.com/p/jquerycsvtotable/

 

Im really interested in also using this ones: http://jquerygridview.com/

But Im not sure if the data from the table can help me, otherwise How can I convert it to use it properly?

Link to post
Share on other sites

Awesome! Thanks a lot UbotDev.

Are there any specifics to javascript objects in ubot?

 

I try the following:

run javascript("var crypt = new JSEncrypt();

crypt.setKey({#rsa});

var enc = crypt.encrypt(\'Das ist ein Test\');

document.write(enc);")

 

But this doesn't work at all. 

 

Just want to ensure that I'm not running into some ubot specific stuff here.

 

Dan

Not that I would know.

 

 

Thats a great method.

Now I am wondering if the &table format can be used to load a csv to table script like:

https://code.google.com/p/js-tables/

or

https://code.google.com/p/jquerycsvtotable/

 

Im really interested in also using this ones: http://jquerygridview.com/

But Im not sure if the data from the table can help me, otherwise How can I convert it to use it properly?

If table loads CSV directly from file you don't need to load it into table (jquerycsvtotable), for others table will only help you to load the data, but after that I think you'll need a custom code which will transform &table to a string which you can then use in JavaScript.

Link to post
Share on other sites

Not that I would know.

 

 

 

If table loads CSV directly from file you don't need to load it into table (jquerycsvtotable), for others table will only help you to load the data, but after that I think you'll need a custom code which will transform &table to a string which you can then use in JavaScript.

Do you know how &table is expressed when I transfer it to javascript?

Link to post
Share on other sites

Do you know how &table is expressed when I transfer it to javascript?

What do you mean by expressed? You can't just use UBot $table in JavaScript directly, you need to format it into JavaScript array or something and pass to your JS script (what you need actually depends on JS script you are going to use).

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...