mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +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) {
|
suspendOneRequest(details) {
|
||||||
this.suspendedTabIds.add(details.tabId);
|
this.suspendedTabIds.add(details.tabId);
|
||||||
return { cancel: true };
|
return {
|
||||||
|
redirectUrl: vAPI.getURL(`web_accessible_resources/empty?secret=${vAPI.warSecret()}`)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unsuspendAllRequests(discard = false) {
|
unsuspendAllRequests(discard = false) {
|
||||||
|
@ -1249,7 +1249,7 @@ vAPI.Net = class {
|
|||||||
if ( this.suspendDepth !== 0 ) { return; }
|
if ( this.suspendDepth !== 0 ) { return; }
|
||||||
this.unsuspendAllRequests(discard);
|
this.unsuspendAllRequests(discard);
|
||||||
}
|
}
|
||||||
canSuspend() {
|
static canSuspend() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -303,7 +303,7 @@ import {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
canSuspend() {
|
static canSuspend() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -110,7 +110,7 @@ const userSettingsDefault = {
|
|||||||
prefetchingDisabled: true,
|
prefetchingDisabled: true,
|
||||||
requestLogMaxEntries: 1000,
|
requestLogMaxEntries: 1000,
|
||||||
showIconBadge: true,
|
showIconBadge: true,
|
||||||
suspendUntilListsAreLoaded: true,
|
suspendUntilListsAreLoaded: vAPI.Net.canSuspend(),
|
||||||
tooltipsDisabled: false,
|
tooltipsDisabled: false,
|
||||||
webrtcIPAddressHidden: false,
|
webrtcIPAddressHidden: false,
|
||||||
};
|
};
|
||||||
|
@ -201,10 +201,20 @@ const onNetWhitelistReady = function(netWhitelistRaw, adminExtra) {
|
|||||||
|
|
||||||
const onUserSettingsReady = function(fetched) {
|
const onUserSettingsReady = function(fetched) {
|
||||||
// Terminate suspended state?
|
// 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 });
|
vAPI.net.unsuspend({ all: true, discard: true });
|
||||||
ubolog(`Unsuspend network activity listener`);
|
ubolog(`Unsuspend network activity listener at ${tnow} ms`);
|
||||||
µb.supportStats.unsuspendAfter = `${Date.now() - vAPI.T0} 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
|
// `externalLists` will be deprecated in some future, it is kept around
|
||||||
|
@ -805,7 +805,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|||||||
const onFilterListsReady = function(lists) {
|
const onFilterListsReady = function(lists) {
|
||||||
this.availableFilterLists = lists;
|
this.availableFilterLists = lists;
|
||||||
|
|
||||||
if ( vAPI.net.canSuspend() ) {
|
if ( vAPI.Net.canSuspend() ) {
|
||||||
vAPI.net.suspend();
|
vAPI.net.suspend();
|
||||||
}
|
}
|
||||||
redirectEngine.reset();
|
redirectEngine.reset();
|
||||||
|
@ -1136,7 +1136,9 @@ const webRequest = {
|
|||||||
|
|
||||||
start: (( ) => {
|
start: (( ) => {
|
||||||
vAPI.net = new vAPI.Net();
|
vAPI.net = new vAPI.Net();
|
||||||
|
if ( vAPI.Net.canSuspend() ) {
|
||||||
vAPI.net.suspend();
|
vAPI.net.suspend();
|
||||||
|
}
|
||||||
|
|
||||||
return async ( ) => {
|
return async ( ) => {
|
||||||
vAPI.net.setSuspendableListener(onBeforeRequest);
|
vAPI.net.setSuspendableListener(onBeforeRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user