code: function _getDeviceType() {
    let ua = navigator.userAgent;
  
    // Tablets must be checked before phones.
    if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i).test(ua)) {
      return 5; // "tablet"
    }
    if ((/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/).test(ua)) {
      return 4; // "phone"
    }
    // Consider that all other devices are personal computers
    return 2;
  }
docs: Based on https://github.com/ua-parser/uap-cpp/blob/master/UaParser.cpp#L331, with the following updates:
  - replaced `mobile` by `mobi` in the table regexp, so Opera Mobile on phones is not detected as a tablet.