mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-04 08:37:11 +02:00
Rework behavior of "Suspend network activity until ..."
The setting will default to the natural capability of the browser: - Checked for Firefox - Unchecked for Chromium-based browsers For Chromium-based browser, if checked, network requests will be redirected to an empty resources instead of blocking the connection. Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/1973 - https://www.reddit.com/r/uBlockOrigin/comments/squo8n/latest_update_blocks_network_connections_at/
This commit is contained in:
parent
3ea92f87a3
commit
2933016d4b
@ -183,7 +183,9 @@ vAPI.Tabs = class extends vAPI.Tabs {
|
||||
|
||||
suspendOneRequest(details) {
|
||||
this.suspendedTabIds.add(details.tabId);
|
||||
return { cancel: true };
|
||||
return {
|
||||
redirectUrl: vAPI.getURL(`web_accessible_resources/empty?secret=${vAPI.warSecret()}`)
|
||||
};
|
||||
}
|
||||
|
||||
unsuspendAllRequests(discard = false) {
|
||||
|
@ -1249,7 +1249,7 @@ vAPI.Net = class {
|
||||
if ( this.suspendDepth !== 0 ) { return; }
|
||||
this.unsuspendAllRequests(discard);
|
||||
}
|
||||
canSuspend() {
|
||||
static canSuspend() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -303,7 +303,7 @@ import {
|
||||
);
|
||||
}
|
||||
}
|
||||
canSuspend() {
|
||||
static canSuspend() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ const userSettingsDefault = {
|
||||
prefetchingDisabled: true,
|
||||
requestLogMaxEntries: 1000,
|
||||
showIconBadge: true,
|
||||
suspendUntilListsAreLoaded: true,
|
||||
suspendUntilListsAreLoaded: vAPI.Net.canSuspend(),
|
||||
tooltipsDisabled: false,
|
||||
webrtcIPAddressHidden: false,
|
||||
};
|
||||
|
@ -201,10 +201,20 @@ const onNetWhitelistReady = function(netWhitelistRaw, adminExtra) {
|
||||
|
||||
const onUserSettingsReady = function(fetched) {
|
||||
// Terminate suspended state?
|
||||
if ( fetched.suspendUntilListsAreLoaded === false ) {
|
||||
const tnow = Date.now() - vAPI.T0;
|
||||
if (
|
||||
vAPI.Net.canSuspend() &&
|
||||
fetched.suspendUntilListsAreLoaded === false
|
||||
) {
|
||||
vAPI.net.unsuspend({ all: true, discard: true });
|
||||
ubolog(`Unsuspend network activity listener`);
|
||||
µb.supportStats.unsuspendAfter = `${Date.now() - vAPI.T0} ms`;
|
||||
ubolog(`Unsuspend network activity listener at ${tnow} ms`);
|
||||
µb.supportStats.unsuspendAfter = `${tnow} ms`;
|
||||
} else if (
|
||||
vAPI.Net.canSuspend() === false &&
|
||||
fetched.suspendUntilListsAreLoaded
|
||||
) {
|
||||
vAPI.net.suspend();
|
||||
ubolog(`Suspend network activity listener at ${tnow} ms`);
|
||||
}
|
||||
|
||||
// `externalLists` will be deprecated in some future, it is kept around
|
||||
|
@ -805,7 +805,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
||||
const onFilterListsReady = function(lists) {
|
||||
this.availableFilterLists = lists;
|
||||
|
||||
if ( vAPI.net.canSuspend() ) {
|
||||
if ( vAPI.Net.canSuspend() ) {
|
||||
vAPI.net.suspend();
|
||||
}
|
||||
redirectEngine.reset();
|
||||
|
@ -1136,7 +1136,9 @@ const webRequest = {
|
||||
|
||||
start: (( ) => {
|
||||
vAPI.net = new vAPI.Net();
|
||||
if ( vAPI.Net.canSuspend() ) {
|
||||
vAPI.net.suspend();
|
||||
}
|
||||
|
||||
return async ( ) => {
|
||||
vAPI.net.setSuspendableListener(onBeforeRequest);
|
||||
|
Loading…
Reference in New Issue
Block a user