diff --git a/.eslintrc b/.eslintrc index a1b6ff0b1d47d4570a7951c7ac666cf84e67ff9d..de12effda82b6c0b7f5877f703e1d19cada4027c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -21,6 +21,7 @@ "shorthands": true, "stateManager": true, "WebRequest": true, + "WebRequestType": true, "Whitelist": true, "wrappers": true }, diff --git a/core/constants.js b/core/constants.js index f476a93cbb9f69d0fe5a1ffd35932486459ce8d8..f4edd000f2379d49aeba18e18aae3ff415eff35d 100644 --- a/core/constants.js +++ b/core/constants.js @@ -47,7 +47,8 @@ const Setting = { 'SHOW_ICON_BADGE': 'showIconBadge', 'SHOW_RELEASE_NOTES': 'showReleaseNotes', 'STRIP_METADATA': 'stripMetadata', - 'WHITELISTED_DOMAINS': 'whitelistedDomains' + 'WHITELISTED_DOMAINS': 'whitelistedDomains', + 'XHR_TEST_DOMAIN': 'xhrTestDomain' }; const WebRequest = { @@ -56,6 +57,10 @@ const WebRequest = { 'HEADERS': 'requestHeaders' }; +const WebRequestType = { + 'XHR': 'xmlhttprequest' +}; + const Whitelist = { 'TRIM_EXPRESSION': /^;+|;+$/g, 'VALUE_SEPARATOR': ';' diff --git a/core/interceptor.js b/core/interceptor.js index 1e57da60db951c79129fd611d235f9787443cedf..561a1013d6beb354fff3602cc21df0eb405c9569 100644 --- a/core/interceptor.js +++ b/core/interceptor.js @@ -42,6 +42,13 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) { tabDomain = Address.EXAMPLE; } + if (requestDetails.type === WebRequestType.XHR) { + + if (tabDomain !== interceptor.xhrTestDomain) { + return interceptor._handleMissingCandidate(requestDetails.url); + } + } + // Temporary list of undetectable tainted domains. let undetectableTaintedDomains = { '10fastfingers.com': true, @@ -125,6 +132,10 @@ interceptor._handleMissingCandidate = function (requestUrl) { interceptor._handleStorageChanged = function (changes) { + if (Setting.XHR_TEST_DOMAIN in changes) { + interceptor.xhrTestDomain = changes.xhrTestDomain.newValue; + } + if (Setting.BLOCK_MISSING in changes) { interceptor.blockMissing = changes.blockMissing.newValue; } @@ -137,9 +148,17 @@ interceptor._handleStorageChanged = function (changes) { interceptor.amountInjected = 0; interceptor.blockMissing = false; -chrome.storage.local.get([Setting.AMOUNT_INJECTED, Setting.BLOCK_MISSING], function (items) { +interceptor.relatedSettings = [ + + Setting.AMOUNT_INJECTED, + Setting.XHR_TEST_DOMAIN, + Setting.BLOCK_MISSING +]; + +chrome.storage.local.get(interceptor.relatedSettings, function (items) { interceptor.amountInjected = items.amountInjected || 0; + interceptor.xhrTestDomain = items.xhrTestDomain || 'decentraleyes.org'; interceptor.blockMissing = items.blockMissing || false; }); diff --git a/core/main.js b/core/main.js index 6c5557c24713bba67d8f0475d454edd4d88c212e..30454ba17b898b05312963ed7c13039bf7b2b7ee 100644 --- a/core/main.js +++ b/core/main.js @@ -26,6 +26,7 @@ var main = {}; main._initializeOptions = function () { let optionDefaults = { + [Setting.XHR_TEST_DOMAIN]: 'decentraleyes.org', [Setting.SHOW_ICON_BADGE]: true, [Setting.BLOCK_MISSING]: false, [Setting.DISABLE_PREFETCH]: true,