script-injector

Inject inline javascript into an HTML stream.

MIT 10 个版本
安装
npm install script-injector
yarn add script-injector
pnpm add script-injector
bun add script-injector
README

#script-injector

  1. provides a through stream that allows you to inject inline javascript into an html text stream.
  2. Uses trumpet to parse your html.
  3. Should only be used for good, never for evil

Installation

npm install script-injector

How to use

Just pipe a stream of html through script-injector. You can pass in either some stringified code or a function object. What could be easier?

scriptInjector = require('script-injector');

// Then do something like this somewhere else

fs.createReadStream('anHTMLFile')
  .pipe(scriptInjector(aFunction))
  .pipe(someOtherPlace);

script-injector will insert the provided code before your first script tags, or just before </body> if you don't have any other scripts.

版本列表
1.0.0 2015-04-13
0.1.7 2014-01-25
0.1.6 2013-10-19
0.1.5 2013-09-19
0.1.4 2013-08-30
0.1.3 2013-08-30
0.1.2 2013-07-21
0.1.1 2013-07-19
0.1.0 2013-07-09
0.0.1 2013-05-01