From a7506a34544f4df3ba65a854c81fadcca2eb303f Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Wed, 2 Sep 2015 12:14:24 +0000 Subject: CRUD stuff almost ready --- js/background.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 js/background.js (limited to 'js/background.js') diff --git a/js/background.js b/js/background.js new file mode 100644 index 0000000..b9ef47b --- /dev/null +++ b/js/background.js @@ -0,0 +1,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"]); -- cgit v1.2.3