@@ -43,6 +43,8 @@ interface Tips {
43
43
hitokoto : string ;
44
44
welcome : string ;
45
45
referrer : string ;
46
+ hoverBody : string ;
47
+ tapBody : string ;
46
48
} ;
47
49
/**
48
50
* Time configuration.
@@ -85,6 +87,21 @@ function registerEventListener(tips: Tips) {
85
87
let userAction = false ;
86
88
let userActionTimer : any ;
87
89
const messageArray = tips . message . default ;
90
+ tips . seasons . forEach ( ( { date, text } ) => {
91
+ const now = new Date ( ) ,
92
+ after = date . split ( '-' ) [ 0 ] ,
93
+ before = date . split ( '-' ) [ 1 ] || after ;
94
+ if (
95
+ Number ( after . split ( '/' ) [ 0 ] ) <= now . getMonth ( ) + 1 &&
96
+ now . getMonth ( ) + 1 <= Number ( before . split ( '/' ) [ 0 ] ) &&
97
+ Number ( after . split ( '/' ) [ 1 ] ) <= now . getDate ( ) &&
98
+ now . getDate ( ) <= Number ( before . split ( '/' ) [ 1 ] )
99
+ ) {
100
+ text = randomSelection ( text ) ;
101
+ text = ( text as string ) . replace ( '{year}' , String ( now . getFullYear ( ) ) ) ;
102
+ messageArray . push ( text ) ;
103
+ }
104
+ } ) ;
88
105
let lastHoverElement : any ;
89
106
window . addEventListener ( 'mousemove' , ( ) => ( userAction = true ) ) ;
90
107
window . addEventListener ( 'keydown' , ( ) => ( userAction = true ) ) ;
@@ -99,7 +116,7 @@ function registerEventListener(tips: Tips) {
99
116
} , 20000 ) ;
100
117
}
101
118
} , 1000 ) ;
102
- showMessage ( welcomeMessage ( tips . time , tips . message . welcome , tips . message . referrer ) , 7000 , 11 ) ;
119
+
103
120
window . addEventListener ( 'mouseover' , ( event ) => {
104
121
// eslint-disable-next-line prefer-const
105
122
for ( let { selector, text } of tips . mouseover ) {
@@ -128,23 +145,16 @@ function registerEventListener(tips: Tips) {
128
145
return ;
129
146
}
130
147
} ) ;
131
- tips . seasons . forEach ( ( { date, text } ) => {
132
- const now = new Date ( ) ,
133
- after = date . split ( '-' ) [ 0 ] ,
134
- before = date . split ( '-' ) [ 1 ] || after ;
135
- if (
136
- Number ( after . split ( '/' ) [ 0 ] ) <= now . getMonth ( ) + 1 &&
137
- now . getMonth ( ) + 1 <= Number ( before . split ( '/' ) [ 0 ] ) &&
138
- Number ( after . split ( '/' ) [ 1 ] ) <= now . getDate ( ) &&
139
- now . getDate ( ) <= Number ( before . split ( '/' ) [ 1 ] )
140
- ) {
141
- text = randomSelection ( text ) ;
142
- text = ( text as string ) . replace ( '{year}' , String ( now . getFullYear ( ) ) ) ;
143
- messageArray . push ( text ) ;
144
- }
148
+ window . addEventListener ( 'live2d:hoverbody' , ( ) => {
149
+ const text = randomSelection ( tips . message . hoverBody ) ;
150
+ showMessage ( text , 4000 , 8 , false ) ;
151
+ } ) ;
152
+ window . addEventListener ( 'live2d:tapbody' , ( ) => {
153
+ const text = randomSelection ( tips . message . tapBody ) ;
154
+ showMessage ( text , 4000 , 9 ) ;
145
155
} ) ;
146
156
147
- const devtools = ( ) => { } ;
157
+ const devtools = ( ) => { } ;
148
158
console . log ( '%c' , devtools ) ;
149
159
devtools . toString = ( ) => {
150
160
showMessage ( tips . message . console , 6000 , 9 ) ;
@@ -164,7 +174,7 @@ function registerEventListener(tips: Tips) {
164
174
*/
165
175
async function loadWidget ( config : Config ) {
166
176
localStorage . removeItem ( 'waifu-display' ) ;
167
- sessionStorage . removeItem ( 'waifu-text ' ) ;
177
+ sessionStorage . removeItem ( 'waifu-message-priority ' ) ;
168
178
document . body . insertAdjacentHTML (
169
179
'beforeend' ,
170
180
`<div id="waifu">
@@ -182,6 +192,7 @@ async function loadWidget(config: Config) {
182
192
tips = await response . json ( ) ;
183
193
models = tips . models ;
184
194
registerEventListener ( tips ) ;
195
+ showMessage ( welcomeMessage ( tips . time , tips . message . welcome , tips . message . referrer ) , 7000 , 11 ) ;
185
196
}
186
197
const model = await ModelManager . initCheck ( config , models ) ;
187
198
await model . loadModel ( '' ) ;
0 commit comments