Fix calls to tab.removeCSS()

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1375
This commit is contained in:
Raymond Hill 2020-12-02 10:46:59 -05:00
parent 4d68d7f586
commit f8b15ed6cc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 21 additions and 14 deletions

View File

@ -1024,23 +1024,30 @@ vAPI.messaging = {
} }
case 'userCSS': case 'userCSS':
if ( tabId === undefined ) { break; } if ( tabId === undefined ) { break; }
const promises = [];
if ( msg.add ) {
const details = { const details = {
code: undefined, code: undefined,
frameId: portDetails.frameId, frameId: portDetails.frameId,
matchAboutBlank: true matchAboutBlank: true,
runAt: 'document_start',
}; };
if ( msg.add ) {
details.runAt = 'document_start';
}
const promises = [];
for ( const cssText of msg.add ) { for ( const cssText of msg.add ) {
details.code = cssText; details.code = cssText;
promises.push(vAPI.tabs.insertCSS(tabId, details)); promises.push(vAPI.tabs.insertCSS(tabId, details));
} }
}
if ( msg.remove ) {
const details = {
code: undefined,
frameId: portDetails.frameId,
matchAboutBlank: true,
};
for ( const cssText of msg.remove ) { for ( const cssText of msg.remove ) {
details.code = cssText; details.code = cssText;
promises.push(vAPI.tabs.removeCSS(tabId, details)); promises.push(vAPI.tabs.removeCSS(tabId, details));
} }
}
Promise.all(promises).then(( ) => { Promise.all(promises).then(( ) => {
callback(); callback();
}); });