doc: Remove 'dnt_helper.js'
This file is totally useless, because it's an inner-used helper that is for publishment of doc files. PR-URL: https://github.com/nodejs/node/pull/22595 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
59e5a39d30
commit
ec75ba6f0a
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* http://schalkneethling.github.io/blog/2015/11/06/respect-user-choice-do-not-track/
|
|
||||||
* https://github.com/schalkneethling/dnt-helper/blob/master/js/dnt-helper.js
|
|
||||||
*
|
|
||||||
* Returns true or false based on whether doNotTack is enabled. It also takes into account the
|
|
||||||
* anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles
|
|
||||||
* IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec.
|
|
||||||
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details
|
|
||||||
* @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing.
|
|
||||||
* @params {string} [userAgent] - An optional mock userAgent string to ease unit testing.
|
|
||||||
* @returns {boolean} true if enabled else false
|
|
||||||
*/
|
|
||||||
function _dntEnabled(dnt, userAgent) {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// for old version of IE we need to use the msDoNotTrack property of navigator
|
|
||||||
// on newer versions, and newer platforms, this is doNotTrack but, on the window object
|
|
||||||
// Safari also exposes the property on the window object.
|
|
||||||
var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
|
|
||||||
var ua = userAgent || navigator.userAgent;
|
|
||||||
|
|
||||||
// List of Windows versions known to not implement DNT according to the standard.
|
|
||||||
var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3'];
|
|
||||||
|
|
||||||
var fxMatch = ua.match(/Firefox\/(\d+)/);
|
|
||||||
var ieRegEx = /MSIE|Trident/i;
|
|
||||||
var isIE = ieRegEx.test(ua);
|
|
||||||
// Matches from Windows up to the first occurrence of ; un-greedily
|
|
||||||
// http://www.regexr.com/3c2el
|
|
||||||
var platform = ua.match(/Windows.+?(?=;)/g);
|
|
||||||
|
|
||||||
// With old versions of IE, DNT did not exist so we simply return false;
|
|
||||||
if (isIE && typeof Array.prototype.indexOf !== 'function') {
|
|
||||||
return false;
|
|
||||||
} else if (fxMatch && parseInt(fxMatch[1], 10) < 32) {
|
|
||||||
// Can't say for sure if it is 1 or 0, due to Fx bug 887703
|
|
||||||
dntStatus = 'Unspecified';
|
|
||||||
} else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) {
|
|
||||||
// default is on, which does not honor the specification
|
|
||||||
dntStatus = 'Unspecified';
|
|
||||||
} else {
|
|
||||||
// sets dntStatus to Disabled or Enabled based on the value returned by the browser.
|
|
||||||
// If dntStatus is undefined, it will be set to Unspecified
|
|
||||||
dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified';
|
|
||||||
}
|
|
||||||
|
|
||||||
return dntStatus === 'Enabled' ? true : false;
|
|
||||||
}
|
|
@ -79,9 +79,17 @@ function toHTML({ input, content, filename, nodeVersion, analytics }, cb) {
|
|||||||
|
|
||||||
if (analytics) {
|
if (analytics) {
|
||||||
HTML = HTML.replace('<!-- __TRACKING__ -->', `
|
HTML = HTML.replace('<!-- __TRACKING__ -->', `
|
||||||
<script src="assets/dnt_helper.js"></script>
|
<script type="text/javascript">
|
||||||
<script>
|
// In all the browsers we'll get '1' or 'yes' (FF 32 or above) as a string
|
||||||
if (!_dntEnabled()) {
|
// value when enabling 'DO NOT TRACK'.
|
||||||
|
// For more:
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/navigator/doNotTrack
|
||||||
|
function isDoNotTrack() {
|
||||||
|
var isDoNotTrackEnabled = navigator.doNotTrack || window.doNotTrack ||
|
||||||
|
navigator.msDoNotTrack;
|
||||||
|
return isDoNotTrackEnabled === '1' || isDoNotTrackEnabled === 'yes';
|
||||||
|
}
|
||||||
|
if (!isDoNotTrack()) {
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;
|
||||||
i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},
|
i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},
|
||||||
i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];
|
i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user