autoload.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. try {
  2. if (!isMobileBrowser()) {
  3. $("<link>").attr({href: "/assets/waifu.min.css?v=1.4.2", rel: "stylesheet", type: "text/css"}).appendTo('head');
  4. $('body').append('<div class="waifu"><div class="waifu-tips"></div><canvas id="live2d" class="live2d"/><div class="waifu-tool"><span class="fui-home"/> <span class="fui-chat"/> <span class="fui-eye"/> <span class="fui-user"/> <span class="fui-photo"/> <span class="fui-info-circle"/> <span class="fui-cross"/></div></div>');
  5. $.ajax({url: '/assets/waifu-tips.min.js?v=1.4.2', dataType: "script", cache: true, async: false});
  6. $.ajax({url: '/assets/live2d.min.js?v=1.0.5', dataType: "script", cache: true, async: false});
  7. /* 可直接修改部分参数 */
  8. live2d_settings['hitokotoAPI'] = 'hitokoto.cn'; // 一言 API
  9. live2d_settings['modelId'] = 6; // 默认模型 ID
  10. live2d_settings['modelTexturesId'] = 13; // 默认材质 ID
  11. live2d_settings['modelStorage'] = false; // 不储存模型 ID
  12. live2d_settings['waifuEdgeSide'] = 'right:30';
  13. live2d_settings['homePageUrl'] = '/';
  14. /* 在 initModel 前添加 */
  15. initModel('/assets/waifu-tips.json');
  16. } else {
  17. console.log('手机端不显看板娘~!')
  18. }
  19. } catch (err) {
  20. console.log('[Error] JQuery is not defined.')
  21. }
  22. function isMobileBrowser() {
  23. var sUserAgent = navigator.userAgent.toLowerCase();
  24. var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
  25. var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
  26. var bIsMidp = sUserAgent.match(/midp/i) == "midp";
  27. var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
  28. var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
  29. var bIsAndroid = sUserAgent.match(/android/i) == "android";
  30. var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
  31. var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
  32. if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
  33. return true;
  34. } else
  35. return false;
  36. }