diff options
| -rw-r--r-- | help.html | 4 | ||||
| -rw-r--r-- | images/icon-dark-128.png (renamed from images/icon-active-128.png) | bin | 1211 -> 1211 bytes | |||
| -rw-r--r-- | images/icon-dark-16.png (renamed from images/icon-active-16.png) | bin | 272 -> 272 bytes | |||
| -rw-r--r-- | images/icon-dark-19.png (renamed from images/icon-active-19.png) | bin | 285 -> 285 bytes | |||
| -rw-r--r-- | images/icon-dark-32.png (renamed from images/icon-active-32.png) | bin | 402 -> 402 bytes | |||
| -rw-r--r-- | images/icon-dark-38.png (renamed from images/icon-active-38.png) | bin | 417 -> 417 bytes | |||
| -rw-r--r-- | images/icon-dark-48.png (renamed from images/icon-active-48.png) | bin | 464 -> 464 bytes | |||
| -rw-r--r-- | images/icon-dark-64.png (renamed from images/icon-active-64.png) | bin | 575 -> 575 bytes | |||
| -rw-r--r-- | images/icon-light-128.png (renamed from images/icon-disabled-128.png) | bin | 1202 -> 1202 bytes | |||
| -rw-r--r-- | images/icon-light-16.png (renamed from images/icon-disabled-16.png) | bin | 274 -> 274 bytes | |||
| -rw-r--r-- | images/icon-light-19.png (renamed from images/icon-disabled-19.png) | bin | 285 -> 285 bytes | |||
| -rw-r--r-- | images/icon-light-32.png (renamed from images/icon-disabled-32.png) | bin | 399 -> 399 bytes | |||
| -rw-r--r-- | images/icon-light-38.png (renamed from images/icon-disabled-38.png) | bin | 424 -> 424 bytes | |||
| -rw-r--r-- | images/icon-light-48.png (renamed from images/icon-disabled-48.png) | bin | 474 -> 474 bytes | |||
| -rw-r--r-- | images/icon-light-64.png (renamed from images/icon-disabled-64.png) | bin | 583 -> 583 bytes | |||
| -rw-r--r-- | js/background.js | 32 | ||||
| -rw-r--r-- | js/popup.js | 21 | ||||
| -rw-r--r-- | js/redirect.js | 13 | ||||
| -rw-r--r-- | js/redirectorpage.js | 2 | ||||
| -rw-r--r-- | js/util.js | 6 | ||||
| -rw-r--r-- | manifest.json | 88 | ||||
| -rw-r--r-- | popup.html | 8 | ||||
| -rw-r--r-- | redirector.html | 3 | 
23 files changed, 126 insertions, 51 deletions
| @@ -4,7 +4,7 @@  		<title>REDIRECTOR HELP</title>  		<meta charset="UTF-8">  		<link rel="stylesheet" href="css/help.css" /> -		<link rel="shortcut icon" href="images/icon-active-32.png"> +		<link rel="shortcut icon" href="images/icon-dark-32.png">  	</head>  	<body> @@ -24,6 +24,7 @@  						<ol>  							<li><a href="#noprocessing">No Processing</a></li>  							<li><a href="#urldecodematches">URL decode matches</a></li> +							<li><a href="#doubleurldecodematches">Double URL decode matches</a></li>  							<li><a href="#urlencodematches">URL encode matches</a></li>  							<li><a href="#base64decodematches">Base64 decode matches</a></li>  						</ol> @@ -101,6 +102,7 @@  		            won't accept this as a new url to redirect to. So, in cases like these you can select the <em>URL Decode matches</em> option and then all  		            matches will be URL decoded (turned from e.g. <span class="url">http%3A%2F%2Fbar%2Ecom</span> to <span class="url">http://bar.com</span>) before being inserted into the target url.  		            </li> +		            <li><a name="doubleurldecodematches"></a><strong>Double URL Decode matches:</strong> Same as above except apply the decode function twice, if the url has been encoded twice.</li>  		            <li><a name="urlencodematches"></a><strong>URL Encode matches:</strong> The opposite of <a href="#urldecodematches">URL Decode matches</a>. Let's say you want to redirect all requests to  		            a domain like <span class="url">http://example.com</span> 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-dark-128.pngBinary files differ index 5ef6a8b..5ef6a8b 100644 --- a/images/icon-active-128.png +++ b/images/icon-dark-128.png diff --git a/images/icon-active-16.png b/images/icon-dark-16.pngBinary files differ index 9482d4b..9482d4b 100644 --- a/images/icon-active-16.png +++ b/images/icon-dark-16.png diff --git a/images/icon-active-19.png b/images/icon-dark-19.pngBinary files differ index def8e2f..def8e2f 100644 --- a/images/icon-active-19.png +++ b/images/icon-dark-19.png diff --git a/images/icon-active-32.png b/images/icon-dark-32.pngBinary files differ index 2bc01ff..2bc01ff 100644 --- a/images/icon-active-32.png +++ b/images/icon-dark-32.png diff --git a/images/icon-active-38.png b/images/icon-dark-38.pngBinary files differ index 2e08aec..2e08aec 100644 --- a/images/icon-active-38.png +++ b/images/icon-dark-38.png diff --git a/images/icon-active-48.png b/images/icon-dark-48.pngBinary files differ index f63956b..f63956b 100644 --- a/images/icon-active-48.png +++ b/images/icon-dark-48.png diff --git a/images/icon-active-64.png b/images/icon-dark-64.pngBinary files differ index accf6a5..accf6a5 100644 --- a/images/icon-active-64.png +++ b/images/icon-dark-64.png diff --git a/images/icon-disabled-128.png b/images/icon-light-128.pngBinary files differ index 002c9d5..002c9d5 100644 --- a/images/icon-disabled-128.png +++ b/images/icon-light-128.png diff --git a/images/icon-disabled-16.png b/images/icon-light-16.pngBinary files differ index 23d6675..23d6675 100644 --- a/images/icon-disabled-16.png +++ b/images/icon-light-16.png diff --git a/images/icon-disabled-19.png b/images/icon-light-19.pngBinary files differ index f5eaa06..f5eaa06 100644 --- a/images/icon-disabled-19.png +++ b/images/icon-light-19.png diff --git a/images/icon-disabled-32.png b/images/icon-light-32.pngBinary files differ index 28d2dc0..28d2dc0 100644 --- a/images/icon-disabled-32.png +++ b/images/icon-light-32.png diff --git a/images/icon-disabled-38.png b/images/icon-light-38.pngBinary files differ index 7e900ba..7e900ba 100644 --- a/images/icon-disabled-38.png +++ b/images/icon-light-38.png diff --git a/images/icon-disabled-48.png b/images/icon-light-48.pngBinary files differ index e2826c4..e2826c4 100644 --- a/images/icon-disabled-48.png +++ b/images/icon-light-48.png diff --git a/images/icon-disabled-64.png b/images/icon-light-64.pngBinary files differ index 97f057a..97f057a 100644 --- a/images/icon-disabled-64.png +++ b/images/icon-light-64.png 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);  		}  	}); @@ -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 @@ -8,10 +8,10 @@  	<body>  		<h1>REDIRECTOR</h1>  		<div class="disabled"><span data-show="disabled" style="display: none;">Disabled</span></div> -		<button onclick="toggle('disabled')"><span data-show="disabled">Enable Redirector</span><span data-show="!disabled">Disable Redirector</span></button> -        <button onclick="openRedirectorSettings()">Edit Redirects</button> -		<label><input type="checkbox" data-bind="logging" onclick="toggle('logging')" /> Enable logging</label> -		<label><input type="checkbox" data-bind="enableNotifications" onclick="toggle('enableNotifications')" /> Enable notifications</label> +		<button id="toggle-disabled"><span data-show="disabled" style="display:none">Enable Redirector</span><span data-show="!disabled">Disable Redirector</span></button> +        <button id="open-redirector-settings">Edit Redirects</button> +		<label><input id="enable-logging" type="checkbox" data-bind="logging" /> Enable logging</label> +		<label><input id="enable-notifications" type="checkbox" data-bind="enableNotifications" /> Enable notifications</label>  		<script src="js/stub.js"></script>  		<script src="js/util.js"></script>  		<script src="js/popup.js"></script> diff --git a/redirector.html b/redirector.html index bafe46b..593b16f 100644 --- a/redirector.html +++ b/redirector.html @@ -5,7 +5,7 @@  		<meta charset="UTF-8">  		<link rel="stylesheet" href="css/redirector.css" />  		<!-- ☈ --> -		<link rel="shortcut icon" href="images/icon-active-32.png"> +		<link rel="shortcut icon" href="images/icon-dark-32.png">  	</head>  	<body>  		<div id="cover"> @@ -94,6 +94,7 @@  							<option value="noProcessing">No Processing</option>  							<option value="urlEncode">URL Encode</option>  							<option value="urlDecode">URL Decode</option> +							<option value="doubleUrlDecode">Double URL Decode</option>  							<option value="base64decode">Base64 Decode</option>  						</select>  						<span class="placeholder" data-bind="processMatchesExampleText"></span> | 
