-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathgoogle-analytics_ga.js
130 lines (124 loc) · 4.7 KB
/
google-analytics_ga.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*******************************************************************************
uBlock Origin - a browser extension to block requests.
Copyright (C) 2019-present Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
Home: https://github.com/gorhill/uBlock
*/
(function() {
'use strict';
const noopfn = function() {
};
//
const Gaq = function() {
};
Gaq.prototype.Na = noopfn;
Gaq.prototype.O = noopfn;
Gaq.prototype.Sa = noopfn;
Gaq.prototype.Ta = noopfn;
Gaq.prototype.Va = noopfn;
Gaq.prototype._createAsyncTracker = noopfn;
Gaq.prototype._getAsyncTracker = noopfn;
Gaq.prototype._getPlugin = noopfn;
Gaq.prototype.push = function(a) {
if ( typeof a === 'function' ) {
a(); return;
}
if ( Array.isArray(a) === false ) { return; }
// https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._link
// https://github.com/uBlockOrigin/uBlock-issues/issues/1807
if (
typeof a[0] === 'string' &&
/(^|\.)_link$/.test(a[0]) &&
typeof a[1] === 'string'
) {
try {
window.location.assign(a[1]);
} catch(ex) {
}
}
// https://github.com/gorhill/uBlock/issues/2162
if ( a[0] === '_set' && a[1] === 'hitCallback' && typeof a[2] === 'function' ) {
a[2]();
}
};
//
const tracker = (function() {
const out = {};
const api = [
'_addIgnoredOrganic _addIgnoredRef _addItem _addOrganic',
'_addTrans _clearIgnoredOrganic _clearIgnoredRef _clearOrganic',
'_cookiePathCopy _deleteCustomVar _getName _setAccount',
'_getAccount _getClientInfo _getDetectFlash _getDetectTitle',
'_getLinkerUrl _getLocalGifPath _getServiceMode _getVersion',
'_getVisitorCustomVar _initData _linkByPost',
'_setAllowAnchor _setAllowHash _setAllowLinker _setCampContentKey',
'_setCampMediumKey _setCampNameKey _setCampNOKey _setCampSourceKey',
'_setCampTermKey _setCampaignCookieTimeout _setCampaignTrack _setClientInfo',
'_setCookiePath _setCookiePersistence _setCookieTimeout _setCustomVar',
'_setDetectFlash _setDetectTitle _setDomainName _setLocalGifPath',
'_setLocalRemoteServerMode _setLocalServerMode _setReferrerOverride _setRemoteServerMode',
'_setSampleRate _setSessionTimeout _setSiteSpeedSampleRate _setSessionCookieTimeout',
'_setVar _setVisitorCookieTimeout _trackEvent _trackPageLoadTime',
'_trackPageview _trackSocial _trackTiming _trackTrans',
'_visitCode'
].join(' ').split(/\s+/);
for ( const method of api ) {
out[method] = noopfn;
}
out._getLinkerUrl = function(a) {
return a;
};
// https://github.com/AdguardTeam/Scriptlets/issues/154
out._link = function(a) {
if ( typeof a !== 'string' ) { return; }
try {
window.location.assign(a);
} catch(ex) {
}
};
return out;
})();
//
const Gat = function() {
};
Gat.prototype._anonymizeIP = noopfn;
Gat.prototype._createTracker = noopfn;
Gat.prototype._forceSSL = noopfn;
Gat.prototype._getPlugin = noopfn;
Gat.prototype._getTracker = function() {
return tracker;
};
Gat.prototype._getTrackerByName = function() {
return tracker;
};
Gat.prototype._getTrackers = noopfn;
Gat.prototype.aa = noopfn;
Gat.prototype.ab = noopfn;
Gat.prototype.hb = noopfn;
Gat.prototype.la = noopfn;
Gat.prototype.oa = noopfn;
Gat.prototype.pa = noopfn;
Gat.prototype.u = noopfn;
const gat = new Gat();
window._gat = gat;
//
const gaq = new Gaq();
(function() {
const aa = window._gaq || [];
if ( Array.isArray(aa) ) {
while ( aa[0] ) {
gaq.push(aa.shift());
}
}
})();
window._gaq = gaq.qf = gaq;
})();