From cab5666e5a5e25fa56c2ee4493a511a817550a71 Mon Sep 17 00:00:00 2001 From: Thomas Rientjes Date: Sun, 24 Jun 2018 23:17:08 +0200 Subject: [PATCH] Refactor existing codebase --- core/constants.js | 1 + core/file-guard.js | 2 +- core/interceptor.js | 4 ++-- core/main.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/constants.js b/core/constants.js index 2681915..6731979 100644 --- a/core/constants.js +++ b/core/constants.js @@ -22,6 +22,7 @@ const Address = { 'ANY_PATH': '/*', 'ANY_PROTOCOL': '*://', 'CHROME_EXTENSION': 'chrome-extension:', + 'DECENTRALEYES': 'decentraleyes.org', 'EXAMPLE': 'example.org', 'HTTP': 'http:', 'HTTPS': 'https:', diff --git a/core/file-guard.js b/core/file-guard.js index 745857c..6f5e696 100644 --- a/core/file-guard.js +++ b/core/file-guard.js @@ -32,7 +32,7 @@ fileGuard._startListening = function () { chrome.webRequest.onBeforeRequest.addListener( fileGuard._verifyRequest, - {'urls': [`${fileGuard.path}/*`]}, + {'urls': [fileGuard.path + Address.ANY_PATH]}, [WebRequest.BLOCKING] ); }; diff --git a/core/interceptor.js b/core/interceptor.js index 2d7be1a..09c409f 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -157,7 +157,7 @@ interceptor._handleStorageChanged = function (changes) { */ interceptor.amountInjected = 0; -interceptor.xhrTestDomain = 'decentraleyes.org'; +interceptor.xhrTestDomain = Address.DECENTRALEYES; interceptor.blockMissing = false; interceptor.relatedSettings = []; @@ -169,7 +169,7 @@ interceptor.relatedSettings.push(Setting.BLOCK_MISSING); chrome.storage.local.get(interceptor.relatedSettings, function (items) { interceptor.amountInjected = items.amountInjected || 0; - interceptor.xhrTestDomain = items.xhrTestDomain || 'decentraleyes.org'; + interceptor.xhrTestDomain = items.xhrTestDomain || Address.DECENTRALEYES; interceptor.blockMissing = items.blockMissing || false; }); diff --git a/core/main.js b/core/main.js index 30454ba..4bb1edd 100644 --- a/core/main.js +++ b/core/main.js @@ -26,7 +26,7 @@ var main = {}; main._initializeOptions = function () { let optionDefaults = { - [Setting.XHR_TEST_DOMAIN]: 'decentraleyes.org', + [Setting.XHR_TEST_DOMAIN]: Address.DECENTRALEYES, [Setting.SHOW_ICON_BADGE]: true, [Setting.BLOCK_MISSING]: false, [Setting.DISABLE_PREFETCH]: true, -- GitLab