Skip to content

Commit

Permalink
v1.0.0 - Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Mar 13, 2018
0 parents commit 3c49c35
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 1.0.0
- Initial Release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Bjorn Stromberg <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Intercept Redirect

Skip tracking redirects that serve no purpose other than to waste your precious time.
62 changes: 62 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const sites = {
'exit.sc': function (q) {
return q.url;
},
'l.facebook.com': function (q) {
return q.u;
},
'www.google.com': function (q) {
return q.url;
},
'l.instagram.com': function (q) {
return q.u;
},
'l.messenger.com': function (q) {
return q.u;
},
'slack-redir.net': function (q) {
return q.url;
},
'steamcommunity.com': function (q) {
return q.url;
},
't.umblr.com': function (q) {
return q.z;
},
'vk.com': function (q) {
return q.to;
},
'www.youtube.com': function (q) {
return q.q;
}
};

const urls = [
'https://exit.sc/*',
'https://l.facebook.com/l.php*',
'https://www.google.com/url*',
'https://l.instagram.com/*',
'https://l.messenger.com/l.php*',
'https://slack-redir.net/link*',
'https://steamcommunity.com/linkfilter/*',
'https://t.umblr.com/redirect*',
'https://vk.com/away.php*',
'https://www.youtube.com/redirect*'
];

chrome.webRequest.onBeforeRequest.addListener(function(request) {
const url = new URL(request.url);
const pairs = url.search.slice(1).split('&');

const q = pairs.reduce((o, pair) => {
const [k, v] = pair.split('=');
o[k] = decodeURIComponent(v);
return o;
}, {});

const redirectUrl = sites[url.host](q);

if (redirectUrl) {
return { redirectUrl };
}
}, { urls }, ['blocking']);
22 changes: 22 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"background": {
"scripts": [ "background.js" ]
},
"manifest_version": 2,
"name": "Intercept Redirect",
"permissions": [
"webRequest",
"webRequestBlocking",
"https://exit.sc/",
"https://l.facebook.com/",
"https://www.google.com/",
"https://l.instagram.com/",
"https://l.messenger.com/",
"https://slack-redir.net/",
"https://steamcommunity.com/",
"https://t.umblr.com/",
"https://vk.com/",
"https://www.youtube.com/"
],
"version": "1.0.0"
}

0 comments on commit 3c49c35

Please sign in to comment.