From 6f49e079db0262e669b70f4169924f796ac8db7c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 9 Nov 2021 13:20:49 -0500 Subject: [PATCH] Improve GA's surrogate script Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1807 --- src/web_accessible_resources/google-analytics_ga.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/web_accessible_resources/google-analytics_ga.js b/src/web_accessible_resources/google-analytics_ga.js index 89abcc877..d9ec2e4f4 100644 --- a/src/web_accessible_resources/google-analytics_ga.js +++ b/src/web_accessible_resources/google-analytics_ga.js @@ -38,12 +38,14 @@ if ( typeof a === 'function' ) { a(); return; } - if ( Array.isArray(a) === false ) { - return; - } - // https://twitter.com/catovitch/status/776442930345218048 + if ( Array.isArray(a) === false ) { return; } // https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._link - if ( a[0] === '_link' && typeof a[1] === 'string' ) { + // https://github.com/uBlockOrigin/uBlock-issues/issues/1807 + if ( + typeof a[0] === 'string' && + /(^|\.)_link$/.test(a[0]) && + typeof a[1] === 'string' + ) { window.location.assign(a[1]); } // https://github.com/gorhill/uBlock/issues/2162