Fix tabs.executeScript() not resolving in due time

Related feedback:
- 6efd8eb84a
This commit is contained in:
Raymond Hill 2023-04-04 14:28:48 -04:00
parent 0f5384ee0d
commit d59eeba8e2
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 5 additions and 0 deletions

View File

@ -609,6 +609,10 @@ const onMessage = function(request, sender, callback) {
});
return;
// https://github.com/gorhill/uBlock/commit/6efd8eb#commitcomment-107523558
// Important: for whatever reason, not using `document_start` causes the
// Promise returned by `tabs.executeScript()` to resolve only when the
// associated tab is closed.
case 'launchReporter': {
const pageStore = µb.pageStoreFromTabId(request.tabId);
if ( pageStore === null ) { break; }
@ -619,6 +623,7 @@ const onMessage = function(request, sender, callback) {
allFrames: true,
file: '/js/scriptlets/cosmetic-report.js',
matchAboutBlank: true,
runAt: 'document_start',
}).then(results => {
const filters = results.reduce((a, v) => {
if ( Array.isArray(v) ) { a.push(...v); }