Skip to content

Instantly share code, notes, and snippets.

@tistaharahap
Created October 7, 2013 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tistaharahap/6871441 to your computer and use it in GitHub Desktop.
Save tistaharahap/6871441 to your computer and use it in GitHub Desktop.
(function(win) {
var xhr = win.XMLHttpRequest ? win.XMLHttpRequest : null;
if(xhr === null)
return;
var org = xhr.open;
xhr.open = function(method, url, someBool) {
var uris = url.split('?');
if(uris.length > 2)
return;
var cleanURL = uris[0].replace('http://', '').replace('https://', '').split('/');
if(cleanURL.length < 2)
return;
var host = cleanURL[0];
var blacklist = [
'172.25.48.182',
'172.25.48.182:8006',
'172.25.48.182:8004',
'172.25.48.111',
'ibnads.xl.co.id',
'ibnads.xl.co.id:8006',
'ibnads.xl.co.id:8004'
];
for(var key in blacklist) {
if(blacklist[key] === host) {
blockPlease();
return;
}
}
org.open(method, url, someBool);
};
function blockPlease() {
console.log('No go bro. Content is blocked. Don\'t invade our content!');
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment