Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Javascript code to browser

Is there a way to send javascript commands to an open web running in a browser from the shell?

Let's say I have stackoverflow.com open with Chrome. Well, I'd like to send something like

alert('hi!');

from the shell, with something similar to the following:

$ send -t Chrome -w "stackoverflow.com" -c "alert('hi!')"

I was wondering this, because if I can write alert('hi!') on the javascript console of Chrome, I should be able to do the same with a call somewhere, right?

I've seen node.js but I think is not possible with that, please, let me know if I'm wrong.

I know the question could seem weird but I'm curious, thanks in advance :)

like image 600
José M. Gilgado Avatar asked Nov 05 '22 02:11

José M. Gilgado


1 Answers

You can send JavaScript to Firefox through the jssh extension.

http://www.croczilla.com/bits_and_pieces/jssh/

This is what the Watir testing framework uses to automate Firefox.

I don't know of an equivalent for Chrome.

like image 68
Steve Avatar answered Nov 09 '22 17:11

Steve