From 40c145d76a238255e3388d743ab2ce2194ee73b4 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 22 Jan 2021 09:37:12 -0500 Subject: [PATCH] Fix handling of cname-aliased URLs in click-to-load widget Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1455 --- src/js/click2load.js | 11 +++++++---- src/js/pagestore.js | 4 +++- src/js/redirect-engine.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/js/click2load.js b/src/js/click2load.js index 6bc2c8c17..baffb0c35 100644 --- a/src/js/click2load.js +++ b/src/js/click2load.js @@ -31,13 +31,16 @@ if ( typeof vAPI !== 'object' ) { return; } const url = new URL(self.location.href); -const frameURL = url.searchParams.get('url'); +const actualURL = url.searchParams.get('url'); +const frameURL = url.searchParams.get('aliasURL') || actualURL; const frameURLElem = document.getElementById('frameURL'); -frameURLElem.children[0].textContent = frameURL; -frameURLElem.children[1].href = frameURL; +frameURLElem.children[0].textContent = actualURL; -document.body.setAttribute('title', frameURL); +frameURLElem.children[1].href = frameURL; +frameURLElem.children[1].title = frameURL; + +document.body.setAttribute('title', actualURL); const onWindowResize = function() { document.body.style.width = `${self.innerWidth}px`; diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 5667878fb..904a099f7 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -596,7 +596,9 @@ const PageStore = class { return 1; } - const cacheableResult = this.cacheableResults.has(fctxt.itype); + const cacheableResult = + this.cacheableResults.has(fctxt.itype) && + fctxt.aliasURL === undefined; if ( cacheableResult ) { const entry = this.netFilteringCache.lookupResult(fctxt); diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index 0466a8ba1..f52b8fb87 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -69,7 +69,7 @@ const redirectableResources = new Map([ alias: 'static.chartbeat.com/chartbeat.js', } ], [ 'click2load.html', { - params: [ 'url' ], + params: [ 'aliasURL', 'url' ], } ], [ 'doubleclick_instream_ad_status.js', { alias: 'doubleclick.net/instream/ad_status.js',