1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-02 00:42:45 +01:00

Add advanced setting to default modify webext flavor

Name: modifyWebextFlavor

Value: A list of space-separated tokens to be added/removed from the
computed default webext flavor.

The primary purpose is to give filter list authors the ability to
test mobile flavor on desktop computers. Though mobile versions of
web pages can be emulated using browser dev tools, it's not
possible to do so for uBO itself.

By using `+mobile` as a value for this setting will force uBO
to act as if it's being executed on a mobile device.

Important: this setting is best used in a dedicated browser
profile, as this affects how filter lists are compiled. So best
to set it in a new browser profile, then force all filter lists
to be recompiled, and use the profile in the future when there
is a need to test the specific webext flavor.
This commit is contained in:
Raymond Hill 2021-09-22 09:37:21 -04:00
parent 33a18c3a1e
commit f49c4e254b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 53 additions and 26 deletions

View File

@ -72,6 +72,7 @@ const hiddenSettingsDefault = {
filterOnHeaders: false,
loggerPopupType: 'popup',
manualUpdateAssetFetchPeriod: 500,
modifyWebextFlavor: 'unset',
popupFontSize: 'unset',
popupPanelDisabledSections: 0,
popupPanelLockedSections: 0,

View File

@ -248,6 +248,57 @@ const onCacheSettingsReady = async function(fetched) {
/******************************************************************************/
const onHiddenSettingsReady = async function() {
// Maybe customize webext flavor
if ( µb.hiddenSettings.modifyWebextFlavor !== 'unset' ) {
const tokens = µb.hiddenSettings.modifyWebextFlavor.split(/\s+/);
for ( const token of tokens ) {
switch ( token[0] ) {
case '+':
vAPI.webextFlavor.soup.add(token.slice(1));
break;
case '-':
vAPI.webextFlavor.soup.delete(token.slice(1));
break;
default:
vAPI.webextFlavor.soup.add(token);
break;
}
}
ubolog(`Override default webext flavor with ${tokens}`);
}
// Maybe override current network listener suspend state
if ( µb.hiddenSettings.suspendTabsUntilReady === 'no' ) {
vAPI.net.unsuspend(true);
} else if ( µb.hiddenSettings.suspendTabsUntilReady === 'yes' ) {
vAPI.net.suspend();
}
// Maybe disable WebAssembly
if ( vAPI.canWASM && µb.hiddenSettings.disableWebAssembly !== true ) {
const wasmModuleFetcher = function(path) {
return fetch(`${path}.wasm`, { mode: 'same-origin' }).then(
WebAssembly.compileStreaming
).catch(reason => {
ubolog(reason);
});
};
staticNetFilteringEngine.enableWASM(wasmModuleFetcher, './js/wasm/').then(result => {
if ( result !== true ) { return; }
ubolog(`WASM modules ready ${Date.now()-vAPI.T0} ms after launch`);
});
}
// Matbe override default cache storage
const cacheBackend = await cacheStorage.select(
µb.hiddenSettings.cacheStorageAPI
);
ubolog(`Backend storage for cache will be ${cacheBackend}`);
};
/******************************************************************************/
const onFirstFetchReady = function(fetched, adminExtra) {
// https://github.com/uBlockOrigin/uBlock-issues/issues/507
// Firefox-specific: somehow `fetched` is undefined under certain
@ -327,34 +378,9 @@ try {
ubolog(`Admin settings ready ${Date.now()-vAPI.T0} ms after launch`);
await µb.loadHiddenSettings();
onHiddenSettingsReady();
ubolog(`Hidden settings ready ${Date.now()-vAPI.T0} ms after launch`);
// Maybe override current network listener suspend state
if ( µb.hiddenSettings.suspendTabsUntilReady === 'no' ) {
vAPI.net.unsuspend(true);
} else if ( µb.hiddenSettings.suspendTabsUntilReady === 'yes' ) {
vAPI.net.suspend();
}
if ( vAPI.canWASM && µb.hiddenSettings.disableWebAssembly !== true ) {
const wasmModuleFetcher = function(path) {
return fetch(`${path}.wasm`, { mode: 'same-origin' }).then(
WebAssembly.compileStreaming
).catch(reason => {
ubolog(reason);
});
};
staticNetFilteringEngine.enableWASM(wasmModuleFetcher, './js/wasm/').then(result => {
if ( result !== true ) { return; }
ubolog(`WASM modules ready ${Date.now()-vAPI.T0} ms after launch`);
});
}
const cacheBackend = await cacheStorage.select(
µb.hiddenSettings.cacheStorageAPI
);
ubolog(`Backend storage for cache will be ${cacheBackend}`);
const adminExtra = await vAPI.adminStorage.get('toAdd');
ubolog(`Extra admin settings ready ${Date.now()-vAPI.T0} ms after launch`);