├── assets ├── flat-ui-icons-regular.eot ├── flat-ui-icons-regular.ttf ├── flat-ui-icons-regular.woff ├── autoload.js ├── waifu-tips.json ├── waifu.css ├── waifu-tips.js └── flat-ui-icons-regular.svg ├── demo2-autoload.html ├── demo1-default.html ├── README.md ├── LICENSE └── demo3-waifu-tips.html /assets/flat-ui-icons-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fghrsh/live2d_demo/HEAD/assets/flat-ui-icons-regular.eot -------------------------------------------------------------------------------- /assets/flat-ui-icons-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fghrsh/live2d_demo/HEAD/assets/flat-ui-icons-regular.ttf -------------------------------------------------------------------------------- /assets/flat-ui-icons-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fghrsh/live2d_demo/HEAD/assets/flat-ui-icons-regular.woff -------------------------------------------------------------------------------- /assets/autoload.js: -------------------------------------------------------------------------------- 1 | try { 2 | $("").attr({href: "assets/waifu.min.css?v=1.4.2", rel: "stylesheet", type: "text/css"}).appendTo('head'); 3 | $('body').append('
'); 4 | $.ajax({url: "assets/waifu-tips.min.js?v=1.4.2", dataType:"script", cache: true, success: function() { 5 | $.ajax({url: "assets/live2d.min.js?v=1.0.5", dataType:"script", cache: true, success: function() { 6 | /* 可直接修改部分参数 */ 7 | live2d_settings['hitokotoAPI'] = "hitokoto.cn"; // 一言 API 8 | live2d_settings['modelId'] = 5; // 默认模型 ID 9 | live2d_settings['modelTexturesId'] = 1; // 默认材质 ID 10 | live2d_settings['modelStorage'] = false; // 不储存模型 ID 11 | /* 在 initModel 前添加 */ 12 | initModel("assets/waifu-tips.json"); 13 | }}); 14 | }}); 15 | } catch(err) { console.log("[Error] JQuery is not defined.") } 16 | -------------------------------------------------------------------------------- /demo2-autoload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Live2D 看板娘 v1.4 / Demo 2 6 | 7 | 8 |

Live2D 看板娘 v1.4 / Demo 2

9 |

- 自动加载 autoload.js (一般网站引用推荐)

10 | 15 | 16 |
17 | <!DOCTYPE html>
18 | <html xmlns="http://www.w3.org/1999/xhtml">
19 | <head>
20 |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
21 |     <title>Live2D 看板娘 v1.4 / Demo 2</title>
22 | </head>
23 | <body style="font-family: 'Microsoft YaHei';">
24 |     <h2><a href="https://www.fghrsh.net/post/123.html" style="color: #38A3DB; text-decoration: none;">Live2D 看板娘 v1.4</a> / Demo 2</h2>
25 |     <h3> - 自动加载 autoload.js <span style="font-size: 12px;color: #666">(一般网站引用推荐)</span></h3>
26 |     <ul>
27 |         <li><a href="demo1-default.html" style="color: #38A3DB; text-decoration: none;" title="常规博客引用推荐">Demo 1 - 常规引用</a></li>
28 |         <li><span title="一般网站引用推荐">Demo 2 (当前面页)</span></li>
29 |         <li><a href="demo3-waifu-tips.html" style="color: #38A3DB; text-decoration: none;" title="博客园等网站引用推荐">Demo 3 - 内置 waifu-tips.json</a></li>
30 |     </ul>
31 |     
32 |     <!-- waifu-tips.js 依赖 JQuery 库 -->
33 |     <script src="assets/jquery.min.js?v=3.3.1"></script>
34 |     
35 |     <!-- 实现拖动效果,需引入 JQuery UI -->
36 |     <script src="assets/jquery-ui.min.js?v=1.12.1"></script>
37 |     
38 |     <!-- 使用 aotuload.js 引入看板娘 -->
39 |     <script src="assets/autoload.js?v=1.4.2"></script>
40 | </body>
41 | </html>
42 | 
43 | # autoload.js
44 | try {
45 |     $("<link>").attr({href: "assets/waifu.min.css?v=1.4.2", rel: "stylesheet", type: "text/css"}).appendTo('head');
46 |     $('body').append('<div class="waifu"><div class="waifu-tips"></div><canvas id="live2d" class="live2d"></canvas><div class="waifu-tool"><span class="fui-home"></span> <span class="fui-chat"></span> <span class="fui-eye"></span> <span class="fui-user"></span> <span class="fui-photo"></span> <span class="fui-info-circle"></span> <span class="fui-cross"></span></div></div>');
47 |     $.ajax({url: 'assets/waifu-tips.min.js?v=1.4.2',dataType:"script", cache: true, async: false});
48 |     $.ajax({url: 'assets/live2d.min.js?v=1.0.5',dataType:"script", cache: true, async: false});
49 |     /* 可直接修改部分参数 */
50 |     live2d_settings['hitokotoAPI'] = 'hitokoto.cn';  // 一言 API
51 |     live2d_settings['modelId'] = 5;                  // 默认模型 ID
52 |     live2d_settings['modelTexturesId'] = 1;          // 默认材质 ID
53 |     live2d_settings['modelStorage'] = false;         // 不储存模型 ID
54 |     /* 在 initModel 前添加 */
55 |     initModel('assets/waifu-tips.json');
56 | } catch(err) { console.log('[Error] JQuery is not defined.') }
57 |     
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /assets/waifu-tips.json: -------------------------------------------------------------------------------- 1 | { 2 | "waifu": { 3 | "console_open_msg": ["哈哈,你打开了控制台,是想要看看我的秘密吗?"], 4 | "copy_message": ["你都复制了些什么呀,转载要记得加上出处哦"], 5 | "screenshot_message": ["照好了嘛,是不是很可爱呢?"], 6 | "hidden_message": ["我们还能再见面的吧…"], 7 | "load_rand_textures": ["我还没有其他衣服呢", "我的新衣服好看嘛"], 8 | "hour_tips": { 9 | "t5-7": ["早上好!一日之计在于晨,美好的一天就要开始了"], 10 | "t7-11": ["上午好!工作顺利嘛,不要久坐,多起来走动走动哦!"], 11 | "t11-14": ["中午了,工作了一个上午,现在是午餐时间!"], 12 | "t14-17": ["午后很容易犯困呢,今天的运动目标完成了吗?"], 13 | "t17-19": ["傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~"], 14 | "t19-21": ["晚上好,今天过得怎么样?"], 15 | "t21-23": ["已经这么晚了呀,早点休息吧,晚安~"], 16 | "t23-5": ["你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"], 17 | "default": ["嗨~ 快来逗我玩吧!"] 18 | }, 19 | "referrer_message": { 20 | "localhost": ["欢迎阅读『", "』", " - "], 21 | "baidu": ["Hello! 来自 百度搜索 的朋友
你是搜索 ", " 找到的我吗?"], 22 | "so": ["Hello! 来自 360搜索 的朋友
你是搜索 ", " 找到的我吗?"], 23 | "google": ["Hello! 来自 谷歌搜索 的朋友
欢迎阅读『", "』", " - "], 24 | "default": ["Hello! 来自 ", " 的朋友"], 25 | "none": ["欢迎阅读『", "』", " - "] 26 | }, 27 | "referrer_hostname": { 28 | "example.com": ["示例网站"], 29 | "www.fghrsh.net": ["FGHRSH 的博客"] 30 | }, 31 | "model_message": { 32 | "1": ["来自 Potion Maker 的 Pio 酱 ~"], 33 | "2": ["来自 Potion Maker 的 Tia 酱 ~"] 34 | }, 35 | "hitokoto_api_message": { 36 | "lwl12.com": ["这句一言来自 『{source}』", ",是 {creator} 投稿的", "。"], 37 | "fghrsh.net": ["这句一言出处是 『{source}』,是 FGHRSH 在 {date} 收藏的!"], 38 | "jinrishici.com": ["这句诗词出自 《{title}》,是 {dynasty}诗人 {author} 创作的!"], 39 | "hitokoto.cn": ["这句一言来自 『{source}』,是 {creator} 在 hitokoto.cn 投稿的。"] 40 | } 41 | }, 42 | "mouseover": [ 43 | { "selector": ".container a[href^='http']", "text": ["要看看 {text} 么?"] }, 44 | { "selector": ".fui-home", "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦"] }, 45 | { "selector": ".fui-chat", "text": ["一言一语,一颦一笑。一字一句,一颗赛艇。"] }, 46 | { "selector": ".fui-eye", "text": ["嗯··· 要切换 看板娘 吗?"] }, 47 | { "selector": ".fui-user", "text": ["喜欢换装 Play 吗?"] }, 48 | { "selector": ".fui-photo", "text": ["要拍张纪念照片吗?"] }, 49 | { "selector": ".fui-info-circle", "text": ["这里有关于我的信息呢"] }, 50 | { "selector": ".fui-cross", "text": ["你不喜欢我了吗..."] }, 51 | { "selector": "#tor_show", "text": ["翻页比较麻烦吗,点击可以显示这篇文章的目录呢"] }, 52 | { "selector": "#comment_go", "text": ["想要去评论些什么吗?"] }, 53 | { "selector": "#night_mode", "text": ["深夜时要爱护眼睛呀"] }, 54 | { "selector": "#qrcode", "text": ["手机扫一下就能继续看,很方便呢"] }, 55 | { "selector": ".comment_reply", "text": ["要吐槽些什么呢"] }, 56 | { "selector": "#back-to-top", "text": ["回到开始的地方吧"] }, 57 | { "selector": "#author", "text": ["该怎么称呼你呢"] }, 58 | { "selector": "#mail", "text": ["留下你的邮箱,不然就是无头像人士了"] }, 59 | { "selector": "#url", "text": ["你的家在哪里呢,好让我去参观参观"] }, 60 | { "selector": "#textarea", "text": ["认真填写哦,垃圾评论是禁止事项"] }, 61 | { "selector": ".OwO-logo", "text": ["要插入一个表情吗"] }, 62 | { "selector": "#csubmit", "text": ["要[提交]^(Commit)了吗,首次评论需要审核,请耐心等待~"] }, 63 | { "selector": ".ImageBox", "text": ["点击图片可以放大呢"] }, 64 | { "selector": "input[name=s]", "text": ["找不到想看的内容?搜索看看吧"] }, 65 | { "selector": ".previous", "text": ["去上一页看看吧"] }, 66 | { "selector": ".next", "text": ["去下一页看看吧"] }, 67 | { "selector": ".dropdown-toggle", "text": ["这里是菜单"] }, 68 | { "selector": "c-player a.play-icon", "text": ["想要听点音乐吗"] }, 69 | { "selector": "c-player div.time", "text": ["在这里可以调整播放进度呢"] }, 70 | { "selector": "c-player div.volume", "text": ["在这里可以调整音量呢"] }, 71 | { "selector": "c-player div.list-button", "text": ["播放列表里都有什么呢"] }, 72 | { "selector": "c-player div.lyric-button", "text": ["有歌词的话就能跟着一起唱呢"] }, 73 | { "selector": ".waifu #live2d", "text": ["干嘛呢你,快把手拿开", "鼠…鼠标放错地方了!"] } 74 | ], 75 | "click": [ 76 | { 77 | "selector": ".waifu #live2d", 78 | "text": [ 79 | "是…是不小心碰到了吧", 80 | "萝莉控是什么呀", 81 | "你看到我的小熊了吗", 82 | "再摸的话我可要报警了!⌇●﹏●⌇", 83 | "110吗,这里有个变态一直在摸我(ó﹏ò。)" 84 | ] 85 | } 86 | ], 87 | "seasons": [ 88 | { "date": "01/01", "text": ["元旦了呢,新的一年又开始了,今年是{year}年~"] }, 89 | { "date": "02/14", "text": ["又是一年情人节,{year}年找到对象了嘛~"] }, 90 | { "date": "03/08", "text": ["今天是妇女节!"] }, 91 | { "date": "03/12", "text": ["今天是植树节,要保护环境呀"] }, 92 | { "date": "04/01", "text": ["悄悄告诉你一个秘密~今天是愚人节,不要被骗了哦~"] }, 93 | { "date": "05/01", "text": ["今天是五一劳动节,计划好假期去哪里了吗~"] }, 94 | { "date": "06/01", "text": ["儿童节了呢,快活的时光总是短暂,要是永远长不大该多好啊…"] }, 95 | { "date": "09/03", "text": ["中国人民抗日战争胜利纪念日,铭记历史、缅怀先烈、珍爱和平、开创未来。"] }, 96 | { "date": "09/10", "text": ["教师节,在学校要给老师问声好呀~"] }, 97 | { "date": "10/01", "text": ["国庆节,新中国已经成立69年了呢"] }, 98 | { "date": "11/05-11/12", "text": ["今年的双十一是和谁一起过的呢~"] }, 99 | { "date": "12/20-12/31", "text": ["这几天是圣诞节,主人肯定又去剁手买买买了~"] } 100 | ] 101 | } -------------------------------------------------------------------------------- /demo1-default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Live2D 看板娘 v1.4 / Demo 1 6 | 7 | 8 | 9 |

Live2D 看板娘 v1.4 / Demo 1

10 |

- 常规引用 (常规博客引用推荐)

11 | 16 | 17 |
 18 | <!DOCTYPE html>
 19 | <html xmlns="http://www.w3.org/1999/xhtml">
 20 | <head>
 21 |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 22 |     <title>Live2D 看板娘 v1.4 / Demo 1</title>
 23 |     <link rel="stylesheet" type="text/css" href="assets/waifu.min.css?v=1.4.2"/>
 24 | </head>
 25 | <body style="font-family: 'Microsoft YaHei';">
 26 |     <h2><a href="https://www.fghrsh.net/post/123.html" style="color: #38A3DB; text-decoration: none;">Live2D 看板娘 v1.4</a> / Demo 1</h2>
 27 |     <h3> - 常规引用 <span style="font-size: 12px;color: #666">(常规博客引用推荐)</span></h3>
 28 |     <ul>
 29 |         <li><span title="常规博客引用推荐">Demo 1 (当前面页)</span></li>
 30 |         <li><a href="demo2-autoload.html" style="color: #38A3DB; text-decoration: none;" title="一般网站引用推荐">Demo 2 - 自动加载 autoload.js</a></li>
 31 |         <li><a href="demo3-waifu-tips.html" style="color: #38A3DB; text-decoration: none;" title="博客园等网站引用推荐">Demo 3 - 内置 waifu-tips.json</a></li>
 32 |     </ul>
 33 |     
 34 |     <!-- waifu-tips.js 依赖 JQuery 库 -->
 35 |     <script src="assets/jquery.min.js?v=3.3.1"></script>
 36 |     
 37 |     <!-- 实现拖动效果,需引入 JQuery UI -->
 38 |     <script src="assets/jquery-ui.min.js?v=1.12.1"></script>
 39 |     
 40 |     <div class="waifu">
 41 |         <div class="waifu-tips"></div>
 42 |         <canvas id="live2d" class="live2d"></canvas>
 43 |         <div class="waifu-tool">
 44 |             <span class="fui-home"></span>
 45 |             <span class="fui-chat"></span>
 46 |             <span class="fui-eye"></span>
 47 |             <span class="fui-user"></span>
 48 |             <span class="fui-photo"></span>
 49 |             <span class="fui-info-circle"></span>
 50 |             <span class="fui-cross"></span>
 51 |         </div>
 52 |     </div>
 53 |         
 54 |     <script src="assets/waifu-tips.min.js?v=1.4.2"></script>
 55 |     <script src="assets/live2d.min.js?v=1.0.5"></script>
 56 |     <script type="text/javascript">
 57 |         /* 可直接修改部分参数 */
 58 |         live2d_settings['modelId'] = 1;                  // 默认模型 ID
 59 |         live2d_settings['modelTexturesId'] = 87;         // 默认材质 ID
 60 |         live2d_settings['modelStorage'] = false;         // 不储存模型 ID
 61 |         live2d_settings['canCloseLive2d'] = false;       // 隐藏 关闭看板娘 按钮
 62 |         live2d_settings['canTurnToHomePage'] = false;    // 隐藏 返回首页 按钮
 63 |         live2d_settings['waifuSize'] = '600x535';        // 看板娘大小
 64 |         live2d_settings['waifuTipsSize'] = '570x150';    // 提示框大小
 65 |         live2d_settings['waifuFontSize'] = '30px';       // 提示框字体
 66 |         live2d_settings['waifuToolFont'] = '36px';       // 工具栏字体
 67 |         live2d_settings['waifuToolLine'] = '50px';       // 工具栏行高
 68 |         live2d_settings['waifuToolTop'] = '-60px';       // 工具栏顶部边距
 69 |         live2d_settings['waifuDraggable'] = 'axis-x';    // 拖拽样式
 70 |         /* 在 initModel 前添加 */
 71 |         initModel("assets/waifu-tips.json?v=1.4.2")
 72 |     </script>
 73 | </body>
 74 | </html>
 75 |     
76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
84 |
85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
95 |
96 | 97 | 98 | 99 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /assets/waifu.css: -------------------------------------------------------------------------------- 1 | .waifu { 2 | position: fixed; 3 | bottom: 0; 4 | z-index: 1; 5 | font-size: 0; 6 | -webkit-transform: translateY(3px); 7 | transform: translateY(3px); 8 | } 9 | .waifu:hover { 10 | -webkit-transform: translateY(0); 11 | transform: translateY(0); 12 | } 13 | .waifu-tips { 14 | opacity: 0; 15 | margin: -20px 20px; 16 | padding: 5px 10px; 17 | border: 1px solid rgba(224, 186, 140, 0.62); 18 | border-radius: 12px; 19 | background-color: rgba(236, 217, 188, 0.5); 20 | box-shadow: 0 3px 15px 2px rgba(191, 158, 118, 0.2); 21 | text-overflow: ellipsis; 22 | overflow: hidden; 23 | position: absolute; 24 | animation-delay: 5s; 25 | animation-duration: 50s; 26 | animation-iteration-count: infinite; 27 | animation-name: shake; 28 | animation-timing-function: ease-in-out; 29 | } 30 | .waifu-tool { 31 | display: none; 32 | color: #aaa; 33 | top: 50px; 34 | right: 10px; 35 | position: absolute; 36 | } 37 | .waifu:hover .waifu-tool { 38 | display: block; 39 | } 40 | .waifu-tool span { 41 | display: block; 42 | cursor: pointer; 43 | color: #5b6c7d; 44 | transition: 0.2s; 45 | } 46 | .waifu-tool span:hover { 47 | color: #34495e; 48 | } 49 | .waifu #live2d{ 50 | position: relative; 51 | } 52 | 53 | @keyframes shake { 54 | 2% { 55 | transform: translate(0.5px, -1.5px) rotate(-0.5deg); 56 | } 57 | 58 | 4% { 59 | transform: translate(0.5px, 1.5px) rotate(1.5deg); 60 | } 61 | 62 | 6% { 63 | transform: translate(1.5px, 1.5px) rotate(1.5deg); 64 | } 65 | 66 | 8% { 67 | transform: translate(2.5px, 1.5px) rotate(0.5deg); 68 | } 69 | 70 | 10% { 71 | transform: translate(0.5px, 2.5px) rotate(0.5deg); 72 | } 73 | 74 | 12% { 75 | transform: translate(1.5px, 1.5px) rotate(0.5deg); 76 | } 77 | 78 | 14% { 79 | transform: translate(0.5px, 0.5px) rotate(0.5deg); 80 | } 81 | 82 | 16% { 83 | transform: translate(-1.5px, -0.5px) rotate(1.5deg); 84 | } 85 | 86 | 18% { 87 | transform: translate(0.5px, 0.5px) rotate(1.5deg); 88 | } 89 | 90 | 20% { 91 | transform: translate(2.5px, 2.5px) rotate(1.5deg); 92 | } 93 | 94 | 22% { 95 | transform: translate(0.5px, -1.5px) rotate(1.5deg); 96 | } 97 | 98 | 24% { 99 | transform: translate(-1.5px, 1.5px) rotate(-0.5deg); 100 | } 101 | 102 | 26% { 103 | transform: translate(1.5px, 0.5px) rotate(1.5deg); 104 | } 105 | 106 | 28% { 107 | transform: translate(-0.5px, -0.5px) rotate(-0.5deg); 108 | } 109 | 110 | 30% { 111 | transform: translate(1.5px, -0.5px) rotate(-0.5deg); 112 | } 113 | 114 | 32% { 115 | transform: translate(2.5px, -1.5px) rotate(1.5deg); 116 | } 117 | 118 | 34% { 119 | transform: translate(2.5px, 2.5px) rotate(-0.5deg); 120 | } 121 | 122 | 36% { 123 | transform: translate(0.5px, -1.5px) rotate(0.5deg); 124 | } 125 | 126 | 38% { 127 | transform: translate(2.5px, -0.5px) rotate(-0.5deg); 128 | } 129 | 130 | 40% { 131 | transform: translate(-0.5px, 2.5px) rotate(0.5deg); 132 | } 133 | 134 | 42% { 135 | transform: translate(-1.5px, 2.5px) rotate(0.5deg); 136 | } 137 | 138 | 44% { 139 | transform: translate(-1.5px, 1.5px) rotate(0.5deg); 140 | } 141 | 142 | 46% { 143 | transform: translate(1.5px, -0.5px) rotate(-0.5deg); 144 | } 145 | 146 | 48% { 147 | transform: translate(2.5px, -0.5px) rotate(0.5deg); 148 | } 149 | 150 | 50% { 151 | transform: translate(-1.5px, 1.5px) rotate(0.5deg); 152 | } 153 | 154 | 52% { 155 | transform: translate(-0.5px, 1.5px) rotate(0.5deg); 156 | } 157 | 158 | 54% { 159 | transform: translate(-1.5px, 1.5px) rotate(0.5deg); 160 | } 161 | 162 | 56% { 163 | transform: translate(0.5px, 2.5px) rotate(1.5deg); 164 | } 165 | 166 | 58% { 167 | transform: translate(2.5px, 2.5px) rotate(0.5deg); 168 | } 169 | 170 | 60% { 171 | transform: translate(2.5px, -1.5px) rotate(1.5deg); 172 | } 173 | 174 | 62% { 175 | transform: translate(-1.5px, 0.5px) rotate(1.5deg); 176 | } 177 | 178 | 64% { 179 | transform: translate(-1.5px, 1.5px) rotate(1.5deg); 180 | } 181 | 182 | 66% { 183 | transform: translate(0.5px, 2.5px) rotate(1.5deg); 184 | } 185 | 186 | 68% { 187 | transform: translate(2.5px, -1.5px) rotate(1.5deg); 188 | } 189 | 190 | 70% { 191 | transform: translate(2.5px, 2.5px) rotate(0.5deg); 192 | } 193 | 194 | 72% { 195 | transform: translate(-0.5px, -1.5px) rotate(1.5deg); 196 | } 197 | 198 | 74% { 199 | transform: translate(-1.5px, 2.5px) rotate(1.5deg); 200 | } 201 | 202 | 76% { 203 | transform: translate(-1.5px, 2.5px) rotate(1.5deg); 204 | } 205 | 206 | 78% { 207 | transform: translate(-1.5px, 2.5px) rotate(0.5deg); 208 | } 209 | 210 | 80% { 211 | transform: translate(-1.5px, 0.5px) rotate(-0.5deg); 212 | } 213 | 214 | 82% { 215 | transform: translate(-1.5px, 0.5px) rotate(-0.5deg); 216 | } 217 | 218 | 84% { 219 | transform: translate(-0.5px, 0.5px) rotate(1.5deg); 220 | } 221 | 222 | 86% { 223 | transform: translate(2.5px, 1.5px) rotate(0.5deg); 224 | } 225 | 226 | 88% { 227 | transform: translate(-1.5px, 0.5px) rotate(1.5deg); 228 | } 229 | 230 | 90% { 231 | transform: translate(-1.5px, -0.5px) rotate(-0.5deg); 232 | } 233 | 234 | 92% { 235 | transform: translate(-1.5px, -1.5px) rotate(1.5deg); 236 | } 237 | 238 | 94% { 239 | transform: translate(0.5px, 0.5px) rotate(-0.5deg); 240 | } 241 | 242 | 96% { 243 | transform: translate(2.5px, -0.5px) rotate(-0.5deg); 244 | } 245 | 246 | 98% { 247 | transform: translate(-1.5px, -1.5px) rotate(-0.5deg); 248 | } 249 | 250 | 0%, 100% { 251 | transform: translate(0, 0) rotate(0); 252 | } 253 | } 254 | @font-face { 255 | font-family: 'Flat-UI-Icons'; 256 | src: url('flat-ui-icons-regular.eot'); 257 | src: url('flat-ui-icons-regular.eot?#iefix') format('embedded-opentype'), url('flat-ui-icons-regular.woff') format('woff'), url('flat-ui-icons-regular.ttf') format('truetype'), url('flat-ui-icons-regular.svg#flat-ui-icons-regular') format('svg'); 258 | } 259 | [class^="fui-"], 260 | [class*="fui-"] { 261 | font-family: 'Flat-UI-Icons'; 262 | speak: none; 263 | font-style: normal; 264 | font-weight: normal; 265 | font-variant: normal; 266 | text-transform: none; 267 | -webkit-font-smoothing: antialiased; 268 | -moz-osx-font-smoothing: grayscale; 269 | } 270 | .fui-cross:before { 271 | content: "\e609"; 272 | } 273 | .fui-info-circle:before { 274 | content: "\e60f"; 275 | } 276 | .fui-photo:before { 277 | content: "\e62a"; 278 | } 279 | .fui-eye:before { 280 | content: "\e62c"; 281 | } 282 | .fui-chat:before { 283 | content: "\e62d"; 284 | } 285 | .fui-home:before { 286 | content: "\e62e"; 287 | } 288 | .fui-user:before { 289 | content: "\e631"; 290 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Live2D demo 2 | 3 | Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 的前端 HTML 源码 4 | 5 | ### 特性 6 | 7 | - 基于 API 加载模型,支持 定制 提示语 8 | - 增加 参数设置 一键定制看板娘,易用性++ 9 | - 增加 看板娘样式设置,可直接设置宽高度等 10 | - 支持多种一言接口,基于 JQuery UI 实现拖拽 11 | 12 | ## 使用 13 | 14 | ### 目录结构 15 | 16 | ```shell 17 | │ demo1-default.html // 常规引用 Demo 18 | │ demo2-autoload.html // autoload.js Demo 19 | │ demo3-waifu-tips.html // 内置 waifu-tips Demo 20 | │ 21 | └─assets 22 | autoload.js // 自动异步加载 23 | flat-ui-icons-regular.eot // Flat UI 字体 24 | flat-ui-icons-regular.svg // Flat UI 字体 25 | flat-ui-icons-regular.ttf // Flat UI 字体 26 | flat-ui-icons-regular.woff // Flat UI 字体 27 | live2d.js // Live2D 核心 28 | waifu-tips.js // Live2D 看板娘 扩展 29 | waifu-tips.json // Live2D 看板娘 提示语 30 | waifu.css // Live2D 看板娘 样式表 31 | ``` 32 | 33 | ### 食用方法 34 | 35 | - 依赖类库 36 | - JQuery (`waifu-tips.js`) 37 | - JQuery UI (仅实现 *拖拽效果* 需要) 38 | 39 | - 常规方式引入 40 | 41 | 1. 在 `` 前引入 `waifu.css` 样式表 42 | 2. 在 `` 前引入 `waifu-tips.js` 和 `live2d.js` 43 | 3. 在 `` 前插入 初始化 JS,可在 初始化前 设置参数 44 | 45 | ```html 46 | 47 | 48 | 49 | · · · · · · 50 | 51 | 52 | 53 | 54 | 55 | · · · · · · 56 | 57 |
58 |
59 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |
69 |
70 | 71 | 72 | 73 | 74 | 79 | 80 | 81 | ``` 82 | 83 | - autoload.js 引入 84 | 1. 在 `` 前引入 `autoload.js` 85 | 2. 修改 `autoload.js` 文件路径,可在 初始化前 设置参数 86 | 87 | ```html 88 | · · · · · · 89 | 90 | 91 | 92 | ``` 93 | 94 | ```javascript 95 | try { 96 | · · · · · · 97 | live2d_settings['modelId'] = 1; 98 | live2d_settings['modelTexturesId'] = 87; 99 | initModel('https://www.example.com/path/to/waifu-tips.json'); 100 | } catch(err) { console.log('[Error] JQuery is not defined.') } 101 | 102 | ``` 103 | 104 | - 定制属于你的看板娘 105 | - 修改 `waifu-tips.js` 顶部的设置参数 (或初始化前设置 106 | - 修改 `waifu-tips.json`,定制看板娘提示语,打造专属看板娘 107 | 108 | ### 设置参数 109 | *Tips: `waifu-tips.js` 已自带默认参数,如无特殊要求可跳过* 110 | 111 | - 后端接口 112 | 113 | - `live2d_settings['modelAPI']`
看板娘 API 地址,默认值 `'//live2d.fghrsh.net/api/'` 114 | 115 | - `live2d_settings['tipsMessage']`
提示语读取路径,默认值 `'waifu-tips.json'` (一般在 `initModel` 时指定) 116 | 117 | - `live2d_settings['hitokotoAPI']`
一言 API 接口,可选 `'lwl12.com'`,`'hitokoto.cn'`,`'jinrishici.com'` (古诗词) 118 | 119 | - 默认模型 120 | 121 | - `live2d_settings['modelId']`
默认模型(分组) ID,可在 Demo 页 `[F12]` 呼出 `控制台(Console)` 找到 122 | 123 | - `live2d_settings['modelTexturesId']`
默认材质(模型) ID,可在 Demo 页 `[F12]` 呼出 `控制台(Console)` 找到 124 | 125 | - 工具栏设置 126 | 127 | - `live2d_settings['showToolMenu']`, 显示工具栏, `true` | `false` 128 | - `live2d_settings['canCloseLive2d']`, 关闭看板娘 按钮,`true` | `false` 129 | - `live2d_settings['canSwitchModel']`, 切换模型 按钮, `true` | `false` 130 | - `live2d_settings['canSwitchTextures']`, 切换材质 按钮, `true` | `false` 131 | - `live2d_settings['canSwitchHitokoto']`, 切换一言 按钮, `true` | `false` 132 | - `live2d_settings['canTakeScreenshot']`, 看板娘截图 按钮,`true` | `false` 133 | - `live2d_settings['canTurnToHomePage']`, 返回首页 按钮, `true` | `false` 134 | - `live2d_settings['canTurnToAboutPage']`,跳转关于页 按钮,`true` | `false` 135 | 136 | - 模型切换模式 137 | 138 | - `live2d_settings['modelStorage']`,记录 ID (刷新后恢复),`true` | `false` 139 | - `live2d_settings['modelRandMode']`,模型切换,可选 `'rand'` (随机) | `'switch'` (顺序) 140 | - `live2d_settings['modelTexturesRandMode']`,材质切换,可选 `'rand'` | `'switch'` 141 | 142 | - 提示消息选项 143 | - `live2d_settings['showHitokoto']`,空闲时一言,`true` | `false` 144 | - `live2d_settings['showF12Status']`,控制台显示加载状态,`true` | `false` 145 | - `live2d_settings['showF12Message']`,提示消息输出到控制台,`true` | `false` 146 | - `live2d_settings['showF12OpenMsg']`,控制台被打开触发提醒,`true` | `false` 147 | - `live2d_settings['showCopyMessage']`,内容被复制触发提醒,`true` | `false` 148 | - `live2d_settings['showWelcomeMessage']`,进入面页时显示欢迎语,`true` | `false` 149 | 150 | - 看板娘样式设置 151 | - `live2d_settings['waifuSize']`,看板娘大小,例如 `'280x250'`,`'600x535'` 152 | - `live2d_settings['waifuTipsSize']`,提示框大小,例如 `'250x70'`,`'570x150'` 153 | - `live2d_settings['waifuFontSize']`,提示框字体,例如 `'12px'`,`'30px'` 154 | - `live2d_settings['waifuToolFont']`,工具栏字体,例如 `'14px'`,`'36px'` 155 | - `live2d_settings['waifuToolLine']`,工具栏行高,例如 `'20px'`,`'36px'` 156 | - `live2d_settings['waifuToolTop']`,工具栏顶部边距,例如 `'0px'`,`'-60px'` 157 | 158 | - `live2d_settings['waifuMinWidth']`
面页小于 指定宽度 隐藏看板娘,例如 `'disable'` (停用),`'768px'` 159 | 160 | - `live2d_settings['waifuEdgeSide']`
看板娘贴边方向,例如 `'left:0'` (靠左 0px),`'right:30'` (靠右 30px) 161 | 162 | - `live2d_settings['waifuDraggable']`
拖拽样式,可选 `'disable'` (禁用),`'axis-x'` (只能水平拖拽),`'unlimited'` (自由拖拽) 163 | 164 | - `live2d_settings['waifuDraggableRevert']`,松开鼠标还原拖拽位置,`true` | `false` 165 | 166 | - 其他杂项设置 167 | - `live2d_settings['l2dVersion']`,当前版本 (无需修改) 168 | - `live2d_settings['l2dVerDate']`,更新日期 (无需修改) 169 | - `live2d_settings['homePageUrl']`,首页地址,可选 `'auto'` (自动),`'{URL 网址}'` 170 | - `live2d_settings['aboutPageUrl']`,关于页地址,`'{URL 网址}'` 171 | - `live2d_settings['screenshotCaptureName']`,看板娘截图文件名,例如 `'live2d.png'` 172 | 173 | ### 定制提示语 174 | *Tips: `waifu-tips.json` 已自带默认提示语,如无特殊要求可跳过* 175 | 176 | - `"waifu"` 系统提示 177 | - `"console_open_msg"` 控制台被打开提醒(支持多句随机) 178 | - `"copy_message"` 内容被复制触发提醒(支持多句随机) 179 | - `"screenshot_message"` 看板娘截图提示语(支持多句随机) 180 | - `"hidden_message"` 看板娘隐藏提示语(支持多句随机) 181 | - `"load_rand_textures"` 随机材质提示语(暂不支持多句) 182 | - `"hour_tips"` 时间段欢迎语(支持多句随机) 183 | - `"referrer_message"` 请求来源欢迎语(不支持多句) 184 | - `"referrer_hostname"` 请求来源自定义名称(根据 host,支持多句随机) 185 | - `"model_message"` 模型切换欢迎语(根据模型 ID,支持多句随机) 186 | - `"hitokoto_api_message"`,一言 API 输出模板(不支持多句随机) 187 | - `"mouseover"` 鼠标触发提示(根据 CSS 选择器,支持多句随机) 188 | - `"click"` 鼠标点击触发提示(根据 CSS 选择器,支持多句随机) 189 | - `"seasons"` 节日提示(日期段,支持多句随机) 190 | 191 | ## 版权声明 192 | 193 | > ( ˃ ˄ ˂̥̥ ) 都看到这了,点个 Star 吧 ~ 194 | 195 | [Flat UI Free][1] 196 | [live2d_src / ©journey-ad / GPL v2.0][2] 197 | [waifu-tips.js / ©journey-ad / CC BY-NC-SA 4.0][3] 198 | 199 | Open sourced under the GPL v2.0 license. 200 | 201 | 202 | [1]: https://designmodo.com/flat-free/ "Flat UI Free" 203 | [2]: https://github.com/journey-ad/live2d_src "基于 #fea64e4 的修改版" 204 | [3]: https://imjad.cn/ "猫与向日葵" 205 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /assets/waifu-tips.js: -------------------------------------------------------------------------------- 1 | window.live2d_settings = Array(); /* 2 | 3 | く__,.ヘヽ.    / ,ー、 〉 4 |      \ ', !-─‐-i / /´ 5 |       /`ー'    L//`ヽ、 Live2D 看板娘 参数设置 6 |      /  /,  /|  ,  ,    ', Version 1.4.2 7 |    イ  / /-‐/ i L_ ハ ヽ!  i Update 2018.11.12 8 |     レ ヘ 7イ`ト  レ'ァ-ト、!ハ|  | 9 |      !,/7 '0'   ´0iソ|   |    10 |      |.从"  _   ,,,, / |./   | 网页添加 Live2D 看板娘 11 |      レ'| i>.、,,__ _,.イ /  .i  | https://www.fghrsh.net/post/123.html 12 |       レ'| | / k_7_/レ'ヽ, ハ. | 13 |        | |/i 〈|/  i ,.ヘ | i | Thanks 14 |       .|/ / i:   ヘ!  \ | journey-ad / https://github.com/journey-ad/live2d_src 15 |         kヽ>、ハ   _,.ヘ、   /、! xiazeyu / https://github.com/xiazeyu/live2d-widget.js 16 |        !'〈//`T´', \ `'7'ーr' Live2d Cubism SDK WebGL 2.1 Projrct & All model authors. 17 |        レ'ヽL__|___i,___,ンレ|ノ 18 |          ト-,/ |___./ 19 |          'ー'  !_,.:*********************************************************************************/ 20 | 21 | 22 | // 后端接口 23 | live2d_settings['modelAPI'] = '//live2d.fghrsh.net/api/'; // 自建 API 修改这里 24 | live2d_settings['tipsMessage'] = 'waifu-tips.json'; // 同目录下可省略路径 25 | live2d_settings['hitokotoAPI'] = 'lwl12.com'; // 一言 API,可选 'lwl12.com', 'hitokoto.cn', 'jinrishici.com'(古诗词) 26 | 27 | // 默认模型 28 | live2d_settings['modelId'] = 1; // 默认模型 ID,可在 F12 控制台找到 29 | live2d_settings['modelTexturesId'] = 53; // 默认材质 ID,可在 F12 控制台找到 30 | 31 | // 工具栏设置 32 | live2d_settings['showToolMenu'] = true; // 显示 工具栏 ,可选 true(真), false(假) 33 | live2d_settings['canCloseLive2d'] = true; // 显示 关闭看板娘 按钮,可选 true(真), false(假) 34 | live2d_settings['canSwitchModel'] = true; // 显示 模型切换 按钮,可选 true(真), false(假) 35 | live2d_settings['canSwitchTextures'] = true; // 显示 材质切换 按钮,可选 true(真), false(假) 36 | live2d_settings['canSwitchHitokoto'] = true; // 显示 一言切换 按钮,可选 true(真), false(假) 37 | live2d_settings['canTakeScreenshot'] = true; // 显示 看板娘截图 按钮,可选 true(真), false(假) 38 | live2d_settings['canTurnToHomePage'] = true; // 显示 返回首页 按钮,可选 true(真), false(假) 39 | live2d_settings['canTurnToAboutPage'] = true; // 显示 跳转关于页 按钮,可选 true(真), false(假) 40 | 41 | // 模型切换模式 42 | live2d_settings['modelStorage'] = true; // 记录 ID (刷新后恢复),可选 true(真), false(假) 43 | live2d_settings['modelRandMode'] = 'switch'; // 模型切换,可选 'rand'(随机), 'switch'(顺序) 44 | live2d_settings['modelTexturesRandMode']= 'rand'; // 材质切换,可选 'rand'(随机), 'switch'(顺序) 45 | 46 | // 提示消息选项 47 | live2d_settings['showHitokoto'] = true; // 显示一言 48 | live2d_settings['showF12Status'] = true; // 显示加载状态 49 | live2d_settings['showF12Message'] = false; // 显示看板娘消息 50 | live2d_settings['showF12OpenMsg'] = true; // 显示控制台打开提示 51 | live2d_settings['showCopyMessage'] = true; // 显示 复制内容 提示 52 | live2d_settings['showWelcomeMessage'] = true; // 显示进入面页欢迎词 53 | 54 | //看板娘样式设置 55 | live2d_settings['waifuSize'] = '280x250'; // 看板娘大小,例如 '280x250', '600x535' 56 | live2d_settings['waifuTipsSize'] = '250x70'; // 提示框大小,例如 '250x70', '570x150' 57 | live2d_settings['waifuFontSize'] = '12px'; // 提示框字体,例如 '12px', '30px' 58 | live2d_settings['waifuToolFont'] = '14px'; // 工具栏字体,例如 '14px', '36px' 59 | live2d_settings['waifuToolLine'] = '20px'; // 工具栏行高,例如 '20px', '36px' 60 | live2d_settings['waifuToolTop'] = '0px' // 工具栏顶部边距,例如 '0px', '-60px' 61 | live2d_settings['waifuMinWidth'] = '768px'; // 面页小于 指定宽度 隐藏看板娘,例如 'disable'(禁用), '768px' 62 | live2d_settings['waifuEdgeSide'] = 'left:0'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px) 63 | live2d_settings['waifuDraggable'] = 'disable'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽) 64 | live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假) 65 | 66 | // 其他杂项设置 67 | live2d_settings['l2dVersion'] = '1.4.2'; // 当前版本 68 | live2d_settings['l2dVerDate'] = '2018.11.12'; // 版本更新日期 69 | live2d_settings['homePageUrl'] = 'auto'; // 主页地址,可选 'auto'(自动), '{URL 网址}' 70 | live2d_settings['aboutPageUrl'] = 'https://www.fghrsh.net/post/123.html'; // 关于页地址, '{URL 网址}' 71 | live2d_settings['screenshotCaptureName']= 'live2d.png'; // 看板娘截图文件名,例如 'live2d.png' 72 | 73 | /****************************************************************************************************/ 74 | 75 | String.prototype.render = function(context) { 76 | var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g; 77 | 78 | return this.replace(tokenReg, function (word, slash1, token, slash2) { 79 | if (slash1 || slash2) { return word.replace('\\', ''); } 80 | 81 | var variables = token.replace(/\s/g, '').split('.'); 82 | var currentObject = context; 83 | var i, length, variable; 84 | 85 | for (i = 0, length = variables.length; i < length; ++i) { 86 | variable = variables[i]; 87 | currentObject = currentObject[variable]; 88 | if (currentObject === undefined || currentObject === null) return ''; 89 | } 90 | return currentObject; 91 | }); 92 | }; 93 | 94 | var re = /x/; 95 | console.log(re); 96 | 97 | function empty(obj) {return typeof obj=="undefined"||obj==null||obj==""?true:false} 98 | function getRandText(text) {return Array.isArray(text) ? text[Math.floor(Math.random() * text.length + 1)-1] : text} 99 | 100 | function showMessage(text, timeout, flag) { 101 | if(flag || sessionStorage.getItem('waifu-text') === '' || sessionStorage.getItem('waifu-text') === null){ 102 | if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1]; 103 | if (live2d_settings.showF12Message) console.log('[Message]', text.replace(/<[^<>]+>/g,'')); 104 | 105 | if(flag) sessionStorage.setItem('waifu-text', text); 106 | 107 | $('.waifu-tips').stop(); 108 | $('.waifu-tips').html(text).fadeTo(200, 1); 109 | if (timeout === undefined) timeout = 5000; 110 | hideMessage(timeout); 111 | } 112 | } 113 | 114 | function hideMessage(timeout) { 115 | $('.waifu-tips').stop().css('opacity',1); 116 | if (timeout === undefined) timeout = 5000; 117 | window.setTimeout(function() {sessionStorage.removeItem('waifu-text')}, timeout); 118 | $('.waifu-tips').delay(timeout).fadeTo(200, 0); 119 | } 120 | 121 | function initModel(waifuPath, type) { 122 | /* console welcome message */ 123 | eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8.d(" ");8.d("\\U,.\\y\\5.\\1\\1\\1\\1/\\1,\\u\\2 \\H\\n\\1\\1\\1\\1\\1\\b \', !-\\r\\j-i\\1/\\1/\\g\\n\\1\\1\\1 \\1 \\a\\4\\f\'\\1\\1\\1 L/\\a\\4\\5\\2\\n\\1\\1 \\1 /\\1 \\a,\\1 /|\\1 ,\\1 ,\\1\\1\\1 \',\\n\\1\\1\\1\\q \\1/ /-\\j/\\1\\h\\E \\9 \\5!\\1 i\\n\\1\\1\\1 \\3 \\6 7\\q\\4\\c\\1 \\3\'\\s-\\c\\2!\\t|\\1 |\\n\\1\\1\\1\\1 !,/7 \'0\'\\1\\1 \\X\\w| \\1 |\\1\\1\\1\\n\\1\\1\\1\\1 |.\\x\\"\\1\\l\\1\\1 ,,,, / |./ \\1 |\\n\\1\\1\\1\\1 \\3\'| i\\z.\\2,,A\\l,.\\B / \\1.i \\1|\\n\\1\\1\\1\\1\\1 \\3\'| | / C\\D/\\3\'\\5,\\1\\9.\\1|\\n\\1\\1\\1\\1\\1\\1 | |/i \\m|/\\1 i\\1,.\\6 |\\F\\1|\\n\\1\\1\\1\\1\\1\\1.|/ /\\1\\h\\G \\1 \\6!\\1\\1\\b\\1|\\n\\1\\1\\1 \\1 \\1 k\\5>\\2\\9 \\1 o,.\\6\\2 \\1 /\\2!\\n\\1\\1\\1\\1\\1\\1 !\'\\m//\\4\\I\\g\', \\b \\4\'7\'\\J\'\\n\\1\\1\\1\\1\\1\\1 \\3\'\\K|M,p,\\O\\3|\\P\\n\\1\\1\\1\\1\\1 \\1\\1\\1\\c-,/\\1|p./\\n\\1\\1\\1\\1\\1 \\1\\1\\1\'\\f\'\\1\\1!o,.:\\Q \\R\\S\\T v"+e.V+" / W "+e.N);8.d(" ");',60,60,'|u3000|uff64|uff9a|uff40|u30fd|uff8d||console|uff8a|uff0f|uff3c|uff84|log|live2d_settings|uff70|u00b4|uff49||u2010||u3000_|u3008||_|___|uff72|u2500|uff67|u30cf|u30fc||u30bd|u4ece|u30d8|uff1e|__|u30a4|k_|uff17_|u3000L_|u3000i|uff1a|u3009|uff34|uff70r|u30fdL__||___i|l2dVerDate|u30f3|u30ce|nLive2D|u770b|u677f|u5a18|u304f__|l2dVersion|FGHRSH|u00b40i'.split('|'),0,{})); 124 | 125 | /* 判断 JQuery */ 126 | if (typeof($.ajax) != 'function') typeof(jQuery.ajax) == 'function' ? window.$ = jQuery : console.log('[Error] JQuery is not defined.'); 127 | 128 | /* 加载看板娘样式 */ 129 | live2d_settings.waifuSize = live2d_settings.waifuSize.split('x'); 130 | live2d_settings.waifuTipsSize = live2d_settings.waifuTipsSize.split('x'); 131 | live2d_settings.waifuEdgeSide = live2d_settings.waifuEdgeSide.split(':'); 132 | 133 | $("#live2d").attr("width",live2d_settings.waifuSize[0]); 134 | $("#live2d").attr("height",live2d_settings.waifuSize[1]); 135 | $(".waifu-tips").width(live2d_settings.waifuTipsSize[0]); 136 | $(".waifu-tips").height(live2d_settings.waifuTipsSize[1]); 137 | $(".waifu-tips").css("top",live2d_settings.waifuToolTop); 138 | $(".waifu-tips").css("font-size",live2d_settings.waifuFontSize); 139 | $(".waifu-tool").css("font-size",live2d_settings.waifuToolFont); 140 | $(".waifu-tool span").css("line-height",live2d_settings.waifuToolLine); 141 | 142 | if (live2d_settings.waifuEdgeSide[0] == 'left') $(".waifu").css("left",live2d_settings.waifuEdgeSide[1]+'px'); 143 | else if (live2d_settings.waifuEdgeSide[0] == 'right') $(".waifu").css("right",live2d_settings.waifuEdgeSide[1]+'px'); 144 | 145 | window.waifuResize = function() { $(window).width() <= Number(live2d_settings.waifuMinWidth.replace('px','')) ? $(".waifu").hide() : $(".waifu").show(); }; 146 | if (live2d_settings.waifuMinWidth != 'disable') { waifuResize(); $(window).resize(function() {waifuResize()}); } 147 | 148 | try { 149 | if (live2d_settings.waifuDraggable == 'axis-x') $(".waifu").draggable({ axis: "x", revert: live2d_settings.waifuDraggableRevert }); 150 | else if (live2d_settings.waifuDraggable == 'unlimited') $(".waifu").draggable({ revert: live2d_settings.waifuDraggableRevert }); 151 | else $(".waifu").css("transition", 'all .3s ease-in-out'); 152 | } catch(err) { console.log('[Error] JQuery UI is not defined.') } 153 | 154 | live2d_settings.homePageUrl = live2d_settings.homePageUrl == 'auto' ? window.location.protocol+'//'+window.location.hostname+'/' : live2d_settings.homePageUrl; 155 | if (window.location.protocol == 'file:' && live2d_settings.modelAPI.substr(0,2) == '//') live2d_settings.modelAPI = 'http:'+live2d_settings.modelAPI; 156 | 157 | $('.waifu-tool .fui-home').click(function (){ 158 | //window.location = 'https://www.fghrsh.net/'; 159 | window.location = live2d_settings.homePageUrl; 160 | }); 161 | 162 | $('.waifu-tool .fui-info-circle').click(function (){ 163 | //window.open('https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02'); 164 | window.open(live2d_settings.aboutPageUrl); 165 | }); 166 | 167 | if (typeof(waifuPath) == "object") loadTipsMessage(waifuPath); else { 168 | $.ajax({ 169 | cache: true, 170 | url: waifuPath == '' ? live2d_settings.tipsMessage : (waifuPath.substr(waifuPath.length-15)=='waifu-tips.json'?waifuPath:waifuPath+'waifu-tips.json'), 171 | dataType: "json", 172 | success: function (result){ loadTipsMessage(result); } 173 | }); 174 | } 175 | 176 | if (!live2d_settings.showToolMenu) $('.waifu-tool').hide(); 177 | if (!live2d_settings.canCloseLive2d) $('.waifu-tool .fui-cross').hide(); 178 | if (!live2d_settings.canSwitchModel) $('.waifu-tool .fui-eye').hide(); 179 | if (!live2d_settings.canSwitchTextures) $('.waifu-tool .fui-user').hide(); 180 | if (!live2d_settings.canSwitchHitokoto) $('.waifu-tool .fui-chat').hide(); 181 | if (!live2d_settings.canTakeScreenshot) $('.waifu-tool .fui-photo').hide(); 182 | if (!live2d_settings.canTurnToHomePage) $('.waifu-tool .fui-home').hide(); 183 | if (!live2d_settings.canTurnToAboutPage) $('.waifu-tool .fui-info-circle').hide(); 184 | 185 | if (waifuPath === undefined) waifuPath = ''; 186 | var modelId = localStorage.getItem('modelId'); 187 | var modelTexturesId = localStorage.getItem('modelTexturesId'); 188 | 189 | if (!live2d_settings.modelStorage || modelId == null) { 190 | var modelId = live2d_settings.modelId; 191 | var modelTexturesId = live2d_settings.modelTexturesId; 192 | } loadModel(modelId, modelTexturesId); 193 | } 194 | 195 | function loadModel(modelId, modelTexturesId=0) { 196 | if (live2d_settings.modelStorage) { 197 | localStorage.setItem('modelId', modelId); 198 | localStorage.setItem('modelTexturesId', modelTexturesId); 199 | } else { 200 | sessionStorage.setItem('modelId', modelId); 201 | sessionStorage.setItem('modelTexturesId', modelTexturesId); 202 | } loadlive2d('live2d', live2d_settings.modelAPI+'get/?id='+modelId+'-'+modelTexturesId, (live2d_settings.showF12Status ? console.log('[Status]','live2d','模型',modelId+'-'+modelTexturesId,'加载完成'):null)); 203 | } 204 | 205 | function loadTipsMessage(result) { 206 | window.waifu_tips = result; 207 | 208 | $.each(result.mouseover, function (index, tips){ 209 | $(document).on("mouseover", tips.selector, function (){ 210 | var text = getRandText(tips.text); 211 | text = text.render({text: $(this).text()}); 212 | showMessage(text, 3000); 213 | }); 214 | }); 215 | $.each(result.click, function (index, tips){ 216 | $(document).on("click", tips.selector, function (){ 217 | var text = getRandText(tips.text); 218 | text = text.render({text: $(this).text()}); 219 | showMessage(text, 3000, true); 220 | }); 221 | }); 222 | $.each(result.seasons, function (index, tips){ 223 | var now = new Date(); 224 | var after = tips.date.split('-')[0]; 225 | var before = tips.date.split('-')[1] || after; 226 | 227 | if((after.split('/')[0] <= now.getMonth()+1 && now.getMonth()+1 <= before.split('/')[0]) && 228 | (after.split('/')[1] <= now.getDate() && now.getDate() <= before.split('/')[1])){ 229 | var text = getRandText(tips.text); 230 | text = text.render({year: now.getFullYear()}); 231 | showMessage(text, 6000, true); 232 | } 233 | }); 234 | 235 | if (live2d_settings.showF12OpenMsg) { 236 | re.toString = function() { 237 | showMessage(getRandText(result.waifu.console_open_msg), 5000, true); 238 | return ''; 239 | }; 240 | } 241 | 242 | if (live2d_settings.showCopyMessage) { 243 | $(document).on('copy', function() { 244 | showMessage(getRandText(result.waifu.copy_message), 5000, true); 245 | }); 246 | } 247 | 248 | $('.waifu-tool .fui-photo').click(function(){ 249 | showMessage(getRandText(result.waifu.screenshot_message), 5000, true); 250 | window.Live2D.captureName = live2d_settings.screenshotCaptureName; 251 | window.Live2D.captureFrame = true; 252 | }); 253 | 254 | $('.waifu-tool .fui-cross').click(function(){ 255 | sessionStorage.setItem('waifu-dsiplay', 'none'); 256 | showMessage(getRandText(result.waifu.hidden_message), 1300, true); 257 | window.setTimeout(function() {$('.waifu').hide();}, 1300); 258 | }); 259 | 260 | window.showWelcomeMessage = function(result) { 261 | var text; 262 | if (window.location.href == live2d_settings.homePageUrl) { 263 | var now = (new Date()).getHours(); 264 | if (now > 23 || now <= 5) text = getRandText(result.waifu.hour_tips['t23-5']); 265 | else if (now > 5 && now <= 7) text = getRandText(result.waifu.hour_tips['t5-7']); 266 | else if (now > 7 && now <= 11) text = getRandText(result.waifu.hour_tips['t7-11']); 267 | else if (now > 11 && now <= 14) text = getRandText(result.waifu.hour_tips['t11-14']); 268 | else if (now > 14 && now <= 17) text = getRandText(result.waifu.hour_tips['t14-17']); 269 | else if (now > 17 && now <= 19) text = getRandText(result.waifu.hour_tips['t17-19']); 270 | else if (now > 19 && now <= 21) text = getRandText(result.waifu.hour_tips['t19-21']); 271 | else if (now > 21 && now <= 23) text = getRandText(result.waifu.hour_tips['t21-23']); 272 | else text = getRandText(result.waifu.hour_tips.default); 273 | } else { 274 | var referrer_message = result.waifu.referrer_message; 275 | if (document.referrer !== '') { 276 | var referrer = document.createElement('a'); 277 | referrer.href = document.referrer; 278 | var domain = referrer.hostname.split('.')[1]; 279 | if (window.location.hostname == referrer.hostname) 280 | text = referrer_message.localhost[0] + document.title.split(referrer_message.localhost[2])[0] + referrer_message.localhost[1]; 281 | else if (domain == 'baidu') 282 | text = referrer_message.baidu[0] + referrer.search.split('&wd=')[1].split('&')[0] + referrer_message.baidu[1]; 283 | else if (domain == 'so') 284 | text = referrer_message.so[0] + referrer.search.split('&q=')[1].split('&')[0] + referrer_message.so[1]; 285 | else if (domain == 'google') 286 | text = referrer_message.google[0] + document.title.split(referrer_message.google[2])[0] + referrer_message.google[1]; 287 | else { 288 | $.each(result.waifu.referrer_hostname, function(i,val) {if (i==referrer.hostname) referrer.hostname = getRandText(val)}); 289 | text = referrer_message.default[0] + referrer.hostname + referrer_message.default[1]; 290 | } 291 | } else text = referrer_message.none[0] + document.title.split(referrer_message.none[2])[0] + referrer_message.none[1]; 292 | } 293 | showMessage(text, 6000); 294 | }; if (live2d_settings.showWelcomeMessage) showWelcomeMessage(result); 295 | 296 | var waifu_tips = result.waifu; 297 | 298 | function loadOtherModel() { 299 | var modelId = modelStorageGetItem('modelId'); 300 | var modelRandMode = live2d_settings.modelRandMode; 301 | 302 | $.ajax({ 303 | cache: modelRandMode == 'switch' ? true : false, 304 | url: live2d_settings.modelAPI+modelRandMode+'/?id='+modelId, 305 | dataType: "json", 306 | success: function(result) { 307 | loadModel(result.model['id']); 308 | var message = result.model['message']; 309 | $.each(waifu_tips.model_message, function(i,val) {if (i==result.model['id']) message = getRandText(val)}); 310 | showMessage(message, 3000, true); 311 | } 312 | }); 313 | } 314 | 315 | function loadRandTextures() { 316 | var modelId = modelStorageGetItem('modelId'); 317 | var modelTexturesId = modelStorageGetItem('modelTexturesId'); 318 | var modelTexturesRandMode = live2d_settings.modelTexturesRandMode; 319 | 320 | $.ajax({ 321 | cache: modelTexturesRandMode == 'switch' ? true : false, 322 | url: live2d_settings.modelAPI+modelTexturesRandMode+'_textures/?id='+modelId+'-'+modelTexturesId, 323 | dataType: "json", 324 | success: function(result) { 325 | if (result.textures['id'] == 1 && (modelTexturesId == 1 || modelTexturesId == 0)) 326 | showMessage(waifu_tips.load_rand_textures[0], 3000, true); 327 | else showMessage(waifu_tips.load_rand_textures[1], 3000, true); 328 | loadModel(modelId, result.textures['id']); 329 | } 330 | }); 331 | } 332 | 333 | function modelStorageGetItem(key) { return live2d_settings.modelStorage ? localStorage.getItem(key) : sessionStorage.getItem(key); } 334 | 335 | /* 检测用户活动状态,并在空闲时显示一言 */ 336 | if (live2d_settings.showHitokoto) { 337 | window.getActed = false; window.hitokotoTimer = 0; window.hitokotoInterval = false; 338 | $(document).mousemove(function(e){getActed = true;}).keydown(function(){getActed = true;}); 339 | setInterval(function(){ if (!getActed) ifActed(); else elseActed(); }, 1000); 340 | } 341 | 342 | function ifActed() { 343 | if (!hitokotoInterval) { 344 | hitokotoInterval = true; 345 | hitokotoTimer = window.setInterval(showHitokotoActed, 30000); 346 | } 347 | } 348 | 349 | function elseActed() { 350 | getActed = hitokotoInterval = false; 351 | window.clearInterval(hitokotoTimer); 352 | } 353 | 354 | function showHitokotoActed() { 355 | if ($(document)[0].visibilityState == 'visible') showHitokoto(); 356 | } 357 | 358 | function showHitokoto() { 359 | switch(live2d_settings.hitokotoAPI) { 360 | case 'lwl12.com': 361 | $.getJSON('https://api.lwl12.com/hitokoto/v1?encode=realjson',function(result){ 362 | if (!empty(result.source)) { 363 | var text = waifu_tips.hitokoto_api_message['lwl12.com'][0]; 364 | if (!empty(result.author)) text += waifu_tips.hitokoto_api_message['lwl12.com'][1]; 365 | text = text.render({source: result.source, creator: result.author}); 366 | window.setTimeout(function() {showMessage(text+waifu_tips.hitokoto_api_message['lwl12.com'][2], 3000, true);}, 5000); 367 | } showMessage(result.text, 5000, true); 368 | });break; 369 | case 'fghrsh.net': 370 | $.getJSON('https://api.fghrsh.net/hitokoto/rand/?encode=jsc&uid=3335',function(result){ 371 | if (!empty(result.source)) { 372 | var text = waifu_tips.hitokoto_api_message['fghrsh.net'][0]; 373 | text = text.render({source: result.source, date: result.date}); 374 | window.setTimeout(function() {showMessage(text, 3000, true);}, 5000); 375 | showMessage(result.hitokoto, 5000, true); 376 | } 377 | });break; 378 | case 'jinrishici.com': 379 | $.ajax({ 380 | url: 'https://v2.jinrishici.com/one.json', 381 | xhrFields: {withCredentials: true}, 382 | success: function (result, status) { 383 | if (!empty(result.data.origin.title)) { 384 | var text = waifu_tips.hitokoto_api_message['jinrishici.com'][0]; 385 | text = text.render({title: result.data.origin.title, dynasty: result.data.origin.dynasty, author:result.data.origin.author}); 386 | window.setTimeout(function() {showMessage(text, 3000, true);}, 5000); 387 | } showMessage(result.data.content, 5000, true); 388 | } 389 | });break; 390 | default: 391 | $.getJSON('https://v1.hitokoto.cn',function(result){ 392 | if (!empty(result.from)) { 393 | var text = waifu_tips.hitokoto_api_message['hitokoto.cn'][0]; 394 | text = text.render({source: result.from, creator: result.creator}); 395 | window.setTimeout(function() {showMessage(text, 3000, true);}, 5000); 396 | } 397 | showMessage(result.hitokoto, 5000, true); 398 | }); 399 | } 400 | } 401 | 402 | $('.waifu-tool .fui-eye').click(function (){loadOtherModel()}); 403 | $('.waifu-tool .fui-user').click(function (){loadRandTextures()}); 404 | $('.waifu-tool .fui-chat').click(function (){showHitokoto()}); 405 | } 406 | -------------------------------------------------------------------------------- /demo3-waifu-tips.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Live2D 看板娘 v1.4 / Demo 3 6 | 7 | 8 | 9 |

Live2D 看板娘 v1.4 / Demo 3

10 |

- 内置 waifu-tips.json (博客园等网站引用推荐)

11 | 16 | 17 |
 18 | <!DOCTYPE html>
 19 | <html xmlns="http://www.w3.org/1999/xhtml">
 20 | <head>
 21 |     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 22 |     <title>Live2D 看板娘 v1.4 / Demo 3</title>
 23 |     <link rel="stylesheet" type="text/css" href="assets/waifu.min.css?v=1.4.2"/>
 24 | </head>
 25 | <body style="font-family: 'Microsoft YaHei';">
 26 |     <h2><a href="https://www.fghrsh.net/post/123.html" style="color: #38A3DB; text-decoration: none;">Live2D 看板娘 v1.4</a> / Demo 3</h2>
 27 |     <h3> - 内置 waifu-tips.json <span style="font-size: 12px;color: #666">(博客园等网站引用推荐)</span></h3>
 28 |     <ul>
 29 |         <li><a href="demo1-default.html" style="color: #38A3DB; text-decoration: none;" title="常规博客引用推荐">Demo 1 - 常规引用</a></li>
 30 |         <li><a href="demo2-autoload.html" style="color: #38A3DB; text-decoration: none;" title="一般网站引用推荐">Demo 2 - 自动加载 autoload.js</a></li>
 31 |         <li><span title="博客园等网站引用推荐">Demo 3 (当前面页)</span></li>
 32 |     </ul>
 33 |     
 34 |     <!-- waifu-tips.js 依赖 JQuery 库 -->
 35 |     <script src="assets/jquery.min.js?v=3.3.1"></script>
 36 |     
 37 |         $("<link>").attr({href: "assets/waifu.min.css?v=1.4.2", rel: "stylesheet", type: "text/css"}).appendTo('head');
 38 |     <!-- 实现拖动效果,需引入 JQuery UI -->
 39 |     <script src="assets/jquery-ui.min.js?v=1.12.1"></script>
 40 |     
 41 |     <script type="text/javascript">
 42 |     /* 把 autoload.js 内容直接内置 */
 43 |     $('body').append('<div class="waifu"><div class="waifu-tips"></div><canvas id="live2d" class="live2d"></canvas><div class="waifu-tool"><span class="fui-home"></span> <span class="fui-chat"></span> <span class="fui-eye"></span> <span class="fui-user"></span> <span class="fui-photo"></span> <span class="fui-info-circle"></span> <span class="fui-cross"></span></div></div>');
 44 |     $.ajax({url: "assets/waifu-tips.min.js?v=1.4.2", dataType:"script", cache: true, success: function() {
 45 |         $.ajax({url: "assets/live2d.min.js?v=1.0.5", dataType:"script", cache: true, success: function() {
 46 |                 /* 可直接修改部分参数 */
 47 |                 live2d_settings['hitokotoAPI'] = 'jinrishici.com'; // 一言 API
 48 |                 live2d_settings['modelId'] = 2;                    // 默认模型 ID
 49 |                 live2d_settings['modelTexturesId'] = 6;            // 默认材质 ID
 50 |                 live2d_settings['modelStorage'] = false;           // 不储存模型 ID
 51 |                 live2d_settings['canCloseLive2d'] = false;         // 隐藏 关闭看板娘 按钮
 52 |                 live2d_settings['canTurnToHomePage'] = false;      // 隐藏 返回首页 按钮
 53 |                 live2d_settings['waifuSize'] = '600x535';          // 看板娘大小
 54 |                 live2d_settings['waifuTipsSize'] = '570x150';      // 提示框大小
 55 |                 live2d_settings['waifuFontSize'] = '30px';         // 提示框字体
 56 |                 live2d_settings['waifuEdgeSide'] = 'right:30';     // 看板娘贴边方向
 57 |                 live2d_settings['waifuToolFont'] = '36px';         // 工具栏字体
 58 |                 live2d_settings['waifuToolLine'] = '50px';         // 工具栏行高
 59 |                 live2d_settings['waifuToolTop'] = '-60px';         // 工具栏顶部边距
 60 |                 live2d_settings['waifuDraggable'] = 'axis-x';      // 拖拽样式
 61 |                     
 62 |                 /* 内置 waifu-tips.json */
 63 |                 initModel({
 64 |                     "waifu": {
 65 |                         "console_open_msg": ["哈哈,你打开了控制台,是想要看看我的秘密吗?"],
 66 |                         "copy_message": ["你都复制了些什么呀,转载要记得加上出处哦"],
 67 |                         "screenshot_message": ["照好了嘛,是不是很可爱呢?"],
 68 |                         "hidden_message": ["我们还能再见面的吧…"],
 69 |                         "load_rand_textures": ["我还没有其他衣服呢", "我的新衣服好看嘛"],
 70 |                         "hour_tips": {
 71 |                             "t5-7": ["早上好!一日之计在于晨,美好的一天就要开始了"],
 72 |                             "t7-11": ["上午好!工作顺利嘛,不要久坐,多起来走动走动哦!"],
 73 |                             "t11-14": ["中午了,工作了一个上午,现在是午餐时间!"],
 74 |                             "t14-17": ["午后很容易犯困呢,今天的运动目标完成了吗?"],
 75 |                             "t17-19": ["傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~"],
 76 |                             "t19-21": ["晚上好,今天过得怎么样?"],
 77 |                             "t21-23": ["已经这么晚了呀,早点休息吧,晚安~"],
 78 |                             "t23-5": ["你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"],
 79 |                             "default": ["嗨~ 快来逗我玩吧!"]
 80 |                         },
 81 |                         "referrer_message": {
 82 |                             "localhost": ["欢迎阅读<span style=\"color:#0099cc;\">『", "』</span>", " - "],
 83 |                             "baidu": ["Hello! 来自 百度搜索 的朋友<br>你是搜索 <span style=\"color:#0099cc;\">", "</span> 找到的我吗?"],
 84 |                             "so": ["Hello! 来自 360搜索 的朋友<br>你是搜索 <span style=\"color:#0099cc;\">", "</span> 找到的我吗?"],
 85 |                             "google": ["Hello! 来自 谷歌搜索 的朋友<br>欢迎阅读<span style=\"color:#0099cc;\">『", "』</span>", " - "],
 86 |                             "default": ["Hello! 来自 <span style=\"color:#0099cc;\">", "</span> 的朋友"],
 87 |                             "none": ["欢迎阅读<span style=\"color:#0099cc;\">『", "』</span>", " - "]
 88 |                         },
 89 |                         "referrer_hostname": {
 90 |                             "example.com": ["示例网站"],
 91 |                             "www.fghrsh.net": ["FGHRSH 的博客"]
 92 |                         },
 93 |                         "model_message": {
 94 |                             "1": ["来自 Potion Maker 的 Pio 酱 ~"],
 95 |                             "2": ["来自 Potion Maker 的 Tia 酱 ~"]  
 96 |                         },
 97 |                         "hitokoto_api_message": {
 98 |                             "lwl12.com": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>", ",是 <span style=\"color:#0099cc;\">{creator}</span> 投稿的", "。"],
 99 |                             "fghrsh.net": ["这句一言出处是 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">FGHRSH</span> 在 {date} 收藏的!"],
100 |                             "jinrishici.com": ["这句诗词出自 <span style=\"color:#0099cc;\">《{title}》</span>,是 {dynasty}诗人 {author} 创作的!"],
101 |                             "hitokoto.cn": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">{creator}</span> 在 hitokoto.cn 投稿的。"]
102 |                         }
103 |                     },
104 |                     "mouseover": [
105 |                         { "selector": ".container a[href^='http']", "text": ["要看看 <span style=\"color:#0099cc;\">{text}</span> 么?"] },
106 |                         { "selector": ".fui-home", "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦"] },
107 |                         { "selector": ".fui-chat", "text": ["一言一语,一颦一笑。一字一句,一颗赛艇。"] },
108 |                         { "selector": ".fui-eye", "text": ["嗯··· 要切换 看板娘 吗?"] },
109 |                         { "selector": ".fui-user", "text": ["喜欢换装 Play 吗?"] },
110 |                         { "selector": ".fui-photo", "text": ["要拍张纪念照片吗?"] },
111 |                         { "selector": ".fui-info-circle", "text": ["这里有关于我的信息呢"] },
112 |                         { "selector": ".fui-cross", "text": ["你不喜欢我了吗..."] },
113 |                         { "selector": "#tor_show", "text": ["翻页比较麻烦吗,点击可以显示这篇文章的目录呢"] },
114 |                         { "selector": "#comment_go", "text": ["想要去评论些什么吗?"] },
115 |                         { "selector": "#night_mode", "text": ["深夜时要爱护眼睛呀"] },
116 |                         { "selector": "#qrcode", "text": ["手机扫一下就能继续看,很方便呢"] },
117 |                         { "selector": ".comment_reply", "text": ["要吐槽些什么呢"] },
118 |                         { "selector": "#back-to-top", "text": ["回到开始的地方吧"] },
119 |                         { "selector": "#author", "text": ["该怎么称呼你呢"] },
120 |                         { "selector": "#mail", "text": ["留下你的邮箱,不然就是无头像人士了"] },
121 |                         { "selector": "#url", "text": ["你的家在哪里呢,好让我去参观参观"] },
122 |                         { "selector": "#textarea", "text": ["认真填写哦,垃圾评论是禁止事项"] },
123 |                         { "selector": ".OwO-logo", "text": ["要插入一个表情吗"] },
124 |                         { "selector": "#csubmit", "text": ["要[提交]^(Commit)了吗,首次评论需要审核,请耐心等待~"] },
125 |                         { "selector": ".ImageBox", "text": ["点击图片可以放大呢"] },
126 |                         { "selector": "input[name=s]", "text": ["找不到想看的内容?搜索看看吧"] },
127 |                         { "selector": ".previous", "text": ["去上一页看看吧"] },
128 |                         { "selector": ".next", "text": ["去下一页看看吧"] },
129 |                         { "selector": ".dropdown-toggle", "text": ["这里是菜单"] },
130 |                         { "selector": "c-player a.play-icon", "text": ["想要听点音乐吗"] },
131 |                         { "selector": "c-player div.time", "text": ["在这里可以调整<span style=\"color:#0099cc;\">播放进度</span>呢"] },
132 |                         { "selector": "c-player div.volume", "text": ["在这里可以调整<span style=\"color:#0099cc;\">音量</span>呢"] },
133 |                         { "selector": "c-player div.list-button", "text": ["<span style=\"color:#0099cc;\">播放列表</span>里都有什么呢"] },
134 |                         { "selector": "c-player div.lyric-button", "text": ["有<span style=\"color:#0099cc;\">歌词</span>的话就能跟着一起唱呢"] },
135 |                         { "selector": ".waifu #live2d", "text": ["干嘛呢你,快把手拿开", "鼠…鼠标放错地方了!"] }
136 |                     ],
137 |                     "click": [
138 |                         {
139 |                             "selector": ".waifu #live2d",
140 |                             "text": [
141 |                                 "是…是不小心碰到了吧",
142 |                                 "萝莉控是什么呀",
143 |                                 "你看到我的小熊了吗",
144 |                                 "再摸的话我可要报警了!⌇●﹏●⌇",
145 |                                 "110吗,这里有个变态一直在摸我(ó﹏ò。)"
146 |                             ]
147 |                         }
148 |                     ],
149 |                     "seasons": [
150 |                         { "date": "01/01", "text": ["<span style=\"color:#0099cc;\">元旦</span>了呢,新的一年又开始了,今年是{year}年~"] },
151 |                         { "date": "02/14", "text": ["又是一年<span style=\"color:#0099cc;\">情人节</span>,{year}年找到对象了嘛~"] },
152 |                         { "date": "03/08", "text": ["今天是<span style=\"color:#0099cc;\">妇女节</span>!"] },
153 |                         { "date": "03/12", "text": ["今天是<span style=\"color:#0099cc;\">植树节</span>,要保护环境呀"] },
154 |                         { "date": "04/01", "text": ["悄悄告诉你一个秘密~<span style=\"background-color:#34495e;\">今天是愚人节,不要被骗了哦~</span>"] },
155 |                         { "date": "05/01", "text": ["今天是<span style=\"color:#0099cc;\">五一劳动节</span>,计划好假期去哪里了吗~"] },
156 |                         { "date": "06/01", "text": ["<span style=\"color:#0099cc;\">儿童节</span>了呢,快活的时光总是短暂,要是永远长不大该多好啊…"] },
157 |                         { "date": "09/03", "text": ["<span style=\"color:#0099cc;\">中国人民抗日战争胜利纪念日</span>,铭记历史、缅怀先烈、珍爱和平、开创未来。"] },
158 |                         { "date": "09/10", "text": ["<span style=\"color:#0099cc;\">教师节</span>,在学校要给老师问声好呀~"] },
159 |                         { "date": "10/01", "text": ["<span style=\"color:#0099cc;\">国庆节</span>,新中国已经成立69年了呢"] },
160 |                         { "date": "11/05-11/12", "text": ["今年的<span style=\"color:#0099cc;\">双十一</span>是和谁一起过的呢~"] },
161 |                         { "date": "12/20-12/31", "text": ["这几天是<span style=\"color:#0099cc;\">圣诞节</span>,主人肯定又去剁手买买买了~"] }
162 |                     ]
163 |                 });
164 |             }});
165 |     }});
166 |     </script>
167 | </body>
168 | </html>
169 |     
170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /assets/flat-ui-icons-regular.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | { 7 | "fontFamily": "flat-ui-icons", 8 | "majorVersion": 1, 9 | "minorVersion": 1, 10 | "fontURL": "http://designmodo.com/flat", 11 | "designer": "Sergey Shmidt", 12 | "designerURL": "http://designmodo.com", 13 | "license": "Attribution-NonCommercial-NoDerivs 3.0 Unported", 14 | "licenseURL": "http://creativecommons.org/licenses/by-nc-nd/3.0/", 15 | "version": "Version 1.1", 16 | "fontId": "flat-ui-icons", 17 | "psName": "flat-ui-icons", 18 | "subFamily": "Regular", 19 | "fullName": "flat-ui-icons", 20 | "description": "Generated by IcoMoon" 21 | } 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | --------------------------------------------------------------------------------