aboutsummaryrefslogtreecommitdiff
path: root/js/background.js
blob: b9ef47b6e945fd9f3057381b3c7bba586f25ea29 (plain) (blame)
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
function checkForRedirect(details) {

	//We only allow GET request to be redirected, don't want to accidentally redirect
	//sensitive POST parameters
	if (details.method != 'GET') {
		return null;
	}

  	if (details.url.match(/mbl\.is/)) {
  		console.log('Redirecting ' + details.url);
  		return  {redirectUrl: 'http://foo.is'}; //this doesn't work
  	}
  	return  null; //{redirectUrl: 'http://foo.is'}; //this doesn't work
}


var filter = {urls:["http://*/*", "https://*/*"]};

//TODO: Better browser detection...
var isChrome = !!navigator.userAgent.match(/ Chrome\//);

var ev = isChrome ? chrome.webRequest.onBeforeRequest : chrome.webRequest.onBeforeSendHeaders;
ev.addListener(checkForRedirect, filter, ["blocking"]);