www-google-analytics-com_ga.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. (function () {
  2. 'use strict';
  3. const noopfn = function () {
  4. };
  5. //
  6. const Gaq = function () {
  7. };
  8. Gaq.prototype.Na = noopfn;
  9. Gaq.prototype.O = noopfn;
  10. Gaq.prototype.Sa = noopfn;
  11. Gaq.prototype.Ta = noopfn;
  12. Gaq.prototype.Va = noopfn;
  13. Gaq.prototype._createAsyncTracker = noopfn;
  14. Gaq.prototype._getAsyncTracker = noopfn;
  15. Gaq.prototype._getPlugin = noopfn;
  16. Gaq.prototype.push = function (a) {
  17. if (typeof a === 'function') {
  18. a(); return;
  19. }
  20. if (Array.isArray(a) === false) { return; }
  21. // https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._link
  22. if (
  23. typeof a[0] === 'string'
  24. && /(^|\.)_link$/.test(a[0])
  25. && typeof a[1] === 'string'
  26. ) {
  27. try {
  28. window.location.assign(a[1]);
  29. } catch (ex) {
  30. }
  31. }
  32. if (a[0] === '_set' && a[1] === 'hitCallback' && typeof a[2] === 'function') {
  33. a[2]();
  34. }
  35. };
  36. //
  37. const tracker = (function () {
  38. const out = {};
  39. const api = [
  40. '_addIgnoredOrganic _addIgnoredRef _addItem _addOrganic',
  41. '_addTrans _clearIgnoredOrganic _clearIgnoredRef _clearOrganic',
  42. '_cookiePathCopy _deleteCustomVar _getName _setAccount',
  43. '_getAccount _getClientInfo _getDetectFlash _getDetectTitle',
  44. '_getLinkerUrl _getLocalGifPath _getServiceMode _getVersion',
  45. '_getVisitorCustomVar _initData _linkByPost',
  46. '_setAllowAnchor _setAllowHash _setAllowLinker _setCampContentKey',
  47. '_setCampMediumKey _setCampNameKey _setCampNOKey _setCampSourceKey',
  48. '_setCampTermKey _setCampaignCookieTimeout _setCampaignTrack _setClientInfo',
  49. '_setCookiePath _setCookiePersistence _setCookieTimeout _setCustomVar',
  50. '_setDetectFlash _setDetectTitle _setDomainName _setLocalGifPath',
  51. '_setLocalRemoteServerMode _setLocalServerMode _setReferrerOverride _setRemoteServerMode',
  52. '_setSampleRate _setSessionTimeout _setSiteSpeedSampleRate _setSessionCookieTimeout',
  53. '_setVar _setVisitorCookieTimeout _trackEvent _trackPageLoadTime',
  54. '_trackPageview _trackSocial _trackTiming _trackTrans',
  55. '_visitCode'
  56. ].join(' ').split(/\s+/);
  57. for (const method of api) {
  58. out[method] = noopfn;
  59. }
  60. out._getLinkerUrl = function (a) {
  61. return a;
  62. };
  63. // https://github.com/AdguardTeam/Scriptlets/issues/154
  64. out._link = function (a) {
  65. if (typeof a !== 'string') { return; }
  66. try {
  67. window.location.assign(a);
  68. } catch (ex) {
  69. }
  70. };
  71. return out;
  72. }());
  73. //
  74. const Gat = function () {
  75. };
  76. Gat.prototype._anonymizeIP = noopfn;
  77. Gat.prototype._createTracker = noopfn;
  78. Gat.prototype._forceSSL = noopfn;
  79. Gat.prototype._getPlugin = noopfn;
  80. Gat.prototype._getTracker = function () {
  81. return tracker;
  82. };
  83. Gat.prototype._getTrackerByName = function () {
  84. return tracker;
  85. };
  86. Gat.prototype._getTrackers = noopfn;
  87. Gat.prototype.aa = noopfn;
  88. Gat.prototype.ab = noopfn;
  89. Gat.prototype.hb = noopfn;
  90. Gat.prototype.la = noopfn;
  91. Gat.prototype.oa = noopfn;
  92. Gat.prototype.pa = noopfn;
  93. Gat.prototype.u = noopfn;
  94. const gat = new Gat();
  95. window._gat = gat;
  96. //
  97. const gaq = new Gaq();
  98. (function () {
  99. const aa = window._gaq || [];
  100. if (Array.isArray(aa)) {
  101. while (aa[0]) {
  102. gaq.push(aa.shift());
  103. }
  104. }
  105. }());
  106. gaq.qf = gaq;
  107. window._gaq = gaq;
  108. }());