Brought to you by Tomasz Janczuk / @tjanczuk
(Use space or arrow keys to navigate)
<html>
<head>
<script src="http://repl.ws/js/{{id}}"></script>
</head>
<body>
<h1>Lorem ipsum</h1>
</body>
</html>
Note the {{id}} in the script URL
It is your repl.ws session identifier
It does not need to be pre-registered, but it should be unique
So use enough entropy - think of it as a password
Use a generic, console-based Node.js WebSocket client
npm install ws -g
wscat -c ws://repl.ws/{{id}}
Remotely manipulate the DOM
> document.body.innerHTML="Hello, world!"
< Hello, world!
Observe the changes in the browser window
Let's load and use jQuery
> .ld('//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js')
< Loaded //ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
> $('body').html()
< Hello, world!
...or use a shorthand for loading JQuery:
> .ldjq
< Loaded //ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
Type .h to see other built-in functions besides .ld
Let's load jQuery UI CSS
> .ld('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css')
< Loaded //ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css
Experiment with or fine tune CSS on actual device/browser
> $('p').css('color', 'red').css('font-size','2em')
< [object Object]
Start a JSConf.US 2014 video on connected browsers
> $('body').html('<iframe src="//www.youtube.com/embed/2RevdtDs6tU"></iframe>')
< [object Object]
Each browser connected to the session has an identifier
> .ls
< 0: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
< 2: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/7.0.4 Safari/537.76.4
Type .h to get help
> .h
< Available commands:
.s - show session status
.ls - list connected browsers
.ld(url) - load JavaScript at `url` into connected browsers
e.g. .ld('http://foo.com/bar.js')
.ldjq - load default jQuery
.ldjqm - load default jQuery Mobile
.ldjqui - load default jQuery UI
.lddojo - load default Dojo
.ldext - load default Ext Core
.ldjq(ver) - load specific version of jQuery, e.g. .ldjq('1.4.3')
.ldjqm(ver) - load specific version of jQuery Mobile, e.g. .ldjqm('1.4.0')
... and more
Receive JSON from browsers for programmatic control with ?json query parameter:
wscat -c ws://repl.ws/{{id}}?json
Repl.ws responses will now be JSON encoded:
< .s
< {"type":"status","browsers":1}
> $('body p').length
< {"type":"msg","msg":"2","from":0}
JSON protocol details on GitHub
Brought to you by Tomasz Janczuk / @tjanczuk