diff --git a/src/web_accessible_resources/google-analytics_analytics.js b/src/web_accessible_resources/google-analytics_analytics.js index 5d6a087c8..87704a282 100644 --- a/src/web_accessible_resources/google-analytics_analytics.js +++ b/src/web_accessible_resources/google-analytics_analytics.js @@ -38,6 +38,7 @@ const w = window; const gaName = w.GoogleAnalyticsObject || 'ga'; const gaQueue = w[gaName]; + // https://github.com/uBlockOrigin/uAssets/pull/4115 const ga = function() { const len = arguments.length; if ( len === 0 ) { return; } @@ -46,6 +47,8 @@ let a = args[len-1]; if ( a instanceof Object && a.hitCallback instanceof Function ) { fn = a.hitCallback; + } else if ( a instanceof Function ) { + fn = ( ) => { a(ga.create()); }; } else { const pos = args.indexOf('hitCallback'); if ( pos !== -1 && args[pos+1] instanceof Function ) { @@ -54,7 +57,7 @@ } if ( fn instanceof Function === false ) { return; } try { - fn(); + setTimeout(fn, 1); } catch (ex) { } };