Noin
Command line utility that moves all the inline scripts in an .html file and put them into their own .js files. It then replaces the inline scripts with script tags linking to the newly created .js files. It also goes through and removes all inline event listeners and moves them into their own file.
Installation
To install, just run:
npm install -g noin
Usage
To use noin on an individual file simply run:
noin index.html
To use noin on an entire folder add the -r flag:
noin -r directory
To have noin backup the files it processes use add the -b flag:
noin -b index.html
Example
Noin will take in an HTML file:
index.html
p Element div Element Another div ELement Another p Element
It backs up the file (index.html.old), then it generates individual .js files for each inline script and inline event listener
index_script0.js
console;
index_script1.js
console;
index_events.js
var listener_0 = document;listener_0;var listener_1 = document;listener_1;var named = document;named;var listener_2 = document;listener_2;
And rips out all the inline script and inline events and links them properly to the .js file (it will add id's to elements that have inline events but no id).
index.html
p Element div Element Another div ELement Another p Element
Notice
Put together for csp testing purposes. It's pretty simple code, but was thrown together quickly and not thourougly tested. Use at your own risk.