Skip to content

Instantly share code, notes, and snippets.

@csanz
Created April 17, 2020 18:21
Show Gist options
  • Save csanz/e7e203b6dd252d49c61da8e1f3bb0360 to your computer and use it in GitHub Desktop.
Save csanz/e7e203b6dd252d49c61da8e1f3bb0360 to your computer and use it in GitHub Desktop.
Rule I created to block some sites on my son's computer at home.
/*
sample:
redirect all https://www.roblox.com/t requests to http://localhost:3000/
redirect all https://www.roblox.com/t requests to http://localhost:3000/
test:
curl https://www.roblox.com/ --proxy http://192.168.1.84:8001
curl https://www.yahoo.com/ --proxy http://192.168.1.84:8001
expected response:
custom page served inside localhost:3000 (this can be your own server)
*/
module.exports = {
*beforeSendRequest(requestDetail) {
if (requestDetail.url.indexOf('roblox.com') >= 0 ||
requestDetail.url.indexOf('youtube.com') >= 0) {
const newRequestOptions = requestDetail.requestOptions;
requestDetail.protocol = 'http';
newRequestOptions.hostname = '127.0.0.1'
newRequestOptions.port = '3000';
newRequestOptions.path = '/';
newRequestOptions.method = 'GET';
return requestDetail;
}
},
*beforeDealHttpsRequest(requestDetail) {
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment