diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 4c48d4ca0..16aa7d3b6 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -42,13 +42,6 @@ var noopFunc = function(){}; /******************************************************************************/ -// https://github.com/gorhill/uMatrix/issues/234 -// https://developer.chrome.com/extensions/privacy#property-network - -chrome.privacy.network.networkPredictionEnabled.set({ value: false }); - -/******************************************************************************/ - vAPI.app = { name: manifest.name, version: manifest.version @@ -68,6 +61,37 @@ vAPI.storage = chrome.storage.local; /******************************************************************************/ +// https://github.com/gorhill/uMatrix/issues/234 +// https://developer.chrome.com/extensions/privacy#property-network + +chrome.privacy.network.networkPredictionEnabled.set({ + value: false, + scope: 'regular' +}); + +vAPI.browserSettings = { + set: function(details) { + for ( var setting in details ) { + if ( details.hasOwnProperty(setting) === false ) { + continue; + } + switch ( setting ) { + case 'prefetching': + chrome.privacy.network.networkPredictionEnabled.set({ + value: !!details[setting], + scope: 'regular' + }); + break; + + default: + break; + } + } + } +}; + +/******************************************************************************/ + vAPI.tabs = {}; /******************************************************************************/ diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index e3b7d1a80..c14d4c3fd 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -97,6 +97,26 @@ window.addEventListener('unload', function() { /******************************************************************************/ +vAPI.browserSettings = { + set: function(details) { + for ( var setting in details ) { + if ( details.hasOwnProperty(setting) === false ) { + continue; + } + switch ( setting ) { + case 'prefetching': + // noop until I find what to use in Firefox + break; + + default: + break; + } + } + } +}; + +/******************************************************************************/ + // API matches that of chrome.storage.local: // https://developer.chrome.com/extensions/storage @@ -404,6 +424,7 @@ vAPI.tabs.registerListeners = function() { /******************************************************************************/ // Firefox: +// https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser // // browser --> ownerDocument --> defaultView --> gBrowser --> browsers --+ // ^ | diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index f361eadf3..522a15cd4 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -171,6 +171,10 @@ "message":"I am an advanced user (Required reading<\/a>)", "description":"English: " }, + "settingsPrefetchingDisabledPrompt":{ + "message":"Disable pre-fetching (to prevent any connection for blocked network requests)", + "description":"English: " + }, "settingsExperimentalPrompt":{ "message":"Enable experimental features (About<\/a>)", "description":"English: Enable experimental features" diff --git a/src/js/background.js b/src/js/background.js index 30539c3bc..bd8329be7 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -63,6 +63,7 @@ return { externalLists: defaultExternalLists, firewallPaneMinimized: true, parseAllABPHideFilters: true, + prefetchingDisabled: true, requestLogMaxEntries: 1000, showIconBadge: true }, diff --git a/src/js/settings.js b/src/js/settings.js index 6a9359dcc..5a2914301 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -186,6 +186,12 @@ var onUserSettingsReceived = function(details) { changeUserSettings('colorBlindFriendly', this.checked); }); + uDom('#prefetching-disabled') + .prop('checked', details.prefetchingDisabled === true) + .on('change', function(){ + changeUserSettings('prefetchingDisabled', this.checked); + }); + uDom('#advanced-user-enabled') .prop('checked', details.advancedUserEnabled === true) .on('change', function(){ diff --git a/src/js/start.js b/src/js/start.js index 913621eee..2a6ecdaba 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -144,6 +144,8 @@ var onUserSettingsReady = function(fetched) { userSettings.experimentalEnabled = false; µb.contextMenu.toggle(userSettings.contextMenuEnabled); + vAPI.browserSettings.set({ 'prefetching': !userSettings.prefetchingDisabled }); + µb.permanentFirewall.fromString(fetched.dynamicFilteringString); µb.sessionFirewall.assign(µb.permanentFirewall); µb.permanentURLFiltering.fromString(fetched.urlFilteringString); diff --git a/src/js/ublock.js b/src/js/ublock.js index e501d707b..39d391950 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -273,6 +273,11 @@ var matchWhitelistDirective = function(url, hostname, directive) { break; case 'experimentalEnabled': break; + case 'prefetchingDisabled': + vAPI.browserSettings.set({ + 'prefetching': !value + }); + break; default: break; } diff --git a/src/settings.html b/src/settings.html index 9c9f6f8a6..644a66283 100644 --- a/src/settings.html +++ b/src/settings.html @@ -17,6 +17,7 @@
  • +