@mlikiowa/nanaeo 1.0.1702968347635 → 1.0.1702969131476
Sign up to get free protection for your applications and to get access to all the features.
- package/2022/08/04/NewBlog/index.html +1 -3473
- package/2022/08/13/GaussWave/index.html +1 -3407
- package/about/index.html +1 -3236
- package/archives/2022/08/index.html +1 -3411
- package/archives/2022/index.html +1 -3411
- package/archives/index.html +1 -3308
- package/categories/DevLog/index.html +1 -3351
- package/categories/SiteLog/index.html +1 -3351
- package/categories/index.html +1 -3174
- package/content.json +1 -1
- package/css/Readme.html +1 -9
- package/css/first.css +2 -1504
- package/css/style.css +2 -7106
- package/friends/index.html +1 -3661
- package/index.html +1 -3421
- package/js/app.js +2 -1223
- package/js/plugins/aplayer.js +2 -186
- package/js/plugins/parallax.js +2 -191
- package/js/plugins/rightMenu.js +2 -577
- package/js/plugins/rightMenus.js +2 -618
- package/js/plugins/tags/contributors.js +2 -92
- package/js/plugins/tags/friends.js +2 -93
- package/js/plugins/tags/sites.js +2 -96
- package/js/search/hexo.js +2 -192
- package/maps/css/first.css.map +1 -0
- package/maps/css/style.css.map +1 -0
- package/maps/js/app.js.map +1 -0
- package/maps/js/plugins/aplayer.js.map +1 -0
- package/maps/js/plugins/parallax.js.map +1 -0
- package/maps/js/plugins/rightMenu.js.map +1 -0
- package/maps/js/plugins/rightMenus.js.map +1 -0
- package/maps/js/plugins/tags/contributors.js.map +1 -0
- package/maps/js/plugins/tags/friends.js.map +1 -0
- package/maps/js/plugins/tags/sites.js.map +1 -0
- package/maps/js/search/hexo.js.map +1 -0
- package/maps/volantis-sw.js.map +1 -0
- package/package.json +1 -1
- package/tags/DevLog/index.html +1 -3351
- package/tags/Gauss/index.html +1 -3351
- package/tags/Hexo/index.html +1 -3351
- package/tags/HexoThemes/index.html +1 -3351
- package/tags/SiteLog/index.html +1 -3351
- package/tags/index.html +1 -3159
- package/volantis-sw.js +2 -797
package/js/plugins/rightMenu.js
CHANGED
@@ -1,577 +1,2 @@
|
|
1
|
-
const RightMenu = (() => {
|
2
|
-
|
3
|
-
rightMenuConfig = volantis.GLOBAL_CONFIG.plugins.rightmenu,
|
4
|
-
messageRightMenu = volantis.GLOBAL_CONFIG.plugins.message.enable && volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable;
|
5
|
-
|
6
|
-
const
|
7
|
-
fn = {},
|
8
|
-
_rightMenuWrapper = document.getElementById('rightmenu-wrapper'),
|
9
|
-
_rightMenuContent = document.getElementById('rightmenu-content'),
|
10
|
-
_printHtml = document.getElementById('printHtml'),
|
11
|
-
_menuMusic = document.getElementById('menuMusic'),
|
12
|
-
_readingModel = document.getElementById('readingModel'),
|
13
|
-
_readBkg = document.getElementById('read_bkg');
|
14
|
-
|
15
|
-
const
|
16
|
-
_menuLoad = document.querySelectorAll('.menuLoad-Content'),
|
17
|
-
_menuOption = document.querySelector('.menu-Option'),
|
18
|
-
_searchWord = document.querySelector('.menu-Option[data-fn-type="searchWord"]'),
|
19
|
-
_copyText = document.querySelector('.menu-Option[data-fn-type="copyText"]'),
|
20
|
-
_copyPaste = document.querySelector('.menu-Option[data-fn-type="copyPaste"]'),
|
21
|
-
_copySelect = document.querySelector('.menu-Option[data-fn-type="copySelect"]'),
|
22
|
-
_copyCut = document.querySelector('.menu-Option[data-fn-type="copyCut"]'),
|
23
|
-
_copyHref = document.querySelector('.menu-Option[data-fn-type="copyHref"]'),
|
24
|
-
_copySrc = document.querySelector('.menu-Option[data-fn-type="copySrc"]'),
|
25
|
-
_copyImg = document.querySelector('.menu-Option[data-fn-type="copyImg"]'),
|
26
|
-
_openTab = document.querySelector('.menu-Option[data-fn-type="openTab"]'),
|
27
|
-
_backward = document.querySelector('#menuMusic .backward'),
|
28
|
-
_toggle = document.querySelector('#menuMusic .toggle'),
|
29
|
-
_forward = document.querySelector('#menuMusic .forward');
|
30
|
-
|
31
|
-
const urlRegx = /^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
|
32
|
-
|
33
|
-
fn.init = () => {
|
34
|
-
DOMController.visible(_menuMusic, false);
|
35
|
-
DOMController.visible(_menuOption, false);
|
36
|
-
if (_readBkg) _readBkg.parentNode.removeChild(_readBkg);
|
37
|
-
|
38
|
-
const readBkg = document.createElement("div");
|
39
|
-
readBkg.className = "common_read_bkg common_read_hide";
|
40
|
-
readBkg.id = "read_bkg";
|
41
|
-
window.document.body.appendChild(readBkg);
|
42
|
-
}
|
43
|
-
|
44
|
-
fn.initEvent = () => {
|
45
|
-
window.document.oncontextmenu = (event) => {
|
46
|
-
if (event.ctrlKey || document.body.offsetWidth <= 500) {
|
47
|
-
fn.hideMenu();
|
48
|
-
return true;
|
49
|
-
}
|
50
|
-
return fn.popMenu(event);
|
51
|
-
}
|
52
|
-
|
53
|
-
_rightMenuWrapper.oncontextmenu = (event) => {
|
54
|
-
event.stopPropagation();
|
55
|
-
event.preventDefault();
|
56
|
-
return false;
|
57
|
-
}
|
58
|
-
|
59
|
-
window.removeEventListener('blur', fn.hideMenu);
|
60
|
-
window.addEventListener('blur', fn.hideMenu);
|
61
|
-
document.body.removeEventListener('click', fn.hideMenu);
|
62
|
-
document.body.addEventListener('click', fn.hideMenu);
|
63
|
-
|
64
|
-
if (_forward && _toggle && _forward) {
|
65
|
-
_backward.onclick = (e) => {
|
66
|
-
e.preventDefault();
|
67
|
-
e.stopPropagation();
|
68
|
-
RightMenuAplayer.aplayerBackward();
|
69
|
-
}
|
70
|
-
_toggle.onclick = (e) => {
|
71
|
-
e.preventDefault();
|
72
|
-
e.stopPropagation();
|
73
|
-
RightMenuAplayer.aplayerToggle();
|
74
|
-
}
|
75
|
-
_forward.onclick = (e) => {
|
76
|
-
e.preventDefault();
|
77
|
-
e.stopPropagation();
|
78
|
-
RightMenuAplayer.aplayerForward();
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
// 菜单位置设定
|
84
|
-
fn.popMenu = (event) => {
|
85
|
-
let mouseClientX = event.clientX;
|
86
|
-
let mouseClientY = event.clientY;
|
87
|
-
let screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
88
|
-
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
89
|
-
|
90
|
-
try {
|
91
|
-
fn.setMenuItem(event);
|
92
|
-
DOMController.visible(_rightMenuWrapper);
|
93
|
-
_rightMenuWrapper.focus();
|
94
|
-
_rightMenuWrapper.style.zIndex = '-2147483648';
|
95
|
-
let menuWidth = _rightMenuContent.offsetWidth;
|
96
|
-
let menuHeight = _rightMenuContent.offsetHeight;
|
97
|
-
let showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
|
98
|
-
let showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
|
99
|
-
showTop = mouseClientY + menuHeight > screenHeight && showTop < menuHeight && mouseClientY < menuHeight ?
|
100
|
-
showTop + (screenHeight - menuHeight - showTop - 10) : showTop;
|
101
|
-
_rightMenuWrapper.style.left = showLeft + "px";
|
102
|
-
_rightMenuWrapper.style.top = showTop + "px";
|
103
|
-
_rightMenuWrapper.style.zIndex = '2147483648';
|
104
|
-
if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) fn.showMessage();
|
105
|
-
} catch (error) {
|
106
|
-
_rightMenuWrapper.blur();
|
107
|
-
console.error(error);
|
108
|
-
return true;
|
109
|
-
}
|
110
|
-
|
111
|
-
return false;
|
112
|
-
}
|
113
|
-
|
114
|
-
// 消息提示
|
115
|
-
fn.showMessage = () => {
|
116
|
-
const NoticeRightMenu = localStorage.getItem('NoticeRightMenu') === 'true';
|
117
|
-
if (messageRightMenu && !NoticeRightMenu)
|
118
|
-
VolantisApp.message('右键菜单', '唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>', {
|
119
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red',
|
120
|
-
time: 9000
|
121
|
-
}, () => {
|
122
|
-
localStorage.setItem('NoticeRightMenu', 'true')
|
123
|
-
});
|
124
|
-
}
|
125
|
-
|
126
|
-
// 菜单项设置
|
127
|
-
fn.setMenuItem = (event) => {
|
128
|
-
let optionFlag = false;
|
129
|
-
const eventTarget = event.target;
|
130
|
-
const selectText = window.getSelection().toString();
|
131
|
-
DOMController.visible(_openTab, false); // 隐藏新标签页打开
|
132
|
-
|
133
|
-
// 判断是否是输入框
|
134
|
-
if (eventTarget.tagName.toLowerCase() === 'input' || eventTarget.tagName.toLowerCase() === 'textarea') {
|
135
|
-
const inputStr = eventTarget.value;
|
136
|
-
|
137
|
-
// 全选
|
138
|
-
if (inputStr.length > 0) {
|
139
|
-
DOMController.visible(_copySelect);
|
140
|
-
_copySelect.onclick = () => {
|
141
|
-
event.preventDefault();
|
142
|
-
eventTarget.select();
|
143
|
-
}
|
144
|
-
} else {
|
145
|
-
DOMController.visible(_copySelect, false);
|
146
|
-
}
|
147
|
-
|
148
|
-
// 剪切
|
149
|
-
if (selectText) {
|
150
|
-
DOMController.visible(_copyCut);
|
151
|
-
_copyCut.onclick = () => {
|
152
|
-
const statrPos = eventTarget.selectionStart;
|
153
|
-
const endPos = eventTarget.selectionEnd;
|
154
|
-
fn.copyString(selectText);
|
155
|
-
eventTarget.value = inputStr.substring(0, statrPos) + inputStr.substring(endPos, inputStr.length);
|
156
|
-
eventTarget.selectionStart = statrPos;
|
157
|
-
eventTarget.selectionEnd = statrPos;
|
158
|
-
eventTarget.focus();
|
159
|
-
}
|
160
|
-
} else {
|
161
|
-
DOMController.visible(_copyCut, false);
|
162
|
-
}
|
163
|
-
|
164
|
-
// 粘贴
|
165
|
-
fn.readClipboard().then(text => {
|
166
|
-
// 如果剪切板存在内容
|
167
|
-
if (!!text) {
|
168
|
-
DOMController.visible(_copyPaste);
|
169
|
-
_copyPaste.onclick = () => {
|
170
|
-
fn.insertAtCaret(eventTarget, text);
|
171
|
-
}
|
172
|
-
} else {
|
173
|
-
DOMController.visible(_copyPaste, false);
|
174
|
-
}
|
175
|
-
}).catch((err) => {
|
176
|
-
console.error(err);
|
177
|
-
DOMController.visible(_copyPaste, false);
|
178
|
-
});
|
179
|
-
} else {
|
180
|
-
DOMController.visible(_copySelect, false);
|
181
|
-
DOMController.visible(_copyPaste, false);
|
182
|
-
DOMController.visible(_copyCut, false);
|
183
|
-
}
|
184
|
-
|
185
|
-
// 新标签打开链接
|
186
|
-
const eventHref = eventTarget.href;
|
187
|
-
if (!!eventHref && urlRegx.test(eventHref)) {
|
188
|
-
optionFlag = true;
|
189
|
-
DOMController.visible(_copyHref);
|
190
|
-
DOMController.visible(_openTab);
|
191
|
-
if (_copyHref) _copyHref.onclick = () => {
|
192
|
-
fn.copyString(eventHref);
|
193
|
-
}
|
194
|
-
_openTab.onclick = () => {
|
195
|
-
window.open(eventHref);
|
196
|
-
}
|
197
|
-
} else {
|
198
|
-
DOMController.visible(_copyHref, false);
|
199
|
-
}
|
200
|
-
|
201
|
-
// 新标签打开图片 & 复制图片链接
|
202
|
-
const eventSrc = eventTarget.currentSrc;
|
203
|
-
if (!!eventSrc && urlRegx.test(eventSrc)) {
|
204
|
-
optionFlag = true;
|
205
|
-
DOMController.visible(_copySrc);
|
206
|
-
DOMController.visible(_openTab);
|
207
|
-
|
208
|
-
_copySrc.onclick = () => {
|
209
|
-
fn.copyString(eventSrc);
|
210
|
-
}
|
211
|
-
|
212
|
-
_openTab.onclick = () => {
|
213
|
-
window.open(eventSrc);
|
214
|
-
}
|
215
|
-
} else {
|
216
|
-
DOMController.visible(_copySrc, false);
|
217
|
-
}
|
218
|
-
|
219
|
-
// 复制图片
|
220
|
-
if (!!eventSrc && urlRegx.test(eventSrc) && eventSrc.trimEnd().endsWith('.png')) {
|
221
|
-
optionFlag = true;
|
222
|
-
DOMController.visible(_copyImg);
|
223
|
-
|
224
|
-
_copyImg.onclick = () => {
|
225
|
-
fn.writeClipImg(event, flag => {
|
226
|
-
if (flag && messageRightMenu) VolantisApp.message('系统提示', '图片复制成功!', {
|
227
|
-
icon: rightMenuConfig.faicon + ' fa-images'
|
228
|
-
});
|
229
|
-
}, (error) => {
|
230
|
-
if (messageRightMenu) VolantisApp.message('系统提示', '复制失败:' + error, {
|
231
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red'
|
232
|
-
});
|
233
|
-
})
|
234
|
-
}
|
235
|
-
} else {
|
236
|
-
DOMController.visible(_copyImg, false);
|
237
|
-
}
|
238
|
-
|
239
|
-
// 复制文本
|
240
|
-
if (selectText) {
|
241
|
-
optionFlag = true;
|
242
|
-
DOMController.visible(_copyText);
|
243
|
-
DOMController.visible(_searchWord);
|
244
|
-
|
245
|
-
_copyText.onclick = () => {
|
246
|
-
fn.copyString(selectText);
|
247
|
-
}
|
248
|
-
|
249
|
-
!!_searchWord && (_searchWord.onclick = () => {
|
250
|
-
OpenSearch(selectText);
|
251
|
-
})
|
252
|
-
} else {
|
253
|
-
DOMController.visible(_copyText, false);
|
254
|
-
DOMController.visible(_searchWord, false);
|
255
|
-
}
|
256
|
-
|
257
|
-
// 打印
|
258
|
-
const _printArticle = document.querySelector('#post.article') || null;
|
259
|
-
const pathName = window.location.pathname;
|
260
|
-
if (!!_printArticle) {
|
261
|
-
DOMController.visible(_printHtml);
|
262
|
-
DOMController.visible(_readingModel);
|
263
|
-
|
264
|
-
if (_printHtml) {
|
265
|
-
_printHtml.onclick = () => {
|
266
|
-
if (window.location.pathname === pathName) {
|
267
|
-
const message = '是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>';
|
268
|
-
if (messageRightMenu) VolantisApp.question('', message, {}, () => {
|
269
|
-
fn.printHtml();
|
270
|
-
})
|
271
|
-
} else {
|
272
|
-
fn.hideMenu();
|
273
|
-
}
|
274
|
-
}
|
275
|
-
}
|
276
|
-
|
277
|
-
if (_readingModel) {
|
278
|
-
_readingModel.onclick = () => {
|
279
|
-
if (window.location.pathname === pathName) {
|
280
|
-
fn.readingModel();
|
281
|
-
} else {
|
282
|
-
fn.readingModel();
|
283
|
-
}
|
284
|
-
}
|
285
|
-
}
|
286
|
-
|
287
|
-
} else {
|
288
|
-
DOMController.visible(_printHtml, false);
|
289
|
-
DOMController.visible(_readingModel, false);
|
290
|
-
}
|
291
|
-
|
292
|
-
if (volantis.GLOBAL_CONFIG.plugins.aplayer.enable
|
293
|
-
&& typeof RightMenuAplayer !== 'undefined'
|
294
|
-
&& RightMenuAplayer.APlayer.player !== undefined) {
|
295
|
-
if (rightMenuConfig.music_alwaysShow) {
|
296
|
-
DOMController.visible(_menuMusic);
|
297
|
-
} else if (RightMenuAplayer.APlayer.status === 'play' || RightMenuAplayer.APlayer.status === 'undefined') {
|
298
|
-
optionFlag = true;
|
299
|
-
DOMController.visible(_menuMusic);
|
300
|
-
} else {
|
301
|
-
DOMController.visible(_menuMusic, false);
|
302
|
-
}
|
303
|
-
} else {
|
304
|
-
DOMController.visible(_menuMusic, false);
|
305
|
-
}
|
306
|
-
|
307
|
-
_menuLoad.forEach(ele => {
|
308
|
-
DOMController.visible(ele, !optionFlag);
|
309
|
-
})
|
310
|
-
|
311
|
-
if (volantis.GLOBAL_CONFIG.plugins.aplayer.enable
|
312
|
-
&& rightMenuConfig.layout.includes('music')) {
|
313
|
-
RightMenuAplayer.checkAPlayer();
|
314
|
-
}
|
315
|
-
}
|
316
|
-
|
317
|
-
// 隐藏菜单
|
318
|
-
fn.hideMenu = () => {
|
319
|
-
DOMController.visible(_rightMenuWrapper, false);
|
320
|
-
}
|
321
|
-
|
322
|
-
// 复制字符串
|
323
|
-
fn.copyString = (str) => {
|
324
|
-
VolantisApp.utilWriteClipText(str)
|
325
|
-
.then(() => {
|
326
|
-
if (messageRightMenu) {
|
327
|
-
VolantisApp.messageCopyright();
|
328
|
-
}
|
329
|
-
}).catch(e => {
|
330
|
-
if (messageRightMenu) {
|
331
|
-
VolantisApp.message('系统提示', e, {
|
332
|
-
icon: rightMenuConfig.faicon + ' fa-exclamation-square red'
|
333
|
-
});
|
334
|
-
}
|
335
|
-
})
|
336
|
-
}
|
337
|
-
|
338
|
-
// 写入文本到剪切板
|
339
|
-
fn.writeClipText = (str) => {
|
340
|
-
try {
|
341
|
-
return navigator.clipboard
|
342
|
-
.writeText(str)
|
343
|
-
.then(() => {
|
344
|
-
return Promise.resolve()
|
345
|
-
})
|
346
|
-
.catch(err => {
|
347
|
-
return Promise.reject(err)
|
348
|
-
})
|
349
|
-
} catch (e) {
|
350
|
-
const input = document.createElement('input');
|
351
|
-
input.setAttribute('readonly', 'readonly');
|
352
|
-
document.body.appendChild(input);
|
353
|
-
input.setAttribute('value', str);
|
354
|
-
input.select();
|
355
|
-
try {
|
356
|
-
let result = document.execCommand('copy')
|
357
|
-
document.body.removeChild(input);
|
358
|
-
if (!result || result === 'unsuccessful') {
|
359
|
-
return Promise.reject('复制文本失败!')
|
360
|
-
} else {
|
361
|
-
return Promise.resolve()
|
362
|
-
}
|
363
|
-
} catch (e) {
|
364
|
-
document.body.removeChild(input);
|
365
|
-
return Promise.reject(
|
366
|
-
'当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!'
|
367
|
-
)
|
368
|
-
}
|
369
|
-
}
|
370
|
-
}
|
371
|
-
|
372
|
-
// 写入图片到剪切板
|
373
|
-
fn.writeClipImg = async function (event, success, error) {
|
374
|
-
const eventSrc = rightMenuConfig.customPicUrl.enable ?
|
375
|
-
event.target.currentSrc.replace(rightMenuConfig.customPicUrl.old, rightMenuConfig.customPicUrl.new) :
|
376
|
-
event.target.currentSrc;
|
377
|
-
const parentElement = event.target.parentElement;
|
378
|
-
try {
|
379
|
-
const data = await fetch(eventSrc);
|
380
|
-
const blob = await data.blob();
|
381
|
-
await navigator.clipboard
|
382
|
-
.write([
|
383
|
-
new ClipboardItem({
|
384
|
-
[blob.type]: blob
|
385
|
-
})
|
386
|
-
]).then(() => {
|
387
|
-
success(true);
|
388
|
-
}, (e) => {
|
389
|
-
console.error('图片复制失败:', e);
|
390
|
-
error(e);
|
391
|
-
});
|
392
|
-
} catch (e) {
|
393
|
-
const dom = document;
|
394
|
-
try {
|
395
|
-
if (dom.body.createTextRange) {
|
396
|
-
const textRange = document.body.createTextRange();
|
397
|
-
textRange.moveToElementText(parentElement);
|
398
|
-
textRange.select();
|
399
|
-
} else if (window.getSelection) {
|
400
|
-
const selection = window.getSelection();
|
401
|
-
const range = document.createRange();
|
402
|
-
range.selectNodeContents(parentElement);
|
403
|
-
selection.removeAllRanges();
|
404
|
-
selection.addRange(range);
|
405
|
-
}
|
406
|
-
document.execCommand('copy');
|
407
|
-
window.getSelection().removeAllRanges();
|
408
|
-
success(false);
|
409
|
-
} catch (e) {
|
410
|
-
console.error(e);
|
411
|
-
error('不支持复制当前图片!');
|
412
|
-
}
|
413
|
-
}
|
414
|
-
}
|
415
|
-
|
416
|
-
// 请求读取剪切板
|
417
|
-
fn.readClipboard = async () => {
|
418
|
-
const result = await navigator.permissions.query({
|
419
|
-
name: 'clipboard-read'
|
420
|
-
});
|
421
|
-
if (result.state === 'granted' || result.state === 'prompt') {
|
422
|
-
// 修改为 .read() 可以获取剪切板中的文字/图片
|
423
|
-
// 返回的是 ClipboardItem
|
424
|
-
return navigator.clipboard
|
425
|
-
.readText()
|
426
|
-
.then(text => text)
|
427
|
-
.catch(err => Promise.reject(err));
|
428
|
-
}
|
429
|
-
return Promise.reject(result);
|
430
|
-
}
|
431
|
-
|
432
|
-
// 粘贴文本
|
433
|
-
fn.insertAtCaret = (elemt, value) => {
|
434
|
-
const startPos = elemt.selectionStart,
|
435
|
-
endPos = elemt.selectionEnd;
|
436
|
-
if (document.selection) {
|
437
|
-
elemt.focus();
|
438
|
-
var sel = document.selection.createRange();
|
439
|
-
sel.text = value;
|
440
|
-
elemt.focus();
|
441
|
-
} else {
|
442
|
-
if (startPos || startPos == '0') {
|
443
|
-
var scrollTop = elemt.scrollTop;
|
444
|
-
elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value.length);
|
445
|
-
elemt.focus();
|
446
|
-
elemt.selectionStart = startPos + value.length;
|
447
|
-
elemt.selectionEnd = startPos + value.length;
|
448
|
-
elemt.scrollTop = scrollTop;
|
449
|
-
} else {
|
450
|
-
elemt.value += value;
|
451
|
-
elemt.focus();
|
452
|
-
}
|
453
|
-
}
|
454
|
-
}
|
455
|
-
|
456
|
-
// 执行打印页面
|
457
|
-
fn.printHtml = () => {
|
458
|
-
if (volantis.isReadModel) fn.readingModel();
|
459
|
-
DOMController.setAttribute('details', 'open', 'true');
|
460
|
-
DOMController.remove('.cus-article-bkg');
|
461
|
-
DOMController.remove('.iziToast-overlay');
|
462
|
-
DOMController.remove('.iziToast-wrapper');
|
463
|
-
DOMController.remove('.prev-next');
|
464
|
-
DOMController.remove('footer');
|
465
|
-
DOMController.remove('#l_header');
|
466
|
-
DOMController.remove('#l_cover');
|
467
|
-
DOMController.remove('#l_side');
|
468
|
-
DOMController.remove('#comments');
|
469
|
-
DOMController.remove('#s-top');
|
470
|
-
DOMController.remove('#BKG');
|
471
|
-
DOMController.remove('#rightmenu-wrapper');
|
472
|
-
DOMController.remove('.nav-tabs');
|
473
|
-
DOMController.remove('.parallax-mirror');
|
474
|
-
DOMController.remove('.new-meta-item.share');
|
475
|
-
DOMController.remove('div.footer');
|
476
|
-
DOMController.setStyle('body', 'backgroundColor', 'unset');
|
477
|
-
DOMController.setStyle('#l_main', 'width', '100%');
|
478
|
-
DOMController.setStyle('#post', 'boxShadow', 'none');
|
479
|
-
DOMController.setStyle('#post', 'background', 'none');
|
480
|
-
DOMController.setStyle('#post', 'padding', '0');
|
481
|
-
DOMController.setStyle('h1', 'textAlign', 'center');
|
482
|
-
DOMController.setStyle('h1', 'fontWeight', '600');
|
483
|
-
DOMController.setStyle('h1', 'fontSize', '2rem');
|
484
|
-
DOMController.setStyle('h1', 'marginBottom', '20px');
|
485
|
-
DOMController.setStyle('.tab-pane', 'display', 'block');
|
486
|
-
DOMController.setStyle('.tab-content', 'borderTop', 'none');
|
487
|
-
DOMController.setStyle('.highlight>table pre', 'whiteSpace', 'pre-wrap');
|
488
|
-
DOMController.setStyle('.highlight>table pre', 'wordBreak', 'break-all');
|
489
|
-
DOMController.setStyle('.fancybox img', 'height', 'auto');
|
490
|
-
DOMController.setStyle('.fancybox img', 'weight', 'auto');
|
491
|
-
|
492
|
-
setTimeout(() => {
|
493
|
-
window.print();
|
494
|
-
document.body.innerHTML = '';
|
495
|
-
window.location.reload();
|
496
|
-
}, 50);
|
497
|
-
}
|
498
|
-
|
499
|
-
// 阅读模式
|
500
|
-
fn.readingModel = () => {
|
501
|
-
if (typeof ScrollReveal === 'function') ScrollReveal().clean('#comments');
|
502
|
-
DOMController.fadeToggle(document.querySelector('#l_header'))
|
503
|
-
DOMController.fadeToggle(document.querySelector('footer'))
|
504
|
-
DOMController.fadeToggle(document.querySelector('#s-top'))
|
505
|
-
DOMController.fadeToggle(document.querySelector('.article-meta#bottom'))
|
506
|
-
DOMController.fadeToggle(document.querySelector('.prev-next'))
|
507
|
-
DOMController.fadeToggle(document.querySelector('#l_side'))
|
508
|
-
DOMController.fadeToggle(document.querySelector('#comments'))
|
509
|
-
|
510
|
-
DOMController.toggleClass(document.querySelector('#l_main'), 'common_read')
|
511
|
-
DOMController.toggleClass(document.querySelector('#l_main'), 'common_read_main')
|
512
|
-
DOMController.toggleClass(document.querySelector('#l_body'), 'common_read')
|
513
|
-
DOMController.toggleClass(document.querySelector('#safearea'), 'common_read')
|
514
|
-
DOMController.toggleClass(document.querySelector('#pjax-container'), 'common_read')
|
515
|
-
DOMController.toggleClass(document.querySelector('#read_bkg'), 'common_read_hide')
|
516
|
-
DOMController.toggleClass(document.querySelector('h1'), 'common_read_h1')
|
517
|
-
DOMController.toggleClass(document.querySelector('#post'), 'post_read')
|
518
|
-
DOMController.toggleClass(document.querySelector('#l_cover'), 'read_cover')
|
519
|
-
DOMController.toggleClass(document.querySelector('.widget.toc-wrapper'), 'post_read')
|
520
|
-
|
521
|
-
volantis.isReadModel = volantis.isReadModel === undefined ? true : !volantis.isReadModel;
|
522
|
-
if (volantis.isReadModel) {
|
523
|
-
const option = {
|
524
|
-
backgroundColor: 'var(--color-read-post)',
|
525
|
-
icon: rightMenuConfig.faicon + ' fa-book-reader',
|
526
|
-
time: 5000
|
527
|
-
}
|
528
|
-
if (messageRightMenu) VolantisApp.message('系统提示', '阅读模式已开启,您可以点击屏幕空白处退出。', option);
|
529
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readingModel);
|
530
|
-
document.querySelector('#l_body').addEventListener('click', (event) => {
|
531
|
-
if (DOMController.hasClass(event.target, 'common_read')) {
|
532
|
-
fn.readingModel();
|
533
|
-
}
|
534
|
-
});
|
535
|
-
} else {
|
536
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readingModel);
|
537
|
-
document.querySelector('#post').removeEventListener('click', fn.readingModel);
|
538
|
-
}
|
539
|
-
}
|
540
|
-
|
541
|
-
return {
|
542
|
-
init: (notice = false) => {
|
543
|
-
fn.init();
|
544
|
-
fn.initEvent();
|
545
|
-
if (notice && messageRightMenu) VolantisApp.message('系统提示', '自定义右键注册成功。');
|
546
|
-
},
|
547
|
-
destroy: (notice = false) => {
|
548
|
-
fn.hideMenu();
|
549
|
-
window.document.oncontextmenu = () => {
|
550
|
-
return true
|
551
|
-
};
|
552
|
-
if (notice && messageRightMenu) VolantisApp.message('系统提示', '自定义右键注销成功。');
|
553
|
-
},
|
554
|
-
hideMenu: fn.hideMenu,
|
555
|
-
readingModel: fn.readingModel
|
556
|
-
}
|
557
|
-
})()
|
558
|
-
|
559
|
-
Object.freeze(RightMenu);
|
560
|
-
|
561
|
-
volantis.requestAnimationFrame(() => {
|
562
|
-
if (document.readyState !== 'loading') {
|
563
|
-
RightMenu.init();
|
564
|
-
|
565
|
-
volantis.pjax.send(() => {
|
566
|
-
RightMenu.hideMenu();
|
567
|
-
})
|
568
|
-
} else {
|
569
|
-
document.addEventListener("DOMContentLoaded", function () {
|
570
|
-
RightMenu.init();
|
571
|
-
|
572
|
-
volantis.pjax.send(() => {
|
573
|
-
RightMenu.hideMenu();
|
574
|
-
})
|
575
|
-
})
|
576
|
-
}
|
577
|
-
});
|
1
|
+
"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},l=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,l=Object.create(i.prototype),a=new k(n||[]);return o(l,"_invoke",{value:_(e,r,a)}),l}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=s;var m="suspendedStart",f="suspendedYield",p="executing",y="completed",h={};function g(){}function v(){}function b(){}var M={};u(M,l,(function(){return this}));var C=Object.getPrototypeOf,O=C&&C(C(q([])));O&&O!==r&&n.call(O,l)&&(M=O);var w=b.prototype=g.prototype=Object.create(M);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function D(e,t){function r(o,i,l,a){var c=d(e[o],e,i);if("throw"!==c.type){var u=c.arg,s=u.value;return s&&"object"==_typeof(s)&&n.call(s,"__await")?t.resolve(s.__await).then((function(e){r("next",e,l,a)}),(function(e){r("throw",e,l,a)})):t.resolve(s).then((function(e){u.value=e,l(u)}),(function(e){return r("throw",e,l,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function _(t,r,n){var o=m;return function(i,l){if(o===p)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw l;return{value:e,done:!0}}for(n.method=i,n.arg=l;;){var a=n.delegate;if(a){var c=x(a,n);if(c){if(c===h)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var u=d(t,r,n);if("normal"===u.type){if(o=n.done?y:f,u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function x(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator["return"]&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var i=d(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,h;var l=i.arg;return l?l.done?(r[t.resultName]=l.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,h):l:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,h)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function q(t){if(t||""===t){var r=t[l];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(_typeof(t)+" is not iterable")}return v.prototype=b,o(w,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},S(D.prototype),u(D.prototype,a,(function(){return this})),t.AsyncIterator=D,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var l=new D(s(e,r,n,o),i);return t.isGeneratorFunction(r)?l:l.next().then((function(e){return e.done?e.value:l.next()}))},S(w),u(w,c,"Generator"),u(w,l,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function o(){for(;r.length;){var e=r.pop();if(e in t)return o.value=e,o.done=!1,o}return o.done=!0,o}},t.values=q,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return a.type="throw",a.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var l=this.tryEntries[i],a=l.completion;if("root"===l.tryLoc)return o("end");if(l.tryLoc<=this.prev){var c=n.call(l,"catchLoc"),u=n.call(l,"finallyLoc");if(c&&u){if(this.prev<l.catchLoc)return o(l.catchLoc,!0);if(this.prev<l.finallyLoc)return o(l.finallyLoc)}else if(c){if(this.prev<l.catchLoc)return o(l.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<l.finallyLoc)return o(l.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var l=i?i.completion:{};return l.type=e,l.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(l)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),h}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:q(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),h}},t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function asyncGeneratorStep(e,t,r,n,o,i,l){try{var a=e[i](l),c=a.value}catch(u){return void r(u)}a.done?t(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function l(e){asyncGeneratorStep(i,n,o,l,a,"next",e)}function a(e){asyncGeneratorStep(i,n,o,l,a,"throw",e)}l(undefined)}))}}var RightMenu=function(){var e=volantis.GLOBAL_CONFIG.plugins.rightmenu,t=volantis.GLOBAL_CONFIG.plugins.message.enable&&volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable,r={},n=document.getElementById("rightmenu-wrapper"),o=document.getElementById("rightmenu-content"),i=document.getElementById("printHtml"),l=document.getElementById("menuMusic"),a=document.getElementById("readingModel"),c=document.getElementById("read_bkg"),u=document.querySelectorAll(".menuLoad-Content"),s=document.querySelector(".menu-Option"),d=document.querySelector('.menu-Option[data-fn-type="searchWord"]'),m=document.querySelector('.menu-Option[data-fn-type="copyText"]'),f=document.querySelector('.menu-Option[data-fn-type="copyPaste"]'),p=document.querySelector('.menu-Option[data-fn-type="copySelect"]'),y=document.querySelector('.menu-Option[data-fn-type="copyCut"]'),h=document.querySelector('.menu-Option[data-fn-type="copyHref"]'),g=document.querySelector('.menu-Option[data-fn-type="copySrc"]'),v=document.querySelector('.menu-Option[data-fn-type="copyImg"]'),b=document.querySelector('.menu-Option[data-fn-type="openTab"]'),M=document.querySelector("#menuMusic .backward"),C=document.querySelector("#menuMusic .toggle"),O=document.querySelector("#menuMusic .forward"),w=/^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;return r.init=function(){DOMController.visible(l,!1),DOMController.visible(s,!1),c&&c.parentNode.removeChild(c);var e=document.createElement("div");e.className="common_read_bkg common_read_hide",e.id="read_bkg",window.document.body.appendChild(e)},r.initEvent=function(){window.document.oncontextmenu=function(e){return e.ctrlKey||document.body.offsetWidth<=500?(r.hideMenu(),!0):r.popMenu(e)},n.oncontextmenu=function(e){return e.stopPropagation(),e.preventDefault(),!1},window.removeEventListener("blur",r.hideMenu),window.addEventListener("blur",r.hideMenu),document.body.removeEventListener("click",r.hideMenu),document.body.addEventListener("click",r.hideMenu),O&&C&&O&&(M.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerBackward()},C.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerToggle()},O.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerForward()})},r.popMenu=function(e){var t=e.clientX,i=e.clientY,l=document.documentElement.clientWidth||document.body.clientWidth,a=document.documentElement.clientHeight||document.body.clientHeight;try{r.setMenuItem(e),DOMController.visible(n),n.focus(),n.style.zIndex="-2147483648";var c=o.offsetWidth,u=o.offsetHeight,s=t+c>l?t-c+10:t,d=i+u>a?i-u+10:i;d=i+u>a&&d<u&&i<u?d+(a-u-d-10):d,n.style.left=s+"px",n.style.top=d+"px",n.style.zIndex="2147483648",volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice&&r.showMessage()}catch(m){return n.blur(),console.error(m),!0}return!1},r.showMessage=function(){var r="true"===localStorage.getItem("NoticeRightMenu");t&&!r&&VolantisApp.message("右键菜单","唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>",{icon:e.faicon+" fa-exclamation-square red",time:9e3},(function(){localStorage.setItem("NoticeRightMenu","true")}))},r.setMenuItem=function(n){var o=!1,c=n.target,s=window.getSelection().toString();if(DOMController.visible(b,!1),"input"===c.tagName.toLowerCase()||"textarea"===c.tagName.toLowerCase()){var M=c.value;M.length>0?(DOMController.visible(p),p.onclick=function(){n.preventDefault(),c.select()}):DOMController.visible(p,!1),s?(DOMController.visible(y),y.onclick=function(){var e=c.selectionStart,t=c.selectionEnd;r.copyString(s),c.value=M.substring(0,e)+M.substring(t,M.length),c.selectionStart=e,c.selectionEnd=e,c.focus()}):DOMController.visible(y,!1),r.readClipboard().then((function(e){e?(DOMController.visible(f),f.onclick=function(){r.insertAtCaret(c,e)}):DOMController.visible(f,!1)}))["catch"]((function(e){console.error(e),DOMController.visible(f,!1)}))}else DOMController.visible(p,!1),DOMController.visible(f,!1),DOMController.visible(y,!1);var C=c.href;C&&w.test(C)?(o=!0,DOMController.visible(h),DOMController.visible(b),h&&(h.onclick=function(){r.copyString(C)}),b.onclick=function(){window.open(C)}):DOMController.visible(h,!1);var O=c.currentSrc;O&&w.test(O)?(o=!0,DOMController.visible(g),DOMController.visible(b),g.onclick=function(){r.copyString(O)},b.onclick=function(){window.open(O)}):DOMController.visible(g,!1),O&&w.test(O)&&O.trimEnd().endsWith(".png")?(o=!0,DOMController.visible(v),v.onclick=function(){r.writeClipImg(n,(function(r){r&&t&&VolantisApp.message("系统提示","图片复制成功!",{icon:e.faicon+" fa-images"})}),(function(r){t&&VolantisApp.message("系统提示","复制失败:"+r,{icon:e.faicon+" fa-exclamation-square red"})}))}):DOMController.visible(v,!1),s?(o=!0,DOMController.visible(m),DOMController.visible(d),m.onclick=function(){r.copyString(s)},d&&(d.onclick=function(){OpenSearch(s)})):(DOMController.visible(m,!1),DOMController.visible(d,!1));var S=document.querySelector("#post.article")||null,D=window.location.pathname;S?(DOMController.visible(i),DOMController.visible(a),i&&(i.onclick=function(){if(window.location.pathname===D){t&&VolantisApp.question("",'是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>',{},(function(){r.printHtml()}))}else r.hideMenu()}),a&&(a.onclick=function(){window.location.pathname,r.readingModel()})):(DOMController.visible(i,!1),DOMController.visible(a,!1)),volantis.GLOBAL_CONFIG.plugins.aplayer.enable&&"undefined"!=typeof RightMenuAplayer&&RightMenuAplayer.APlayer.player!==undefined?e.music_alwaysShow?DOMController.visible(l):"play"===RightMenuAplayer.APlayer.status||"undefined"===RightMenuAplayer.APlayer.status?(o=!0,DOMController.visible(l)):DOMController.visible(l,!1):DOMController.visible(l,!1),u.forEach((function(e){DOMController.visible(e,!o)})),volantis.GLOBAL_CONFIG.plugins.aplayer.enable&&e.layout.includes("music")&&RightMenuAplayer.checkAPlayer()},r.hideMenu=function(){DOMController.visible(n,!1)},r.copyString=function(r){VolantisApp.utilWriteClipText(r).then((function(){t&&VolantisApp.messageCopyright()}))["catch"]((function(r){t&&VolantisApp.message("系统提示",r,{icon:e.faicon+" fa-exclamation-square red"})}))},r.writeClipText=function(e){try{return navigator.clipboard.writeText(e).then((function(){return Promise.resolve()}))["catch"]((function(e){return Promise.reject(e)}))}catch(n){var t=document.createElement("input");t.setAttribute("readonly","readonly"),document.body.appendChild(t),t.setAttribute("value",e),t.select();try{var r=document.execCommand("copy");return document.body.removeChild(t),r&&"unsuccessful"!==r?Promise.resolve():Promise.reject("复制文本失败!")}catch(n){return document.body.removeChild(t),Promise.reject("当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!")}}},r.writeClipImg=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function r(t,n,o){var i,l,a,c,u,s,d,m;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=e.customPicUrl.enable?t.target.currentSrc.replace(e.customPicUrl.old,e.customPicUrl["new"]):t.target.currentSrc,l=t.target.parentElement,r.prev=2,r.next=5,fetch(i);case 5:return a=r.sent,r.next=8,a.blob();case 8:return c=r.sent,r.next=11,navigator.clipboard.write([new ClipboardItem(_defineProperty({},c.type,c))]).then((function(){n(!0)}),(function(e){console.error("图片复制失败:",e),o(e)}));case 11:r.next=17;break;case 13:r.prev=13,r.t0=r["catch"](2),u=document;try{u.body.createTextRange?((s=document.body.createTextRange()).moveToElementText(l),s.select()):window.getSelection&&(d=window.getSelection(),(m=document.createRange()).selectNodeContents(l),d.removeAllRanges(),d.addRange(m)),document.execCommand("copy"),window.getSelection().removeAllRanges(),n(!1)}catch(f){console.error(f),o("不支持复制当前图片!")}case 17:case"end":return r.stop()}}),r,null,[[2,13]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.readClipboard=_asyncToGenerator(_regeneratorRuntime().mark((function S(){var e;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.permissions.query({name:"clipboard-read"});case 2:if("granted"!==(e=t.sent).state&&"prompt"!==e.state){t.next=5;break}return t.abrupt("return",navigator.clipboard.readText().then((function(e){return e}))["catch"]((function(e){return Promise.reject(e)})));case 5:return t.abrupt("return",Promise.reject(e));case 6:case"end":return t.stop()}}),S)}))),r.insertAtCaret=function(e,t){var r=e.selectionStart,n=e.selectionEnd;if(document.selection)e.focus(),document.selection.createRange().text=t,e.focus();else if(r||"0"==r){var o=e.scrollTop;e.value=e.value.substring(0,r)+t+e.value.substring(n,e.value.length),e.focus(),e.selectionStart=r+t.length,e.selectionEnd=r+t.length,e.scrollTop=o}else e.value+=t,e.focus()},r.printHtml=function(){volantis.isReadModel&&r.readingModel(),DOMController.setAttribute("details","open","true"),DOMController.remove(".cus-article-bkg"),DOMController.remove(".iziToast-overlay"),DOMController.remove(".iziToast-wrapper"),DOMController.remove(".prev-next"),DOMController.remove("footer"),DOMController.remove("#l_header"),DOMController.remove("#l_cover"),DOMController.remove("#l_side"),DOMController.remove("#comments"),DOMController.remove("#s-top"),DOMController.remove("#BKG"),DOMController.remove("#rightmenu-wrapper"),DOMController.remove(".nav-tabs"),DOMController.remove(".parallax-mirror"),DOMController.remove(".new-meta-item.share"),DOMController.remove("div.footer"),DOMController.setStyle("body","backgroundColor","unset"),DOMController.setStyle("#l_main","width","100%"),DOMController.setStyle("#post","boxShadow","none"),DOMController.setStyle("#post","background","none"),DOMController.setStyle("#post","padding","0"),DOMController.setStyle("h1","textAlign","center"),DOMController.setStyle("h1","fontWeight","600"),DOMController.setStyle("h1","fontSize","2rem"),DOMController.setStyle("h1","marginBottom","20px"),DOMController.setStyle(".tab-pane","display","block"),DOMController.setStyle(".tab-content","borderTop","none"),DOMController.setStyle(".highlight>table pre","whiteSpace","pre-wrap"),DOMController.setStyle(".highlight>table pre","wordBreak","break-all"),DOMController.setStyle(".fancybox img","height","auto"),DOMController.setStyle(".fancybox img","weight","auto"),setTimeout((function(){window.print(),document.body.innerHTML="",window.location.reload()}),50)},r.readingModel=function(){if("function"==typeof ScrollReveal&&ScrollReveal().clean("#comments"),DOMController.fadeToggle(document.querySelector("#l_header")),DOMController.fadeToggle(document.querySelector("footer")),DOMController.fadeToggle(document.querySelector("#s-top")),DOMController.fadeToggle(document.querySelector(".article-meta#bottom")),DOMController.fadeToggle(document.querySelector(".prev-next")),DOMController.fadeToggle(document.querySelector("#l_side")),DOMController.fadeToggle(document.querySelector("#comments")),DOMController.toggleClass(document.querySelector("#l_main"),"common_read"),DOMController.toggleClass(document.querySelector("#l_main"),"common_read_main"),DOMController.toggleClass(document.querySelector("#l_body"),"common_read"),DOMController.toggleClass(document.querySelector("#safearea"),"common_read"),DOMController.toggleClass(document.querySelector("#pjax-container"),"common_read"),DOMController.toggleClass(document.querySelector("#read_bkg"),"common_read_hide"),DOMController.toggleClass(document.querySelector("h1"),"common_read_h1"),DOMController.toggleClass(document.querySelector("#post"),"post_read"),DOMController.toggleClass(document.querySelector("#l_cover"),"read_cover"),DOMController.toggleClass(document.querySelector(".widget.toc-wrapper"),"post_read"),volantis.isReadModel=volantis.isReadModel===undefined||!volantis.isReadModel,volantis.isReadModel){var n={backgroundColor:"var(--color-read-post)",icon:e.faicon+" fa-book-reader",time:5e3};t&&VolantisApp.message("系统提示","阅读模式已开启,您可以点击屏幕空白处退出。",n),document.querySelector("#l_body").removeEventListener("click",r.readingModel),document.querySelector("#l_body").addEventListener("click",(function(e){DOMController.hasClass(e.target,"common_read")&&r.readingModel()}))}else document.querySelector("#l_body").removeEventListener("click",r.readingModel),document.querySelector("#post").removeEventListener("click",r.readingModel)},{init:function(){var e=arguments.length>0&&arguments[0]!==undefined&&arguments[0];r.init(),r.initEvent(),e&&t&&VolantisApp.message("系统提示","自定义右键注册成功。")},destroy:function(){var e=arguments.length>0&&arguments[0]!==undefined&&arguments[0];r.hideMenu(),window.document.oncontextmenu=function(){return!0},e&&t&&VolantisApp.message("系统提示","自定义右键注销成功。")},hideMenu:r.hideMenu,readingModel:r.readingModel}}();Object.freeze(RightMenu),volantis.requestAnimationFrame((function(){"loading"!==document.readyState?(RightMenu.init(),volantis.pjax.send((function(){RightMenu.hideMenu()}))):document.addEventListener("DOMContentLoaded",(function(){RightMenu.init(),volantis.pjax.send((function(){RightMenu.hideMenu()}))}))}));
|
2
|
+
//# sourceMappingURL=../../maps/js/plugins/rightMenu.js.map
|