Jump to content
UBot Underground

Executing Javascript inside a Ubot 3 or 4


Recommended Posts

I've got some bots built with Zennoposter and want to port them over to Ubot.

 

In Zennoposter I made extensive use of Javascript to handle any complex data manipulation.

 

As far as I'm aware, Ubot can also execute Javascript but I can't figure out how to get the data out after executing the javascript.

 

I'm sure its very simple... :blink: Can someone point me in the right direction.

 

Cheers!

Link to post
Share on other sites

not sure how to get the data out after executing?

 

 

can you elaborate a bit more?

 

You could always add a define node, choose function, and drop the run JavaScript node in there.

 

then use a set node, to set a variable, and use the custom function you just created, in the content of the variable, as a means to execute the custom defined function, when the variable set node is ran.

Link to post
Share on other sites

Thanks LoWrIdErTJ, that is pretty much what I'm trying to do.

 

Unfortunately I'm still doing something wrong.

 

Here is a really simple example that should set #a to 10 but it leaves it undefined. :mellow:

 

set(#a, 1, "Global")
define $js {
   run javascript("10;")
}
set(#a, $js(), "Global")
ui stat monitor("a=", #a)

Link to post
Share on other sites

Sure you can. here is an example of something i am using in v4 now..

 

    set(#start date, $eval("var d = new Date(\"{#dte}\");
d.setDate(d.getDate());
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();

curr_month + \"/\" + curr_date + \"/\" + curr_year;"), "Global")

Link to post
Share on other sites

Nice.

 

I couldn't find any documentation on this but with that example, you've made it much clearer.

 

Thanks :)

 

Is there any preset function to escape input to make it ready for JavaScript?

Link to post
Share on other sites

What I'd also like to do is escape line feed characters from a block of text, prior to processing the text with javascript.

 

Is there some built in function to take line feeds and turn them into javascript friendly \r\n ?

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...