From 3c49c3578955a338ecce36ef5bcfb59e9867fe1c Mon Sep 17 00:00:00 2001 From: Bjorn Stromberg Date: Tue, 13 Mar 2018 12:03:50 +0900 Subject: [PATCH] v1.0.0 - Initial Release --- CHANGELOG.md | 2 ++ LICENSE | 21 +++++++++++++++++ README.md | 3 +++ background.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 22 ++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 background.js create mode 100644 manifest.json diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2f16a49 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# 1.0.0 +- Initial Release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6024576 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Bjorn Stromberg + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e658dd5 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Intercept Redirect + +Skip tracking redirects that serve no purpose other than to waste your precious time. diff --git a/background.js b/background.js new file mode 100644 index 0000000..748b887 --- /dev/null +++ b/background.js @@ -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']); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..8dcb4a8 --- /dev/null +++ b/manifest.json @@ -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" +}