From 581e9a1c0c96b0bac33c29b20bdd37006d077365 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 14 Jun 2021 07:36:49 -0400 Subject: [PATCH] Also process existing pending callbacks Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1629 --- .../google-analytics_analytics.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/web_accessible_resources/google-analytics_analytics.js b/src/web_accessible_resources/google-analytics_analytics.js index 7ae84ff0f..aa4668bf0 100644 --- a/src/web_accessible_resources/google-analytics_analytics.js +++ b/src/web_accessible_resources/google-analytics_analytics.js @@ -79,11 +79,17 @@ dl.hide.end(); } if ( typeof dl.push === 'function' ) { - dl.push = function(o) { - if ( o instanceof Object && typeof o.eventCallback === 'function' ) { - setTimeout(o.eventCallback, 1); - } + const doCallback = function(item) { + if ( item instanceof Object === false ) { return; } + if ( typeof item.eventCallback !== 'function' ) { return; } + setTimeout(item.eventCallback, 1); }; + if ( Array.isArray(dl) ) { + for ( const item of dl ) { + doCallback(item); + } + } + dl.push = item => doCallback(item); } } // empty ga queue