1/* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5// create namespace 6if (typeof Mozilla === 'undefined') { 7 var Mozilla = {}; 8} 9 10/** 11 * Returns true or false based on whether doNotTrack is enabled. It also takes into account the 12 * anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles 13 * IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec. 14 * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details 15 * @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing. 16 * @params {string} [ua] - An optional mock userAgent string to ease unit testing. 17 * @returns {boolean} true if enabled else false 18 */ 19Mozilla.dntEnabled = function(dnt, ua) { 20 'use strict'; 21 22 // for old version of IE we need to use the msDoNotTrack property of navigator 23 // on newer versions, and newer platforms, this is doNotTrack but, on the window object 24 // Safari also exposes the property on the window object. 25 var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack; 26 var userAgent = ua || navigator.userAgent; 27 28 // List of Windows versions known to not implement DNT according to the standard. 29 var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3']; 30 31 var fxMatch = userAgent.match(/Firefox\/(\d+)/); 32 var ieRegEx = /MSIE|Trident/i; 33 var isIE = ieRegEx.test(userAgent); 34 // Matches from Windows up to the first occurance of ; un-greedily 35 // http://www.regexr.com/3c2el 36 var platform = userAgent.match(/Windows.+?(?=;)/g); 37 38 // With old versions of IE, DNT did not exist so we simply return false; 39 if (isIE && typeof Array.prototype.indexOf !== 'function') { 40 return false; 41 } else if (fxMatch && parseInt(fxMatch[1], 10) < 32) { 42 // Can't say for sure if it is 1 or 0, due to Fx bug 887703 43 dntStatus = 'Unspecified'; 44 } else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) { 45 // default is on, which does not honor the specification 46 dntStatus = 'Unspecified'; 47 } else { 48 // sets dntStatus to Disabled or Enabled based on the value returned by the browser. 49 // If dntStatus is undefined, it will be set to Unspecified 50 dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified'; 51 } 52 53 return dntStatus === 'Enabled' ? true : false; 54}; 55 56(function() { 57 'use strict'; 58 59 var blogName = document.querySelector('meta[name="blog-name"][content]').content; 60 61 // If doNotTrack is not enabled, it is ok to add Google Analytics 62 // @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details 63 if (typeof Mozilla.dntEnabled === 'function' && !Mozilla.dntEnabled() && blogName) { 64 var measurementId = 'G-X4N05QV93S'; 65 66 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 67 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 68 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 69 'https://www.googletagmanager.com/gtag/js?id='+i+dl;f.parentNode.insertBefore(j,f); 70 })(window,document,'script','dataLayer',measurementId); 71 72 window.dataLayer = window.dataLayer || []; 73 window.gtag = function(){dataLayer.push(arguments);} 74 gtag('js', new Date()); 75 76 gtag('config', measurementId); 77 } 78})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.