This commit is contained in:
gorhill 2015-06-01 15:03:22 -04:00
parent ce9781791e
commit 14371b5d92
8 changed files with 71 additions and 7 deletions

View File

@ -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 = {};
/******************************************************************************/

View File

@ -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 --+
// ^ |

View File

@ -171,6 +171,10 @@
"message":"I am an advanced user (<a href='https:\/\/github.com\/gorhill\/uBlock\/wiki\/Advanced-user-features'>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 (<a href='https:\/\/github.com\/gorhill\/uBlock\/wiki\/Experimental-features'>About<\/a>)",
"description":"English: Enable experimental features"

View File

@ -63,6 +63,7 @@ return {
externalLists: defaultExternalLists,
firewallPaneMinimized: true,
parseAllABPHideFilters: true,
prefetchingDisabled: true,
requestLogMaxEntries: 1000,
showIconBadge: true
},

View File

@ -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(){

View File

@ -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);

View File

@ -273,6 +273,11 @@ var matchWhitelistDirective = function(url, hostname, directive) {
break;
case 'experimentalEnabled':
break;
case 'prefetchingDisabled':
vAPI.browserSettings.set({
'prefetching': !value
});
break;
default:
break;
}

View File

@ -17,6 +17,7 @@
<li><input id="color-blind-friendly" type="checkbox"><label data-i18n="settingsColorBlindPrompt" for="color-blind-friendly"></label>
<li><input id="advanced-user-enabled" type="checkbox"><label data-i18n="settingsAdvancedUserPrompt" for="advanced-user-enabled"></label>
<!-- <li><input id="experimental-enabled" type="checkbox" disabled><label data-i18n="settingsExperimentalPrompt" for="experimental-enabled"></label> -->
<li><input id="prefetching-disabled" type="checkbox"><label data-i18n="settingsPrefetchingDisabledPrompt" for="prefetching-disabled"></label>
</ul>
<div id="localData" style="margin: 0 1em;">