Fix local Google Analytics replacement script

Related issue:
- https://github.com/uBlockOrigin/uAssets/pull/4115
This commit is contained in:
Raymond Hill 2020-10-13 18:53:11 -04:00
parent 62c985fe4c
commit 30c38de9bc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 1 deletions

View File

@ -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) {
}
};