autoload

看板娘autoload

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/417049/874533/autoload.js

  1. // 注意:live2d_path 参数应使用绝对路径
  2. const live2d_path = "https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/";
  3. //const live2d_path = "/live2d-widget/";
  4.  
  5. // 封装异步加载资源的方法
  6. function loadExternalResource(url, type) {
  7. return new Promise((resolve, reject) => {
  8. let tag;
  9.  
  10. if (type === "css") {
  11. tag = document.createElement("link");
  12. tag.rel = "stylesheet";
  13. tag.href = url;
  14. }
  15. else if (type === "js") {
  16. tag = document.createElement("script");
  17. tag.src = url;
  18. }
  19. if (tag) {
  20. tag.onload = () => resolve(url);
  21. tag.onerror = () => reject(url);
  22. document.head.appendChild(tag);
  23. }
  24. });
  25. }
  26.  
  27. // 加载 waifu.css live2d.min.js waifu-tips.js
  28. if (screen.width >= 768) {
  29. Promise.all([
  30. loadExternalResource(live2d_path + "waifu.css", "css"),
  31. loadExternalResource(live2d_path + "live2d.min.js", "js"),
  32. loadExternalResource(live2d_path + "waifu-tips.js", "js")
  33. ]).then(() => {
  34. initWidget({
  35. waifuPath: live2d_path + "waifu-tips.json",
  36. apiPath: "https://live2d.fghrsh.net/api/",
  37. //cdnPath: "https://cdn.jsdelivr.net/gh/fghrsh/live2d_api/"
  38. });
  39. });
  40. }
  41. // initWidget 第一个参数为 waifu-tips.json 的路径,第二个参数为 API 地址
  42. // API 后端可自行搭建,参考 https://github.com/fghrsh/live2d_api
  43. // 初始化看板娘会自动加载指定目录下的 waifu-tips.json
  44.  
  45. console.log(`
  46. __,.ヘヽ. / ,ー、
  47. ', !-─‐-i /
  48. /`ー' L//`ヽ、
  49. / /, /| , , ',
  50. / /-‐/ L_ ヽ! i
  51. 7イ`ト 'ァ-ト、!ハ| |
  52. !,/7 '0' ´0iソ| |
  53. |.从" _ ,,,, / |./ |
  54. '| i>.、,,__ _,.イ / .i |
  55. '| | / k_7_/レ'ヽ, ハ. |
  56. | |/i 〈|/ i ,.ヘ | i |
  57. .|/ / i: ヘ! |
  58. kヽ>、ハ _,.ヘ、 /、!
  59. !'〈//`T´', '7'r'
  60. 'ヽL__|___i,___,ンレ|ノ
  61. ト-,/ |___./
  62. 'ー' !_,.:
  63. `);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址