From fba680f9abb16ce567c24dd02f5edc53b543b159 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 24 Jan 2022 12:26:24 -0500 Subject: [PATCH] Improve google-analytics shim Related issue: - https://github.com/uBlockOrigin/uAssets/issues/11456 --- .../google-analytics_analytics.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/web_accessible_resources/google-analytics_analytics.js b/src/web_accessible_resources/google-analytics_analytics.js index 15725b28e..6fdf396d6 100644 --- a/src/web_accessible_resources/google-analytics_analytics.js +++ b/src/web_accessible_resources/google-analytics_analytics.js @@ -76,15 +76,22 @@ if ( dl instanceof Object ) { if ( dl.hide instanceof Object && typeof dl.hide.end === 'function' ) { dl.hide.end(); + dl.hide.end = ()=>{}; } if ( typeof dl.push === 'function' ) { const doCallback = function(item) { if ( item instanceof Object === false ) { return; } if ( typeof item.eventCallback !== 'function' ) { return; } setTimeout(item.eventCallback, 1); + item.eventCallback = ()=>{}; }; + dl.push = new Proxy(dl.push, { + apply: function(target, thisArg, args) { + doCallback(args[0]); + return Reflect.apply(target, thisArg, args); + } + }); if ( Array.isArray(dl) ) { - dl.push = item => doCallback(item); const q = dl.slice(); for ( const item of q ) { doCallback(item);