javascript [js-browser fingerprintjs2] #js #browser

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript [js-browser fingerprintjs2] #js #browser相关的知识,希望对你有一定的参考价值。

/*
https://github.com/Valve/fingerprintjs2
<script src="//cdn.jsdelivr.net/npm/fingerprintjs2@<VERSION>/dist/fingerprint2.min.js"></script>
*/
//can pass an object with options: https://github.com/Valve/fingerprintjs2/wiki/List-of-options
var options = {
  swfPath: '/assets/FontList.swf', excludeUserAgent: true,
  userDefinedFonts: ["Nimbus Mono", "Junicode", "Presto"],	//increase the entropy of the font fingerprint
  //Function that is called with each component value that may be used to modify component values before computing the fingerprint
  preprocessor: function(key, value) {
    //ie: strip browser version from user agent
    if (key == "user_agent") {
      var parser = new UAParser(value); // https://github.com/faisalman/ua-parser-js
      var userAgentMinusVersion = parser.getOS().name + ' ' + parser.getBrowser().name
      return userAgentMinusVersion
    } else {
      return value
    }
  }
}

new Fingerprint2(options).get(function(result, components) {
  console.log(result) // a hash, representing your device fingerprint
  console.log(components) // an array of FP components
});

以上是关于javascript [js-browser fingerprintjs2] #js #browser的主要内容,如果未能解决你的问题,请参考以下文章

[javascript svg fill stroke stroke-width x1 y1 x2 y2 line stroke-opacity fill-opacity 属性讲解] svg fi

JavaScript函数组成3个函数

用javascript格式化(人性化)文件字节大小表示

如何将 javascript 对象转置为键/值数组

使用 JavaScript 多步骤表单进行联系表单验证

JavaScript XMLHttpRequest 同源限制及CORS杂谈