Skip to content

Commit

Permalink
New version: touch screen details
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Vasilyev committed Jul 13, 2015
1 parent d4ac379 commit a335eb3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ python -m SimpleHTTPServer
17. WebGL fingerprinting
18. Plugins (IE included)
19. Is AdBlock installed or not
20. Has the user tampered with its languages
20. Has the user tampered with its languages
21. Has the user tampered with its screen resolution
22. Has the user tampered with its OS
23. Has the user tampered with its browser

24. Touch screen detection and capabilities


### Many more fingerprinting sources will be implemented, such as
Expand All @@ -121,10 +121,8 @@ python -m SimpleHTTPServer
* Flash linux kernel version,
* Internal HashTable implementation detection
* WebRTC fingerprinting
* Touch screen implementation fingerprinting
* Many more


#### To recompile the FontList.swf file:

* Download Adobe Flex SDK from: http://www.adobe.com/devnet/flex/flex-sdk-download.html
Expand Down
2 changes: 1 addition & 1 deletion dist/fingerprint2.js

Large diffs are not rendered by default.

37 changes: 36 additions & 1 deletion fingerprint2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Fingerprintjs2 0.3.0 - Modern & flexible browser fingerprint library v2
* Fingerprintjs2 0.4.0 - Modern & flexible browser fingerprint library v2
* https://github.com/Valve/fingerprintjs2
* Copyright (c) 2015 Valentin Vasilyev ([email protected])
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
Expand Down Expand Up @@ -101,6 +101,7 @@
keys = this.hasLiedResolutionKey(keys);
keys = this.hasLiedOsKey(keys);
keys = this.hasLiedBrowserKey(keys);
keys = this.touchSupportKey(keys);
var that = this;
this.fontsKey(keys, function(newKeys){
var murmur = that.x64hash128(newKeys.join("~~~"), 31);
Expand Down Expand Up @@ -429,6 +430,12 @@
return "";
}
},
touchSupportKey: function (keys) {
if(!this.options.excludeTouchSupport){
keys.push(this.getTouchSupport());
}
return keys;
},
hasSessionStorage: function () {
try {
return !!window.sessionStorage;
Expand Down Expand Up @@ -468,6 +475,30 @@
return "doNotTrack: unknown";
}
},
// This is a crude and primitive touch screen detection.
// It's not possible to currently reliably detect the availability of a touch screen
// with a JS, without actually subscribing to a touch event.
// http://www.stucox.com/blog/you-cant-detect-a-touchscreen/
// https://github.com/Modernizr/Modernizr/issues/548
// method returns an array of 3 values:
// maxTouchPoints, the success or failure of creating a TouchEvent,
// and the availability of the 'ontouchstart' property
getTouchSupport: function () {
var maxTouchPoints = 0;
var touchEvent = false;
if(typeof navigator.maxTouchPoints !== "undefined") {
maxTouchPoints = navigator.maxTouchPoints;
} else if (typeof navigator.msMaxTouchPoints !== "undefined") {
maxTouchPoints = navigator.msMaxTouchPoints;
}
try {
document.createEvent("TouchEvent");
touchEvent = true;
} catch(_) { /* squelch */ }
var touchStart = "ontouchstart" in window;
return [maxTouchPoints, touchEvent, touchStart];
},
// https://www.browserleaks.com/canvas#how-does-it-work
getCanvasFp: function() {
var result = [];
// Very simple now, need to make it more complex (geo shapes etc)
Expand All @@ -484,6 +515,10 @@
ctx.globalCompositeOperation = "screen";
} catch (e) { /* squelch */ }
result.push("canvas blending:" + ((ctx.globalCompositeOperation === "screen") ? "yes" : "no"));

// detect browser support of canvas winding
// http://blogs.adobe.com/webplatform/2013/01/30/winding-rules-in-canvas/
// https://github.com/Modernizr/Modernizr/blob/master/feature-detects/canvas/winding.js
ctx.rect(0, 0, 10, 10);
ctx.rect(2, 2, 6, 6);
result.push("canvas winding:" + ((ctx.isPointInPath(5, 5, "evenodd") === false) ? "yes" : "no"));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fingerprintjs2",
"version": "0.3.0",
"version": "0.4.0",
"description": "Modern & flexible browser fingerprinting library",
"main": "fingerprint2.js",
"dependencies": {
Expand Down

0 comments on commit a335eb3

Please sign in to comment.