aboutsummaryrefslogtreecommitdiff
path: root/js/background.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2015-09-02 12:14:24 +0000
committerEinar Egilsson <einar@einaregilsson.com>2015-09-02 12:14:24 +0000
commita7506a34544f4df3ba65a854c81fadcca2eb303f (patch)
tree7421ff72bcfabfac94bb5ddd48e33c73af75a7e2 /js/background.js
parent4d9993f230c59f8a97767599b1d81eeeac3d35ec (diff)
CRUD stuff almost ready
Diffstat (limited to 'js/background.js')
-rw-r--r--js/background.js25
1 files changed, 25 insertions, 0 deletions
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"]);