From b7510eee6190639438314820f35b1b490430afc1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 15 Jul 2025 12:10:10 -0400 Subject: [PATCH] Improve reporting of `reason` option in strict-blocked pages Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/1195#issuecomment-3072981070 --- src/css/document-blocked.css | 3 ++- src/js/pagestore.js | 12 +++++------- src/js/traffic.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/css/document-blocked.css b/src/css/document-blocked.css index 169acf9d6..96eb4a783 100644 --- a/src/css/document-blocked.css +++ b/src/css/document-blocked.css @@ -73,7 +73,7 @@ a { } #theURL > p > span:first-of-type { display: block; - max-height: 6lh; + max-height: 3lh; overflow-y: auto; } :root.mobile #theURL > p > span:first-of-type { @@ -146,6 +146,7 @@ details > *:not(summary) { #urlskip a { display: block; + max-height: 3lh; overflow-y: auto; word-break: break-all; } diff --git a/src/js/pagestore.js b/src/js/pagestore.js index cfb997475..db308ddf4 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -976,14 +976,12 @@ const PageStore = class { skipMainDocument(fctxt, blocked) { const directives = staticNetFilteringEngine.urlSkip(fctxt, blocked); if ( directives === undefined ) { return; } - if ( logger.enabled !== true ) { return; } fctxt.pushFilters(directives.map(a => a.logData())); - if ( fctxt.redirectURL !== undefined ) { - fctxt.pushFilter({ - source: 'redirect', - raw: fctxt.redirectURL - }); - } + if ( fctxt.redirectURL === undefined ) { return; } + fctxt.pushFilter({ + source: 'redirect', + raw: fctxt.redirectURL + }); } filterCSPReport(fctxt) { diff --git a/src/js/traffic.js b/src/js/traffic.js index 478487e77..a06b7be89 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -221,9 +221,16 @@ const onBeforeRootFrameRequest = function(fctxt) { // Blocked + let reason = logData.reason; + // Find out the URL navigated to should the document not be strict-blocked pageStore.skipMainDocument(fctxt, false); + if ( reason === undefined && Array.isArray(fctxt.filter) ) { + const filter = fctxt.filter.find(a => a.reason !== undefined); + reason = filter?.reason; + } + const query = { url: requestURL, dn: fctxt.getDomain() || requestHostname, @@ -231,8 +238,8 @@ const onBeforeRootFrameRequest = function(fctxt) { hn: requestHostname, to: fctxt.redirectURL || '', }; - if ( logData.reason ) { - query.reason = logData.reason; + if ( reason ) { + query.reason = reason; } vAPI.tabs.replace(