From 0fcc8c5e734d5e3ea769c5ef7be9f2200c3aca06 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Wed, 11 Dec 2019 15:06:42 +0000 Subject: More fixes after removing angular --- help.html | 4 +- images/icon-active-128.png | Bin 1211 -> 0 bytes images/icon-active-16.png | Bin 272 -> 0 bytes images/icon-active-19.png | Bin 285 -> 0 bytes images/icon-active-32.png | Bin 402 -> 0 bytes images/icon-active-38.png | Bin 417 -> 0 bytes images/icon-active-48.png | Bin 464 -> 0 bytes images/icon-active-64.png | Bin 575 -> 0 bytes images/icon-dark-128.png | Bin 0 -> 1211 bytes images/icon-dark-16.png | Bin 0 -> 272 bytes images/icon-dark-19.png | Bin 0 -> 285 bytes images/icon-dark-32.png | Bin 0 -> 402 bytes images/icon-dark-38.png | Bin 0 -> 417 bytes images/icon-dark-48.png | Bin 0 -> 464 bytes images/icon-dark-64.png | Bin 0 -> 575 bytes images/icon-disabled-128.png | Bin 1202 -> 0 bytes images/icon-disabled-16.png | Bin 274 -> 0 bytes images/icon-disabled-19.png | Bin 285 -> 0 bytes images/icon-disabled-32.png | Bin 399 -> 0 bytes images/icon-disabled-38.png | Bin 424 -> 0 bytes images/icon-disabled-48.png | Bin 474 -> 0 bytes images/icon-disabled-64.png | Bin 583 -> 0 bytes images/icon-light-128.png | Bin 0 -> 1202 bytes images/icon-light-16.png | Bin 0 -> 274 bytes images/icon-light-19.png | Bin 0 -> 285 bytes images/icon-light-32.png | Bin 0 -> 399 bytes images/icon-light-38.png | Bin 0 -> 424 bytes images/icon-light-48.png | Bin 0 -> 474 bytes images/icon-light-64.png | Bin 0 -> 583 bytes js/background.js | 32 ++++++++-------- js/popup.js | 21 +++++++++-- js/redirect.js | 13 +++++-- js/redirectorpage.js | 2 +- js/util.js | 6 ++- manifest.json | 88 +++++++++++++++++++++++++++++++++---------- popup.html | 8 ++-- redirector.html | 3 +- 37 files changed, 126 insertions(+), 51 deletions(-) delete mode 100644 images/icon-active-128.png delete mode 100644 images/icon-active-16.png delete mode 100644 images/icon-active-19.png delete mode 100644 images/icon-active-32.png delete mode 100644 images/icon-active-38.png delete mode 100644 images/icon-active-48.png delete mode 100644 images/icon-active-64.png create mode 100644 images/icon-dark-128.png create mode 100644 images/icon-dark-16.png create mode 100644 images/icon-dark-19.png create mode 100644 images/icon-dark-32.png create mode 100644 images/icon-dark-38.png create mode 100644 images/icon-dark-48.png create mode 100644 images/icon-dark-64.png delete mode 100644 images/icon-disabled-128.png delete mode 100644 images/icon-disabled-16.png delete mode 100644 images/icon-disabled-19.png delete mode 100644 images/icon-disabled-32.png delete mode 100644 images/icon-disabled-38.png delete mode 100644 images/icon-disabled-48.png delete mode 100644 images/icon-disabled-64.png create mode 100644 images/icon-light-128.png create mode 100644 images/icon-light-16.png create mode 100644 images/icon-light-19.png create mode 100644 images/icon-light-32.png create mode 100644 images/icon-light-38.png create mode 100644 images/icon-light-48.png create mode 100644 images/icon-light-64.png diff --git a/help.html b/help.html index 78ca8ad..cd41d02 100644 --- a/help.html +++ b/help.html @@ -4,7 +4,7 @@ REDIRECTOR HELP - + @@ -24,6 +24,7 @@
  1. No Processing
  2. URL decode matches
  3. +
  4. Double URL decode matches
  5. URL encode matches
  6. Base64 decode matches
@@ -101,6 +102,7 @@ won't accept this as a new url to redirect to. So, in cases like these you can select the URL Decode matches option and then all matches will be URL decoded (turned from e.g. http%3A%2F%2Fbar%2Ecom to http://bar.com) before being inserted into the target url. +
  • Double URL Decode matches: Same as above except apply the decode function twice, if the url has been encoded twice.
  • URL Encode matches: The opposite of URL Decode matches. Let's say you want to redirect all requests to a domain like http://example.com to some proxy site that took the url to proxy as an url parameter. Then you might do something like the regular expression pattern diff --git a/images/icon-active-128.png b/images/icon-active-128.png deleted file mode 100644 index 5ef6a8b..0000000 Binary files a/images/icon-active-128.png and /dev/null differ diff --git a/images/icon-active-16.png b/images/icon-active-16.png deleted file mode 100644 index 9482d4b..0000000 Binary files a/images/icon-active-16.png and /dev/null differ diff --git a/images/icon-active-19.png b/images/icon-active-19.png deleted file mode 100644 index def8e2f..0000000 Binary files a/images/icon-active-19.png and /dev/null differ diff --git a/images/icon-active-32.png b/images/icon-active-32.png deleted file mode 100644 index 2bc01ff..0000000 Binary files a/images/icon-active-32.png and /dev/null differ diff --git a/images/icon-active-38.png b/images/icon-active-38.png deleted file mode 100644 index 2e08aec..0000000 Binary files a/images/icon-active-38.png and /dev/null differ diff --git a/images/icon-active-48.png b/images/icon-active-48.png deleted file mode 100644 index f63956b..0000000 Binary files a/images/icon-active-48.png and /dev/null differ diff --git a/images/icon-active-64.png b/images/icon-active-64.png deleted file mode 100644 index accf6a5..0000000 Binary files a/images/icon-active-64.png and /dev/null differ diff --git a/images/icon-dark-128.png b/images/icon-dark-128.png new file mode 100644 index 0000000..5ef6a8b Binary files /dev/null and b/images/icon-dark-128.png differ diff --git a/images/icon-dark-16.png b/images/icon-dark-16.png new file mode 100644 index 0000000..9482d4b Binary files /dev/null and b/images/icon-dark-16.png differ diff --git a/images/icon-dark-19.png b/images/icon-dark-19.png new file mode 100644 index 0000000..def8e2f Binary files /dev/null and b/images/icon-dark-19.png differ diff --git a/images/icon-dark-32.png b/images/icon-dark-32.png new file mode 100644 index 0000000..2bc01ff Binary files /dev/null and b/images/icon-dark-32.png differ diff --git a/images/icon-dark-38.png b/images/icon-dark-38.png new file mode 100644 index 0000000..2e08aec Binary files /dev/null and b/images/icon-dark-38.png differ diff --git a/images/icon-dark-48.png b/images/icon-dark-48.png new file mode 100644 index 0000000..f63956b Binary files /dev/null and b/images/icon-dark-48.png differ diff --git a/images/icon-dark-64.png b/images/icon-dark-64.png new file mode 100644 index 0000000..accf6a5 Binary files /dev/null and b/images/icon-dark-64.png differ diff --git a/images/icon-disabled-128.png b/images/icon-disabled-128.png deleted file mode 100644 index 002c9d5..0000000 Binary files a/images/icon-disabled-128.png and /dev/null differ diff --git a/images/icon-disabled-16.png b/images/icon-disabled-16.png deleted file mode 100644 index 23d6675..0000000 Binary files a/images/icon-disabled-16.png and /dev/null differ diff --git a/images/icon-disabled-19.png b/images/icon-disabled-19.png deleted file mode 100644 index f5eaa06..0000000 Binary files a/images/icon-disabled-19.png and /dev/null differ diff --git a/images/icon-disabled-32.png b/images/icon-disabled-32.png deleted file mode 100644 index 28d2dc0..0000000 Binary files a/images/icon-disabled-32.png and /dev/null differ diff --git a/images/icon-disabled-38.png b/images/icon-disabled-38.png deleted file mode 100644 index 7e900ba..0000000 Binary files a/images/icon-disabled-38.png and /dev/null differ diff --git a/images/icon-disabled-48.png b/images/icon-disabled-48.png deleted file mode 100644 index e2826c4..0000000 Binary files a/images/icon-disabled-48.png and /dev/null differ diff --git a/images/icon-disabled-64.png b/images/icon-disabled-64.png deleted file mode 100644 index 97f057a..0000000 Binary files a/images/icon-disabled-64.png and /dev/null differ diff --git a/images/icon-light-128.png b/images/icon-light-128.png new file mode 100644 index 0000000..002c9d5 Binary files /dev/null and b/images/icon-light-128.png differ diff --git a/images/icon-light-16.png b/images/icon-light-16.png new file mode 100644 index 0000000..23d6675 Binary files /dev/null and b/images/icon-light-16.png differ diff --git a/images/icon-light-19.png b/images/icon-light-19.png new file mode 100644 index 0000000..f5eaa06 Binary files /dev/null and b/images/icon-light-19.png differ diff --git a/images/icon-light-32.png b/images/icon-light-32.png new file mode 100644 index 0000000..28d2dc0 Binary files /dev/null and b/images/icon-light-32.png differ diff --git a/images/icon-light-38.png b/images/icon-light-38.png new file mode 100644 index 0000000..7e900ba Binary files /dev/null and b/images/icon-light-38.png differ diff --git a/images/icon-light-48.png b/images/icon-light-48.png new file mode 100644 index 0000000..e2826c4 Binary files /dev/null and b/images/icon-light-48.png differ diff --git a/images/icon-light-64.png b/images/icon-light-64.png new file mode 100644 index 0000000..97f057a Binary files /dev/null and b/images/icon-light-64.png differ diff --git a/js/background.js b/js/background.js index e74ae50..3c84b38 100644 --- a/js/background.js +++ b/js/background.js @@ -1,8 +1,8 @@ //This is the background script. It is responsible for actually redirecting requests, //as well as monitoring changes in the redirects and the disabled status and reacting to them. -function log(msg) { - if (log.enabled) { +function log(msg, force) { + if (log.enabled || force) { console.log('REDIRECTOR: ' + msg); } } @@ -127,12 +127,12 @@ function monitorChanges(changes, namespace) { } if (changes.logging) { - log('Logging settings have changed, updating...'); - updateLogging(); + log.enabled = changes.logging.newValue; + log('Logging settings have changed to ' + changes.logging.newValue, true); //Always want this to be logged... } if (changes.enableNotifications){ - log('notifications setting changed'); - enableNotifications=changes.enableNotifications.newValue; + log('notifications setting changed to ' + changes.enableNotifications.newValue); + enableNotifications = changes.enableNotifications.newValue; } } chrome.storage.onChanged.addListener(monitorChanges); @@ -201,7 +201,12 @@ function setUpRedirectListener() { function updateIcon() { chrome.storage.local.get({disabled:false}, function(obj) { - setIcon(obj.disabled ? 'icon-disabled' : 'icon-active'); + if (window.matchMedia('(prefers-color-scheme: dark)')) { + setIcon('icon-light'); + } else { + setIcon('icon-dark'); + } + //setIcon(obj.disabled ? 'icon-light' : 'icon-dark'); }); } @@ -327,12 +332,9 @@ chrome.runtime.onMessage.addListener( //First time setup updateIcon(); -function updateLogging() { - chrome.storage.local.get({logging:false}, function(obj) { - log.enabled = obj.logging; - }); -} -updateLogging(); +chrome.storage.local.get({logging:false}, function(obj) { + log.enabled = obj.logging; +}); chrome.storage.local.get({ isSyncEnabled: false @@ -388,7 +390,7 @@ function sendNotifications(redirect, originalUrl, redirectedUrl ){ "items": items, "title": head, "message": head, - "iconUrl": "images/icon-active-38.png" + "iconUrl": "images/icon-dark-38.png" }); } else{ var message = "Applied rule : " + redirect.description + " and redirected original page " + originalUrl + " to " + redirectedUrl; @@ -397,7 +399,7 @@ function sendNotifications(redirect, originalUrl, redirectedUrl ){ "type": "basic", "title": "Redirector", "message": message, - "iconUrl": "images/icon-active-38.png" + "iconUrl": "images/icon-dark-38.png" }); } } diff --git a/js/popup.js b/js/popup.js index 36d0685..8ac707c 100644 --- a/js/popup.js +++ b/js/popup.js @@ -15,10 +15,7 @@ function toggle(prop) { }); } -storage.get({logging:false, enableNotifications:false, disabled: false}, function(obj) { - viewModel = obj; - applyBinding(); -}) + function openRedirectorSettings() { @@ -41,3 +38,19 @@ function openRedirectorSettings() { }); return; }; + + +function pageLoad() { + storage.get({logging:false, enableNotifications:false, disabled: false}, function(obj) { + viewModel = obj; + applyBinding(); + }) + + el('#enable-notifications').addEventListener('input', () => toggle('enableNotifications')); + el('#enable-logging').addEventListener('input', () => toggle('logging')); + el('#toggle-disabled').addEventListener('click', () => toggle('disabled')); + el('#open-redirector-settings').addEventListener('click', openRedirectorSettings); +} + +pageLoad(); +//Setup page... diff --git a/js/redirect.js b/js/redirect.js index 3bdf0f0..dfc59aa 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -155,6 +155,10 @@ Redirect.prototype = { return; } + if (match.isMatch && !match.redirectTo.match(/^https?\:\/\//)) { + this.error = 'The redirect result must start with http:// or https://, current result is: "' + match.redirectTo + "."; + return; + } if (!match.isMatch) { this.error = 'The include pattern does not match the example url.'; return; @@ -241,6 +245,7 @@ Redirect.prototype = { noProcessing : 'Use matches as they are', urlEncode : 'E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2', urlDecode : 'E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2', + doubleUrlDecode : 'E.g. turn %252Fbar%252Ffoo%253Fx%253D2 into /bar/foo?x=2', base64Decode : 'E.g. turn aHR0cDovL2Nubi5jb20= into http://cnn.com' }; @@ -264,11 +269,11 @@ Redirect.prototype = { var repl = matches[i] || ''; if (this.processMatches == 'urlDecode') { repl = unescape(repl); - } - if (this.processMatches == 'urlEncode') { + } else if (this.processMatches == 'doubleUrlDecode') { + repl = unescape(unescape(repl)); + } else if (this.processMatches == 'urlEncode') { repl = encodeURIComponent(repl); - } - if (this.processMatches == 'base64decode') { + } else if (this.processMatches == 'base64decode') { if (repl.indexOf('%') > -1) { repl = unescape(repl); } diff --git a/js/redirectorpage.js b/js/redirectorpage.js index 379da96..fd5be8c 100644 --- a/js/redirectorpage.js +++ b/js/redirectorpage.js @@ -18,7 +18,7 @@ function saveChanges() { console.log(response.message); if(response.message.indexOf("Redirects failed to save") > -1){ showMessage(response.message, false); - }else{ + } else{ console.log('Saved ' + arr.length + ' redirects at ' + new Date() + '. Message from background page:' + response.message); } }); diff --git a/js/util.js b/js/util.js index d8ad0db..43eaa69 100644 --- a/js/util.js +++ b/js/util.js @@ -12,8 +12,10 @@ function dataBind(el, dataObject) { if (tag.tagName.toLowerCase() === 'input') { if (tag.getAttribute('type').toLowerCase() === 'radio') { tag.checked = dataObject[prop] === tag.getAttribute('value'); - } else { - tag.value = dataObject[prop]; + } else if (tag.getAttribute('type').toLowerCase() === 'checkbox') { + tag.checked = dataObject[prop]; + } else { + tag.value = dataObject[prop]; } } else if (tag.tagName.toLowerCase() === 'select') { for (let opt of tag.querySelectorAll('option')) { diff --git a/manifest.json b/manifest.json index b907d61..b95744b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,40 +1,90 @@ { - "manifest_version": 2, "name": "Redirector", "description": "Automatically redirect content based on user-defined rules.", "version": "3.5", - - "icons": { "16": "images/icon-active-16.png", - "32": "images/icon-active-32.png", - "48": "images/icon-active-48.png", - "64": "images/icon-active-64.png", - "128": "images/icon-active-128.png" }, - - "permissions" : ["webRequest", "webRequestBlocking", "storage", "tabs", "http://*/*", "https://*/*", "notifications"], - + "icons": { + "16": "images/icon-dark-16.png", + "19": "images/icon-dark-19.png", + "32": "images/icon-dark-32.png", + "38": "images/icon-dark-38.png", + "48": "images/icon-dark-48.png", + "64": "images/icon-dark-64.png", + "128": "images/icon-dark-128.png" + }, + "permissions": [ + "webRequest", + "webRequestBlocking", + "storage", + "tabs", + "http://*/*", + "https://*/*", + "notifications" + ], "applications": { "gecko": { "id": "redirector@einaregilsson.com" } }, - - "background": { - "scripts": ["js/redirect.js", "js/background.js"], + "background": { + "scripts": [ + "js/redirect.js", + "js/background.js" + ], "persistent": true }, - "options_ui": { "page": "popup.html", "chrome_style": true }, - "browser_action": { "default_icon": { - "19": "images/icon-active-19.png", - "38": "images/icon-active-38.png" + "16": "images/icon-dark-16.png", + "19": "images/icon-dark-19.png", + "32": "images/icon-dark-32.png", + "38": "images/icon-dark-38.png", + "48": "images/icon-dark-48.png", + "64": "images/icon-dark-64.png", + "128": "images/icon-dark-128.png" }, "default_title": "Redirector", - "default_popup": "popup.html" + "default_popup": "popup.html", + "theme_icons": [ + { + "light": "images/icon-dark-16.png", + "dark": "images/icon-light-16.png", + "size": 16 + }, + { + "light": "images/icon-dark-19.png", + "dark": "images/icon-light-19.png", + "size": 19 + }, + { + "light": "images/icon-dark-32.png", + "dark": "images/icon-light-32.png", + "size": 32 + }, + { + "light": "images/icon-dark-38.png", + "dark": "images/icon-light-38.png", + "size": 38 + }, + { + "light": "images/icon-dark-48.png", + "dark": "images/icon-light-48.png", + "size": 48 + }, + { + "light": "images/icon-dark-64.png", + "dark": "images/icon-light-64.png", + "size": 64 + }, + { + "light": "images/icon-dark-128.png", + "dark": "images/icon-light-128.png", + "size": 128 + } + ] } -} +} \ No newline at end of file diff --git a/popup.html b/popup.html index fd8a8f0..1eba021 100644 --- a/popup.html +++ b/popup.html @@ -8,10 +8,10 @@

    REDIRECTOR

    Disabled
    - - - - + + + + diff --git a/redirector.html b/redirector.html index bafe46b..593b16f 100644 --- a/redirector.html +++ b/redirector.html @@ -5,7 +5,7 @@ - +
    @@ -94,6 +94,7 @@ + -- cgit v1.2.3