Skip to content

Instantly share code, notes, and snippets.

@fabe
Created March 22, 2016 11:30
Show Gist options
  • Save fabe/887b7801ce9f10603b62 to your computer and use it in GitHub Desktop.
Save fabe/887b7801ce9f10603b62 to your computer and use it in GitHub Desktop.
Chrome plugin to send every network request to a server via socket.io.
{
"name": "plugin",
"description": "plugin description.",
"devtools_page": "plugin.html",
"permissions": [
"http://*/*",
"https://*/*"
],
"manifest_version": 1,
"version": "1"
}
<html>
<head>
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script src="plugin.js"></script>
</head>
<body></body>
</html>
var socket = io.connect('http://localhost:8888'); // your url for the request
chrome.devtools.network.onRequestFinished.addListener(function(request) {
var data = {};
// get request data
data.url = request.request.url;
data.size = request.response.content.size;
data.type = request.response.content.mimeType;
data.time = request.time;
data.start = request.startedDateTime;
// send data to server
socket.emit('data', data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment