Skip to content

Instantly share code, notes, and snippets.

@pi0
Last active November 10, 2020 12:45
Show Gist options
  • Save pi0/a76fd97c4ea259c89f728a4a8ebca741 to your computer and use it in GitHub Desktop.
Save pi0/a76fd97c4ea259c89f728a4a8ebca741 to your computer and use it in GitHub Desktop.
doNotTrack polyFill

Tiny (230 char) Polyfill for window.doNotTrack. Checks for:

  • window.doNotTrack == 1
  • navigator.doNotTrack == 'yes'
  • navigator.doNotTrack == 1
  • navigator.msDoNotTrack == 1'
  • window.external.msTrackingProtectionEnabled()

And sets value to either 1 (do not track) or 0 (track)

Read more: https://allaboutdnt.com/

(function(w,n,d,m,e,p){w[d]=(w[d]==1||n[d]=='yes'||n[d]==1||n[m]==1||(w[e]&&w[e][p]&&w[e][p]()))?1:0})(window,navigator,'doNotTrack','msDoNotTrack','external','msTrackingProtectionEnabled')
@pi0
Copy link
Author

pi0 commented Nov 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment