-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathharmonproxy.js
31 lines (26 loc) · 1.14 KB
/
harmonproxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var http = require('http'),
httpProxy = require('http-proxy');
var selects = [];
var simpleselect = {};
simpleselect.query = 'head';
simpleselect.func = function (node) {
var out = '<style type="text/css"> img { ';
out +='-webkit-transform: rotate(-90deg); ';
out += '-moz-transform: rotate(-90deg); ';
out += 'filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);}</style>';
node.createWriteStream({ outer: true }).end(out)
}
selects.push(simpleselect);
httpProxy.createServer(
require('harmon')([], selects),
9000, 'localhost'
).listen(8000);
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
output = '<html><head><script>'
output += 'window.onload = function () {'
output += 'document.getElementById("message").innerHTML = "The piece of javascript also inside the head tag wasn\'t touched :)";';
output += '}</script></head><body><h3>A simple example of injecting some css to rotate an image into a page before it is rendered.</h3>'
output += '<image src="http://i.imgur.com/fpMGL.png" /><div id="message"></div></body></html>';
res.end(output);
}).listen(9000);