aboutsummaryrefslogtreecommitdiff
path: root/js/stub.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2019-12-11 13:17:42 +0000
committerEinar Egilsson <einar@einaregilsson.com>2019-12-11 13:17:42 +0000
commitb53d093463e94096f16f0fd7656fc88d642faa3d (patch)
treeef8b1a0b8f07c2ab965a805421e1564622ac814f /js/stub.js
parentcdb8d5e3d5af6dc2d4d630481c4385734ecc6a1d (diff)
Completely removed angular.js
Diffstat (limited to 'js/stub.js')
-rw-r--r--js/stub.js112
1 files changed, 112 insertions, 0 deletions
diff --git a/js/stub.js b/js/stub.js
new file mode 100644
index 0000000..59b2da9
--- /dev/null
+++ b/js/stub.js
@@ -0,0 +1,112 @@
+
+//Dummy file to use while developing the UI. This way we can just develop it on a local fileserver, and don't have to reload
+//an extension for every tiny change!
+
+if (!chrome || !chrome.storage || !chrome.storage.local) {
+
+ let testData = {
+ "createdBy": "Redirector v3.2",
+ "createdAt": "2019-12-09T12:54:13.391Z",
+ "redirects": [
+ {
+ "description": "Mbl test",
+ "exampleUrl": "https://mbl.is",
+ "exampleResult": "http://foo.is",
+ "error": null,
+ "includePattern": "*mbl*",
+ "excludePattern": "",
+ "patternDesc": "My description",
+ "redirectUrl": "http://foo.is",
+ "patternType": "R",
+ "processMatches": "noProcessing",
+ "disabled": false,
+ "appliesTo": [
+ "main_frame",
+ "script"
+ ]
+ },
+ {
+ "description": "Msdfsdfbl test",
+ "exampleUrl": "https://mbssfdsl.is",
+ "exampleResult": "http://foo.is",
+ "error": null,
+ "includePattern": "*mbl*",
+ "excludePattern": "",
+ "patternDesc": "My description",
+ "redirectUrl": "http://foo.is",
+ "patternType": "W",
+ "processMatches": "urlEncode",
+ "disabled": false,
+ "appliesTo": [
+ "main_frame",
+ "sub_frame"
+ ]
+ }, {
+ "description": "https://foo.is?s=joh",
+ "exampleUrl": "https://foo.is?s=joh",
+ "exampleResult": "https://foo.is",
+ "error": null,
+ "includePattern": "(.*)(\\?s=)(.*)",
+ "excludePattern": "",
+ "patternDesc": "Test error",
+ "redirectUrl": "$1",
+ "patternType": "R",
+ "processMatches": "noProcessing",
+ "disabled": false,
+ "appliesTo": [
+ "main_frame"
+ ]
+ }
+ ]
+ };
+
+ localStorage.redirector = JSON.stringify(testData);
+
+
+ //Make dummy for testing...
+ window.chrome = window.chrome || {};
+ chrome.storage = {
+ local : {
+ get : function(defaults, callback) {
+ let data = JSON.parse(localStorage.redirector || '{}');
+
+ let result = {};
+ for (let key in defaults) {
+ if (typeof data[key] !== 'undefined') {
+ result[key] = data[key];
+ } else {
+ result[key] = defaults[key];
+ }
+ }
+ callback(result);
+ },
+
+ set : function(obj) {
+ let data = JSON.parse(localStorage.redirector || '{}');
+
+ for (let k in obj) {
+ data[k] = obj[k];
+ }
+ localStorage.redirector = JSON.stringify(data);
+ }
+ }
+ };
+
+ chrome.runtime = {
+ sendMessage : function(params, callback) {
+ let data = JSON.parse(localStorage.redirector || '{}');
+ if (params.type === 'get-redirects') {
+ chrome.storage.local.get({redirects:[]}, callback);
+ } else if (params.type === 'toggle-sync') {
+ if (params.isSyncEnabled) {
+ callback({message:'sync-enabled'});
+ } else {
+ callback({message:'sync-disabled'});
+ }
+ }
+ },
+ getManifest : function() {
+ return { version: '0-dev' };
+ }
+ };
+} \ No newline at end of file