Send Javascript code to browser

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

Say I have stackoverflow.com open with Chrome. Well, I would like to send something like

alert('hi!');

from the shell, something similar to the following:

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

I was wondering because if I can write a warning (β€œhello!”) On the Chrome javascript console, I would have to do the same with a call somewhere, right?

I saw node.js, but I think this is not possible, please let me know if I am wrong.

I know the question may seem strange, but I wonder, thanks in advance :)

+3
source share
5 answers

JavaScript Firefox jssh.

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

, Watir Firefox.

Chrome.

0

IE , VBScript: http://www.autohotkey.com/forum/topic7642.html

IE8.:)

: , , JS .vbs :

Dim oIE

Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = 1

oIE.Navigate "http://stackoverflow.com/questions/4992552/send-javascript-code-to-browser/4992812"

Do While (oIE.Busy)
   Wscript.Sleep 10
Loop

oIE.Navigate "javascript:alert(fkey);"
+1

, , - , . , .

0

, ​​. , :

, , [ - ] [], [ -], -, ?

, , . , , - , .

, , , , .

, , , , , .

0

! , AutoHotKey,

send F6 //focus the address bar
send ctrl+v  //given that your code is in clipboard
send enter

. ? : !

document.title .

(, JSON), ,

document.title='calculating...';
document.title=returnValue.subString(0,20);
sleep(10);
document.title=returnValue.subString(20,40);
sleep(10);
document.title=returnValue.subString(40,60);
...
document.title='finished';

, .

0

Source: https://habr.com/ru/post/1792004/


All Articles