aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/js/tab.js39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/js/tab.js b/src/js/tab.js
index 9a90c2b..a3b1d4a 100644
--- a/src/js/tab.js
+++ b/src/js/tab.js
@@ -496,29 +496,56 @@ vAPI.tabs.onPopup = function(details) {
requestType: 'popup'
};
- var pageStore = µb.pageStoreFromTabId(details.openerTabId);
var result = '';
+ var loggerEnabled = µb.logger.isEnabled();
// Check user switch first
if ( µb.hnSwitches.evaluateZ('no-popups', openerHostname) ) {
result = 'ub:no-popups: ' + µb.hnSwitches.z + ' true';
}
+ // https://github.com/gorhill/uBlock/issues/581
+ // Take into account popup-specific rules in dynamic URL filtering, OR
+ // generic allow rules.
+ if ( result === '' ) {
+ µb.sessionURLFiltering.evaluateZ(openerHostname, targetURL, 'popup');
+ if (
+ µb.sessionURLFiltering.r === 1 && µb.sessionURLFiltering.type === 'popup' ||
+ µb.sessionURLFiltering.r === 2
+ ) {
+ result = µb.sessionURLFiltering.toFilterString();
+ }
+ }
+
+ // https://github.com/gorhill/uBlock/issues/581
+ // Take into account `allow` rules in dynamic filtering: `block` rules
+ // are ignored, as block rules are not meant to block specific types
+ // like `popup` (just like with static filters).
+ if ( result === '' ) {
+ µb.sessionFirewall.evaluateCellZY(openerHostname, context.requestHostname, 'popup');
+ if ( µb.sessionFirewall.r === 2 ) {
+ result = µb.sessionFirewall.toFilterString();
+ }
+ }
+
// https://github.com/chrisaljoudi/uBlock/issues/323
// https://github.com/chrisaljoudi/uBlock/issues/1142
// Don't block if uBlock is turned off in popup's context
- // https://github.com/gorhill/uBlock/issues/581
- // Take into account dynamic filtering.
- if ( result === '' && pageStore && µb.getNetFilteringSwitch(targetURL) ) {
- result = pageStore.filterRequestNoCache(context);
+ if (
+ result === '' &&
+ µb.getNetFilteringSwitch(targetURL) &&
+ µb.staticNetFilteringEngine.matchStringExactType(context, targetURL, 'popup') !== undefined
+ ) {
+ result = µb.staticNetFilteringEngine.toResultString(loggerEnabled);
}
// https://github.com/chrisaljoudi/uBlock/issues/91
+ var pageStore = µb.pageStoreFromTabId(details.openerTabId);
if ( pageStore ) {
pageStore.logRequest(context, result);
}
- if ( µb.logger.isEnabled() ) {
+ if ( loggerEnabled ) {
µb.logger.writeOne(
details.openerTabId,
'net',