一种通过WebGL检测是否是开发员工具模拟的手机的方法
1 var canvas = document.createElement('canvas'); 2 var gl = canvas.getContext('webgl'); 3 4 var debugInfo = gl.getExtension('WEBGL_debug_renderer_info'); 5 var vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL); 6 var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL); 7 8 console.log(vendor); 9 console.log(renderer);
真机vendor会返回手机信息,例如:
vendor:ARM
renderer:Mali-G610 MC6
而电脑仿真的返回电脑上的设备,例如:
vendor:Google Inc. (NVIDIA)
renderer:ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 Direct3D11 vs_5_0 ps_5_0, D3D11)
标签:canvas,vendor,真机,WEBGL,Javascript,代码运行,renderer,var,gl From: https://www.cnblogs.com/easyc/p/16743863.html