Skip to content

Run remote commands in a web page via HTTP requests.

Notifications You must be signed in to change notification settings

azer/remote-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

remote-control

Run remote commands in a web page via HTTP requests.

Install

$ npm install azer/remote-control

Usage

Start running;

$ remote-control -p [port] # or; ./node_modules/.bin/remote-control
// => Running at [internal-ip]:[port]

And include it in your page;

<script type="text/javascript" src="http://[ip]:[port]"></script>

Now remote-control API is available in your web page. You can register commands;

remoteControl.register('reload', function () {
  location.reload(true)
})

The browser on this page will be connected to the remote control server via websockets.

$ curl http://[ip]:[port]/commands/reload
// => Ran command "reload" on [n] clients.

Example Commands

Reload CSS Stylesheets

remoteControl.register('reload-css', reloadCSS)

function reloadCSS () {
  const styles = document.querySelectorAll('link')
  for (let style of styles) {
    if (style.rel === "stylesheet") {
      style.href = style.href.replace(/\.css[\?\d]*$/, '.css?' + Date.now())
    }
  }
}

About

Run remote commands in a web page via HTTP requests.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published