HTTP Instrumentation (from the page-side)
A chrome extension providing the ability for page-side js to modify http requests and responses, based on a variety of conditions.
You can get it from the webstore.
Grabs a url with custom request headers:
var tamper = {
headers: {
Origin: 'totally-not-evil.com'
}
};
var url = TamperApi.makeUrl('http://foo.com', tamper);
fetch(url); // or whatever
It can also alter response headers.
For example, to make a Cross-Origin request look normal to the server (and succeed in the browser):
var tamper = {
headers : {
Origin: null // null means to remove this header
},
response : {
headers : {
access-control-allow-origin : '*'
}
}
};
var url = TamperApi.makeUrl('http://cross-origin.com', tamper);
Tampering can also be done by regex match (against request url).
Useful if you want to effect some functionality that you don't pass a url to directly.
// add returns a promise
TamperApi.add({
regexes : [ /\?q=lumberjack/, /* ... */ ], // if anything in this list matches, tampering will occur
tamper : { /* ... */ },
}).then(() => {
searchFor('lumberjack');
});
This project is released into the public domain via the Unlicense - see the LICENSE.md file for details
To install a copy for local work, or if you just don't want to get it via the webstore, you may use Chrome's Developer Mode.
- Clone the repo
- In top right of chrome, click the vertical-ellipsis > More Tools > Extensions
- Check the box labelled 'Developer mode'
- Click 'Load Unpacked Extension'
- Select directory 'ext' under the repo root.
- Fork it
- Create your feature branch (
git checkout -b feature-fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature-fooBar
) - Create a new Pull Request