GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cblanquera/browser-script: Run client scripts from Node

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
example
example
 
 
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

HTTP Browser Script

A Node HTTP plugin that allows you to send browser scripts from the server. (A fun meme project)

Install

$ npm i http-browser-script --save

Express Example

const express = require('express')
const bs = require('http-browser-script')

const app = express()

app.use(bs).listen(3000)

app.get('/foo', function(req, res) {
  //you can use browser references inside here
  const client = function(str1, str2) {
    window.alert(str1)
    document.getElementById('results').innerHTML = str2[0]
  }
  
  //you can pass variables
  res.end(bs.evaluate(client, 'hello', ['World']))
})
<!-- On your client -->
<div id="results"></div>
<script type="text/javascript" src="/browser/script.js"></script>
<script type="text/javascript">
//...
bs.import('/foo')
//...
</script>

HTTP Example

const http = require('http')
const bs = require('browser-script')

const server = http.createServer(function(req, res) {
  if (bs(req, res)) return
  if (req.url === '/foo') {
    //you can use browser references inside here
    const client = function(str1, str2) {
      window.alert(str1)
      document.getElementById('results').innerHTML = str2[0]
    }
    
    //you can pass variables
    res.end(bs.evaluate(client, 'hello', ['World']))
  }
})

server.listen(3000)

You can see more examples in this repo.

About

Run client scripts from Node

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.