Open a browser and run a javascript directly on the console through another programming language

Asked

Viewed 529 times

1

My question is this: Imagine the following scene. You open the browser, open the console and then put some javascript code there to perform some task.

I wonder if it is possible to create a script in some language (like C for example or any other as possible) that is able to open a browser and run a javascript code in it automatically.

I’m researching the subject but unsuccessfully in finding any response to such a possibility.

Thank you who can answer.

  • 1

    Take a look here warrior, maybe I can help!

1 answer

0

The answer is: depends on...

If you want to simply run a Javascript script, you have to find a way to create an HTML file that has a tag <script> directed to the desired script, and then run that page. This can be done up with bash, or python3.

If you want to turn a piece of code built in Javascript (turning C++ into Javascript, for example), which is what I understood you want, you will have to go through a process called "transcompilation".

After a few minutes of research, I found that list. Might be useful to you.

The third case, which already has an answer, even, is when you produce certain standard scripts for web pages that can serve as "jokers". I won’t go into details, but it’s very simple and useful.

The fourth case is that the website accessed through a link on your site has its Javascript changed. I don’t know if it’s possible, but I can’t imagine the developers of this hypothetical site agreeing with this.

In any case, it is possible. But, depending on what you want to do, it may not be worth it.

  • 1

    "If you want to turn a piece of code built into Javascript..." That wouldn’t be it. For example: Imagine the following manual task of me opening a website, then opening the console and then putting some js script for some purpose whatsoever. I would like to know if there is a possibility of running this sequence of steps through some other programming language. The most I found so far searching were simple scripts via . bat to open the browser but that’s not even close to what I’m interested in knowing.

  • Like I said, if I understand what you want to do, can perform this using bash. For this, you must know which browser will be used and the syntax to open a link or HTML with it. For this, use man [comando]. Ex: man firefox

Browser other questions tagged

You are not signed in. Login or sign up in order to post.