hexo-theme-solitude 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/_config.yml +15 -19
  2. package/languages/default.yml +173 -173
  3. package/layout/archive.pug +3 -1
  4. package/layout/category.pug +3 -1
  5. package/layout/includes/rightmenu.pug +6 -5
  6. package/layout/includes/widgets/third-party/hot/artalk.pug +56 -0
  7. package/layout/includes/widgets/third-party/hot/twikoo.pug +57 -0
  8. package/layout/includes/widgets/third-party/pjax.pug +2 -1
  9. package/layout/index.pug +1 -1
  10. package/layout/tag.pug +2 -0
  11. package/package.json +1 -1
  12. package/scripts/event/init.js +0 -1
  13. package/scripts/event/merge_config.js +14 -39
  14. package/scripts/filter/default.js +20 -21
  15. package/scripts/filter/lazyload.js +2 -4
  16. package/scripts/helper/getArchiveLength.js +9 -11
  17. package/scripts/helper/related_post.js +56 -56
  18. package/scripts/tags/tabs.js +28 -46
  19. package/source/css/_comments/twikoo.styl +3 -3
  20. package/source/css/_highlight/highlight/diff.styl +13 -1
  21. package/source/css/_highlight/index.styl +2 -2
  22. package/source/css/_highlight/prismjs/diff.styl +13 -1
  23. package/source/css/_layout/recent-post.styl +2 -2
  24. package/source/img/error_load.avif +0 -0
  25. package/source/js/covercolor/api.js +29 -14
  26. package/source/js/covercolor/ave.js +38 -24
  27. package/source/js/covercolor/local.js +52 -52
  28. package/source/js/main.js +236 -244
  29. package/source/js/music.js +21 -39
  30. package/source/js/right_menu.js +67 -132
  31. package/source/js/third_party/barrage.min.js +93 -1
  32. package/source/js/third_party/envelope.min.js +1 -1
  33. package/source/js/third_party/post_ai.min.js +184 -1
  34. package/source/js/tw_cn.js +19 -18
  35. package/source/js/utils.js +50 -57
  36. package/layout/includes/widgets/home/hot/artalk.pug +0 -45
  37. package/layout/includes/widgets/home/hot/twikoo.pug +0 -46
  38. package/source/img/loading.avif +0 -0
  39. /package/layout/includes/widgets/{home → third-party}/hot/index.pug +0 -0
@@ -2,21 +2,19 @@ class MusicPlayer {
2
2
  constructor() {
3
3
  this.init();
4
4
  }
5
+
5
6
  init() {
6
7
  document.documentElement.style.setProperty('--vh', `${window.innerHeight}px`);
7
8
  this.getCustomPlayList();
8
- this.addEventListenerToDocument();
9
- this.addButtonListEventListener();
9
+ this.addEventListeners();
10
10
  }
11
11
 
12
12
  getCustomPlayList() {
13
13
  this.changeMusicBg(false);
14
14
  }
15
- addEventListenerToDocument() {
16
- document.addEventListener("keydown", this.handleKeydown.bind(this));
17
- }
18
15
 
19
- addButtonListEventListener() {
16
+ addEventListeners() {
17
+ document.addEventListener("keydown", this.handleKeydown.bind(this));
20
18
  const aplayerList = document.querySelector(".aplayer-list");
21
19
  document.querySelector(".aplayer-lrc")?.addEventListener("click", () => {
22
20
  aplayerList.classList.toggle("aplayer-list-hide");
@@ -27,11 +25,7 @@ class MusicPlayer {
27
25
  const musicBg = document.getElementById("Music-bg");
28
26
  const musicLoading = document.getElementsByClassName("Music-loading")[0];
29
27
 
30
- if (isChangeBg) {
31
- this.updateBackgroundImage(musicBg);
32
- } else {
33
- this.setLoadingScreen(musicLoading, musicBg);
34
- }
28
+ isChangeBg ? this.updateBackgroundImage(musicBg) : this.setLoadingScreen(musicLoading, musicBg);
35
29
  }
36
30
 
37
31
  updateBackgroundImage(element) {
@@ -40,8 +34,8 @@ class MusicPlayer {
40
34
  img.src = this.extractValue(musicCover.style.backgroundImage);
41
35
  img.onload = () => {
42
36
  element.style.backgroundImage = musicCover.style.backgroundImage;
37
+ element.className = 'show';
43
38
  };
44
- element.className = 'show'
45
39
  }
46
40
 
47
41
  setLoadingScreen(loadingElement, backgroundElement) {
@@ -50,23 +44,20 @@ class MusicPlayer {
50
44
  if (musicCover) {
51
45
  loadingElement.style.display = "none";
52
46
  clearInterval(timer);
53
- document.querySelector('meting-js');
54
47
  this.addEventListenerChangeMusicBg();
55
48
  backgroundElement.style.display = "block";
56
49
  }
57
- this.addButtonListEventListener();
58
50
  }, 100);
59
51
  }
60
52
 
61
53
  extractValue(input) {
62
- const valueRegex = /url\("([^"]+)"\)/;
63
- const match = valueRegex.exec(input);
54
+ const match = /url\("([^"]+)"\)/.exec(input);
64
55
  return match ? match[1] : '';
65
56
  }
66
57
 
67
58
  addEventListenerChangeMusicBg() {
68
59
  const aplayer = document.querySelector("#Music-page meting-js").aplayer;
69
- aplayer.on('loadeddata', this.changeMusicBg.bind(this, true));
60
+ aplayer.on('loadeddata', () => this.changeMusicBg(true));
70
61
  aplayer.on('timeupdate', this.lrcUpdate.bind(this));
71
62
  }
72
63
 
@@ -81,36 +72,27 @@ class MusicPlayer {
81
72
 
82
73
  handleKeydown(event) {
83
74
  const aplayer = document.querySelector('meting-js').aplayer;
84
- switch (event.code) {
85
- case "Space":
86
- event.preventDefault();
87
- aplayer.toggle();
88
- break;
89
- case "ArrowRight":
90
- event.preventDefault();
91
- aplayer.skipForward();
92
- break;
93
- case "ArrowLeft":
94
- event.preventDefault();
95
- aplayer.skipBack();
96
- break;
97
- case "ArrowUp":
98
- event.preventDefault();
99
- if (aplayer.volume < 1) aplayer.volume(aplayer.volume + 0.1);
100
- break;
101
- case "ArrowDown":
102
- event.preventDefault();
103
- if (aplayer.volume > 0) aplayer.volume(aplayer.volume - 0.1);
104
- break;
75
+ const actions = {
76
+ "Space": () => aplayer.toggle(),
77
+ "ArrowRight": () => aplayer.skipForward(),
78
+ "ArrowLeft": () => aplayer.skipBack(),
79
+ "ArrowUp": () => { if (aplayer.volume < 1) aplayer.volume(aplayer.volume + 0.1); },
80
+ "ArrowDown": () => { if (aplayer.volume > 0) aplayer.volume(aplayer.volume - 0.1); }
81
+ };
82
+
83
+ if (actions[event.code]) {
84
+ event.preventDefault();
85
+ actions[event.code]();
105
86
  }
106
87
  }
88
+
107
89
  destroy() {
108
90
  document.removeEventListener("keydown", this.handleKeydown);
109
91
  }
110
92
  }
111
93
 
112
94
  function initializeMusicPlayer() {
113
- let exitingMusic = window.scoMusic;
95
+ const exitingMusic = window.scoMusic;
114
96
  if (exitingMusic) exitingMusic.destroy();
115
97
  window.scoMusic = new MusicPlayer();
116
98
  }
@@ -1,10 +1,10 @@
1
1
  let selectTextNow = "";
2
2
  let firstShowRightMenu = true;
3
+
3
4
  const selectText = () => {
4
- selectTextNow = document.selection
5
- ? document.selection.createRange().text
6
- : window.getSelection() + "" || "";
5
+ selectTextNow = document.selection ? document.selection.createRange().text : window.getSelection().toString() || "";
7
6
  };
7
+
8
8
  document.onmouseup = document.ondbclick = selectText;
9
9
 
10
10
  const rm = {
@@ -41,24 +41,26 @@ const rm = {
41
41
  ],
42
42
  },
43
43
  showRightMenu(e, x = 0, y = 0) {
44
- this.menu.style.top = y + "px";
45
- this.menu.style.left = x + "px";
44
+ this.menu.style.top = `${y}px`;
45
+ this.menu.style.left = `${x}px`;
46
46
  this.menu.style.display = e ? "block" : "none";
47
- e ? stopMaskScroll() : (this.mask.style.display = "none");
47
+ this.mask.style.display = e ? "flex" : "none";
48
+ if (e) stopMaskScroll();
48
49
  },
49
50
  hideRightMenu() {
50
- rm.showRightMenu(false);
51
- rm.mask.style.display = "none";
51
+ this.showRightMenu(false);
52
52
  },
53
53
  reLoadSize() {
54
- rm.menu.style.display = "block";
55
- rm.width = rm.menu.offsetWidth;
56
- rm.height = rm.menu.offsetHeight;
57
- rm.menu.style.display = 'none';
54
+ this.menu.style.display = "block";
55
+ this.width = this.menu.offsetWidth;
56
+ this.height = this.menu.offsetHeight;
57
+ this.menu.style.display = 'none';
58
58
  },
59
59
  copyText(e) {
60
- navigator.clipboard && navigator.clipboard.writeText(e);
61
- utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success, false, 2000);
60
+ if (navigator.clipboard) {
61
+ navigator.clipboard.writeText(e);
62
+ utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success, false, 2000);
63
+ }
62
64
  this.hideRightMenu();
63
65
  },
64
66
  async downloadImage(imageUrl = this.domsrc, filename = "photo") {
@@ -68,8 +70,7 @@ const rm = {
68
70
  const url = URL.createObjectURL(blob);
69
71
  const link = document.createElement("a");
70
72
  link.href = url;
71
- link.download = filename || "image.jpg";
72
- link.style.display = "none";
73
+ link.download = filename;
73
74
  document.body.appendChild(link);
74
75
  link.click();
75
76
  document.body.removeChild(link);
@@ -82,127 +83,80 @@ const rm = {
82
83
  window.open(imgUrl);
83
84
  },
84
85
  mode(darkmode) {
85
- darkmode
86
- ? (document.querySelector(".menu-darkmode-text").textContent =
87
- GLOBAL_CONFIG.right_menu.mode.light)
88
- : (document.querySelector(".menu-darkmode-text").textContent =
89
- GLOBAL_CONFIG.right_menu.mode.dark);
86
+ document.querySelector(".menu-darkmode-text").textContent = darkmode ? GLOBAL_CONFIG.right_menu.mode.light : GLOBAL_CONFIG.right_menu.mode.dark;
90
87
  this.hideRightMenu();
91
88
  },
92
89
  barrage(enable) {
93
- enable
94
- ? (document.querySelector(".menu-commentBarrage-text").textContent =
95
- GLOBAL_CONFIG.right_menu.barrage.open)
96
- : (document.querySelector(".menu-commentBarrage-text").textContent =
97
- GLOBAL_CONFIG.right_menu.barrage.close);
90
+ document.querySelector(".menu-commentBarrage-text").textContent = enable ? GLOBAL_CONFIG.right_menu.barrage.open : GLOBAL_CONFIG.right_menu.barrage.close;
98
91
  this.hideRightMenu();
99
92
  },
100
93
  };
101
94
 
102
95
  function stopMaskScroll() {
103
- utils.addEventListenerPjax(rm.menu, "mousewheel", rm.hideRightMenu, { passive: true });
104
- utils.addEventListenerPjax(rm.mask, "mousewheel", rm.hideRightMenu, { passive: true });
105
- utils.addEventListenerPjax(rm.mask, "click", rm.hideRightMenu, { passive: true });
96
+ const hideMenu = rm.hideRightMenu.bind(rm);
97
+ utils.addEventListenerPjax(rm.menu, "mousewheel", hideMenu, { passive: true });
98
+ utils.addEventListenerPjax(rm.mask, "mousewheel", hideMenu, { passive: true });
99
+ utils.addEventListenerPjax(rm.mask, "click", hideMenu, { passive: true });
106
100
  }
107
101
 
108
102
  window.oncontextmenu = (ele) => {
109
103
  if (document.body.clientWidth <= 768) return;
110
- if (GLOBAL_CONFIG.right_menu.ctrlOriginalMenu) {
111
- if (firstShowRightMenu) {
112
- firstShowRightMenu = false;
113
- utils.snackbarShow(GLOBAL_CONFIG.right_menu.ctrlOriginalMenu, false, 2000);
114
- }
115
- if (ele.ctrlKey) {
116
- return true;
117
- }
104
+ if (GLOBAL_CONFIG.right_menu.ctrlOriginalMenu && firstShowRightMenu) {
105
+ firstShowRightMenu = false;
106
+ utils.snackbarShow(GLOBAL_CONFIG.right_menu.ctrlOriginalMenu, false, 2000);
107
+ if (ele.ctrlKey) return true;
118
108
  }
109
+
119
110
  let x = ele.clientX + 10;
120
111
  let y = ele.clientY;
121
- Array.from(rm.menuItems.other).forEach((item) => (item.style.display = "flex"));
112
+ Array.from(rm.menuItems.other).forEach(item => item.style.display = "flex");
122
113
  rm.globalEvent = ele;
123
114
 
124
- let display = false;
125
- let link = ele.target.href;
126
- let src = ele.target.currentSrc;
115
+ const link = ele.target.href;
116
+ const src = ele.target.currentSrc;
117
+ const tagName = ele.target.tagName.toLowerCase();
118
+ const cls = ele.target.className.toLowerCase();
127
119
 
128
- if (selectTextNow && window.getSelection()) {
129
- display = true;
130
- rm.menuItems.copy.style.display = "flex";
131
- GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = "flex");
132
- rm.menuItems.search && (rm.menuItems.search.style.display = "flex");
133
- } else {
134
- rm.menuItems.copy.style.display = "none";
135
- GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = "none");
136
- rm.menuItems.search && (rm.menuItems.search.style.display = "none");
137
- }
120
+ const display = !!(selectTextNow && window.getSelection()) || !!link || !!src || (tagName === "input" || tagName === "textarea") || cls.match(/aplayer/);
138
121
 
139
- if (link) {
140
- display = true;
141
- rm.menuItems.new.style.display = "flex";
142
- rm.menuItems.copyLink.style.display = "flex";
143
- rm.domhref = link;
144
- } else {
145
- rm.menuItems.new.style.display = "none";
146
- rm.menuItems.copyLink.style.display = "none";
147
- }
122
+ rm.menuItems.copy.style.display = selectTextNow && window.getSelection() ? "flex" : "none";
123
+ GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = selectTextNow && window.getSelection() ? "flex" : "none");
124
+ rm.menuItems.search.style.display = selectTextNow && window.getSelection() ? "flex" : "none";
148
125
 
149
- if (src) {
150
- display = true;
151
- rm.menuItems.copyImg.style.display = "flex";
152
- rm.menuItems.downloadImg.style.display = "flex";
153
- rm.domsrc = src;
154
- } else {
155
- rm.menuItems.copyImg.style.display = "none";
156
- rm.menuItems.downloadImg.style.display = "none";
157
- }
126
+ rm.menuItems.new.style.display = link ? "flex" : "none";
127
+ rm.menuItems.copyLink.style.display = link ? "flex" : "none";
128
+ rm.domhref = link || "";
129
+
130
+ rm.menuItems.copyImg.style.display = src ? "flex" : "none";
131
+ rm.menuItems.downloadImg.style.display = src ? "flex" : "none";
132
+ rm.domsrc = src || "";
133
+
134
+ rm.menuItems.paste.style.display = (tagName === "input" || tagName === "textarea") ? "flex" : "none";
158
135
 
159
- let tagName = ele.target.tagName.toLowerCase();
160
- if (tagName === "input" || tagName === "textarea") {
161
- display = true;
162
- rm.menuItems.paste.style.display = "flex";
163
- } else {
164
- rm.menuItems.paste.style.display = "none";
165
- }
166
- let cls = ele.target.className.toLowerCase();
167
136
  if (cls.match(/aplayer/)) {
168
- display = true;
169
- rm.menuItems.music.forEach((item) => (item.style.display = "flex"));
137
+ rm.menuItems.music.forEach(item => item.style.display = "flex");
170
138
  } else {
171
- rm.menuItems.music[0] &&
172
- rm.menuItems.music.forEach((item) => (item.style.display = "none"));
139
+ rm.menuItems.music.forEach(item => item.style.display = "none");
173
140
  }
174
141
 
175
- Array.from(display ? rm.menuItems.other : rm.menuItems.plugin).forEach(
176
- (item) => (item.style.display = "none")
177
- );
142
+ Array.from(display ? rm.menuItems.other : rm.menuItems.plugin).forEach(item => item.style.display = "none");
143
+ Array.from(display ? rm.menuItems.plugin : rm.menuItems.other).forEach(item => item.style.display = "block");
178
144
 
179
- Array.from(display ? rm.menuItems.plugin : rm.menuItems.other).forEach(
180
- (item) => (item.style.display = "block")
181
- );
182
145
  rm.reLoadSize();
183
- x + rm.width > window.innerWidth && (x -= rm.width + 10);
184
- y + rm.height > window.innerHeight && (y -= y + rm.height - window.innerHeight);
185
- rm.mask.style.display = "flex";
146
+ x = (x + rm.width > window.innerWidth) ? x - (rm.width + 10) : x;
147
+ y = (y + rm.height > window.innerHeight) ? y - (y + rm.height - window.innerHeight) : y;
148
+
186
149
  rm.showRightMenu(true, x, y);
187
150
  return false;
188
151
  };
189
152
 
190
153
  (function () {
191
- const addEventListener = (element, event, handler) =>
192
- element.addEventListener(event, handler);
154
+ const addEventListener = (element, event, handler) => element.addEventListener(event, handler);
193
155
 
194
- addEventListener(rm.menuItems.back, "click", () =>
195
- window.history.back() || rm.hideRightMenu()
196
- );
197
- addEventListener(rm.menuItems.forward, "click", () =>
198
- window.history.forward() || rm.hideRightMenu()
199
- );
200
- addEventListener(rm.menuItems.refresh, "click", () =>
201
- window.location.reload()
202
- );
203
- addEventListener(rm.menuItems.top, "click", () =>
204
- sco.toTop() || rm.hideRightMenu()
205
- );
156
+ addEventListener(rm.menuItems.back, "click", () => window.history.back() || rm.hideRightMenu());
157
+ addEventListener(rm.menuItems.forward, "click", () => window.history.forward() || rm.hideRightMenu());
158
+ addEventListener(rm.menuItems.refresh, "click", () => window.location.reload());
159
+ addEventListener(rm.menuItems.top, "click", () => sco.toTop() || rm.hideRightMenu());
206
160
 
207
161
  if (GLOBAL_CONFIG.right_menu.music) {
208
162
  addEventListener(rm.menuItems.music[0], "click", () => {
@@ -218,45 +172,26 @@ window.oncontextmenu = (ele) => {
218
172
  rm.hideRightMenu();
219
173
  });
220
174
  addEventListener(rm.menuItems.music[3], "click", () => {
221
- const title = Array.from(document.querySelectorAll(".aplayer-title")).map(
222
- (e) => e.innerText
223
- )[0];
175
+ const title = Array.from(document.querySelectorAll(".aplayer-title")).map(e => e.innerText)[0];
224
176
  rm.copyText(title);
225
177
  });
226
178
  }
227
179
 
228
180
  addEventListener(rm.menuItems.copy, "click", () => {
229
- if (GLOBAL_CONFIG.copyright) {
230
- const { limit, author, link, source, info } = GLOBAL_CONFIG.right_menu;
231
- if (selectTextNow.length > limit) {
232
- selectTextNow = `${selectTextNow}\n\n${author}\n${link}${window.location.href}\n${source}\n${info}`;
233
- }
181
+ if (GLOBAL_CONFIG.copyright && selectTextNow.length > GLOBAL_CONFIG.right_menu.limit) {
182
+ selectTextNow += `\n\n${GLOBAL_CONFIG.right_menu.author}\n${GLOBAL_CONFIG.right_menu.link}${window.location.href}\n${GLOBAL_CONFIG.right_menu.source}\n${GLOBAL_CONFIG.right_menu.info}`;
234
183
  }
235
184
  rm.copyText(selectTextNow);
236
- rm.hideRightMenu();
237
185
  });
238
186
 
239
187
  if (utils.saveToLocal.get("commentBarrageSwitch") !== null) {
240
188
  rm.menuItems.barrage && rm.barrage(!utils.saveToLocal.get("commentBarrageSwitch"));
241
189
  }
242
190
 
243
- addEventListener(rm.menuItems.paste, "click", () =>
244
- rm.pasteText() && rm.hideRightMenu()
245
- );
246
- GLOBAL_CONFIG.comment &&
247
- addEventListener(rm.menuItems.comment, "click", () =>
248
- rm.hideRightMenu() || sco.toTalk(selectTextNow)
249
- );
250
- addEventListener(rm.menuItems.new, "click", () =>
251
- window.open(rm.domhref) && rm.hideRightMenu()
252
- );
253
- addEventListener(rm.menuItems.downloadImg, "click", () =>
254
- rm.downloadImage() && rm.hideRightMenu()
255
- );
256
- addEventListener(rm.menuItems.copyImg, "click", () =>
257
- rm.copyImage() && rm.hideRightMenu()
258
- );
259
- addEventListener(rm.menuItems.copyLink, "click", () =>
260
- rm.copyText(rm.domhref) && rm.hideRightMenu()
261
- );
191
+ addEventListener(rm.menuItems.paste, "click", () => rm.pasteText() && rm.hideRightMenu());
192
+ GLOBAL_CONFIG.comment && addEventListener(rm.menuItems.comment, "click", () => rm.hideRightMenu() || sco.toTalk(selectTextNow));
193
+ addEventListener(rm.menuItems.new, "click", () => window.open(rm.domhref) && rm.hideRightMenu());
194
+ addEventListener(rm.menuItems.downloadImg, "click", () => rm.downloadImage() && rm.hideRightMenu());
195
+ addEventListener(rm.menuItems.copyImg, "click", () => rm.copyImage() && rm.hideRightMenu());
196
+ addEventListener(rm.menuItems.copyLink, "click", () => rm.copyText(rm.domhref) && rm.hideRightMenu());
262
197
  })();
@@ -3,4 +3,96 @@
3
3
  * author: @everfu
4
4
  * date: 2024-04-28
5
5
  */
6
- function _0x2736(_0x423b83,_0x26de1b){const _0x562b41=_0x562b();return _0x2736=function(_0x2736dc,_0x1e863c){_0x2736dc=_0x2736dc-0x11f;let _0x1c44ad=_0x562b41[_0x2736dc];return _0x1c44ad;},_0x2736(_0x423b83,_0x26de1b);}const _0xf096ba=_0x2736;(function(_0x244294,_0x51eb5a){const _0x2047ac=_0x2736,_0x461abb=_0x244294();while(!![]){try{const _0x362f69=-parseInt(_0x2047ac(0x12f))/0x1+-parseInt(_0x2047ac(0x126))/0x2+-parseInt(_0x2047ac(0x120))/0x3+-parseInt(_0x2047ac(0x15b))/0x4+parseInt(_0x2047ac(0x13c))/0x5+parseInt(_0x2047ac(0x153))/0x6*(parseInt(_0x2047ac(0x15c))/0x7)+parseInt(_0x2047ac(0x132))/0x8*(parseInt(_0x2047ac(0x152))/0x9);if(_0x362f69===_0x51eb5a)break;else _0x461abb['push'](_0x461abb['shift']());}catch(_0x59d2ed){_0x461abb['push'](_0x461abb['shift']());}}}(_0x562b,0xa9d59));class Barrage{constructor(_0x35d098){const _0xc51bb8=_0x2736;this['comments']=_0x35d098,this[_0xc51bb8(0x136)]=document[_0xc51bb8(0x15a)](_0xc51bb8(0x142)),this[_0xc51bb8(0x12c)]=[],this[_0xc51bb8(0x133)]=0x0,this[_0xc51bb8(0x139)]=[],this[_0xc51bb8(0x14b)]=![],this[_0xc51bb8(0x146)]();}[_0xf096ba(0x13e)]=_0x50912d=>{const _0x243af9=_0xf096ba;return _0x50912d['flatMap'](_0x18bbb5=>_0x18bbb5[_0x243af9(0x14a)]?[_0x18bbb5,...this['filterAndFlatten'](_0x18bbb5[_0x243af9(0x14a)])]:[_0x18bbb5]);};[_0xf096ba(0x135)](_0x25b918){const _0x4cf7a3=_0xf096ba;return _0x25b918[_0x4cf7a3(0x124)](/(<([^>]+)>)/ig,'')[_0x4cf7a3(0x12e)]();}[_0xf096ba(0x147)](_0x3c5b88){const _0x58f618=_0xf096ba,_0x1c09f9=this[_0x58f618(0x135)](_0x3c5b88[_0x58f618(0x156)]);if(!_0x1c09f9)return![];const _0xbed29a=document[_0x58f618(0x127)]('div');return _0xbed29a[_0x58f618(0x122)]=_0x58f618(0x138),_0xbed29a[_0x58f618(0x12d)]='<div\x20class=\x22barrageHead\x22><a\x20class=\x22barrageTitle\x22\x20href=\x22javascript:sco.scrollTo(\x27post-comment\x27)\x22>'+GLOBAL_CONFIG[_0x58f618(0x125)][_0x58f618(0x158)][_0x58f618(0x134)]+_0x58f618(0x140)+_0x3c5b88['nick']+_0x58f618(0x149)+GLOBAL_CONFIG[_0x58f618(0x130)][_0x58f618(0x13b)]+_0x58f618(0x143)+_0x3c5b88[_0x58f618(0x131)]+_0x58f618(0x14d)+(_0x3c5b88['id']?_0x58f618(0x14f)+_0x3c5b88['id']+'\x27)':'javascript:sco.scrollTo(\x27post-comment\x27)')+'\x22>'+_0x1c09f9+_0x58f618(0x11f),this[_0x58f618(0x136)][_0x58f618(0x155)](_0xbed29a),this[_0x58f618(0x139)][_0x58f618(0x12a)](_0xbed29a),!![];}[_0xf096ba(0x141)](_0x4142a6){const _0x5da976=_0xf096ba;_0x4142a6[_0x5da976(0x13a)][_0x5da976(0x14e)](_0x5da976(0x13f)),setTimeout(()=>this[_0x5da976(0x136)][_0x5da976(0x121)](_0x4142a6),0x3e8);}[_0xf096ba(0x154)](){const _0x3d0cb8=_0xf096ba;if(this['barrageList'][_0x3d0cb8(0x159)]&&!this[_0x3d0cb8(0x14b)]){if(!this[_0x3d0cb8(0x147)](this['barrageList'][this[_0x3d0cb8(0x133)]]))return this[_0x3d0cb8(0x133)]=(this[_0x3d0cb8(0x133)]+0x1)%this[_0x3d0cb8(0x12c)][_0x3d0cb8(0x159)],this[_0x3d0cb8(0x154)]();this[_0x3d0cb8(0x133)]=(this[_0x3d0cb8(0x133)]+0x1)%this['barrageList'][_0x3d0cb8(0x159)];}this[_0x3d0cb8(0x139)][_0x3d0cb8(0x159)]>Math['min'](0x1,this['barrageList'][_0x3d0cb8(0x159)])&&!this[_0x3d0cb8(0x14b)]&&this[_0x3d0cb8(0x141)](this['barrageTimer'][_0x3d0cb8(0x150)]());}['initBarrage'](){const _0x571de5=_0xf096ba,_0x2e2e3e=utils[_0x571de5(0x157)][_0x571de5(0x137)](_0x571de5(0x128));this[_0x571de5(0x136)]['style']['display']=_0x2e2e3e?_0x571de5(0x13d):_0x571de5(0x144),this[_0x571de5(0x12c)]=this['filterAndFlatten'](this[_0x571de5(0x145)]),this[_0x571de5(0x136)][_0x571de5(0x12d)]='',clearInterval(this['commentInterval']),this[_0x571de5(0x14c)]=setInterval(()=>this[_0x571de5(0x154)](),0x1388);}[_0xf096ba(0x146)](){const _0x81bb1e=_0xf096ba;this['initBarrage'](),this['dom'][_0x81bb1e(0x148)]('mouseover',()=>this['hoverOnCommentBarrage']=!![]),this[_0x81bb1e(0x136)][_0x81bb1e(0x148)](_0x81bb1e(0x151),()=>this[_0x81bb1e(0x14b)]=![]);}[_0xf096ba(0x123)](){const _0x569798=_0xf096ba;clearInterval(this[_0x569798(0x14c)]),this[_0x569798(0x136)][_0x569798(0x129)]('mouseover',()=>this[_0x569798(0x14b)]=!![]),this[_0x569798(0x136)][_0x569798(0x129)](_0x569798(0x151),()=>this['hoverOnCommentBarrage']=![]),this[_0x569798(0x136)][_0x569798(0x12d)]='';}}function _0x562b(){const _0x3031bd=['</div><img\x20class=\x22barrageAvatar\x22\x20src=\x22','replies','hoverOnCommentBarrage','commentInterval','\x22/><a\x20class=\x22comment-barrage-close\x22\x20href=\x22javascript:sco.switchCommentBarrage();\x22><i\x20class=\x22solitude\x20st-close-fill\x22></i></a></div><a\x20class=\x22barrageContent\x22\x20href=\x22','add','javascript:sco.scrollTo(\x27','shift','mouseout','10792323NNfVVh','32478HpqMfw','manageBarrage','appendChild','content','saveToLocal','barrage','length','querySelector','209952OxSGhj','854DBnOiw','</a>','3742368aCgLQg','removeChild','className','destroy','replace','lang','1438760uXBNRa','createElement','commentBarrageSwitch','removeEventListener','push','currentBarrage','barrageList','innerHTML','trim','271090IyHbzI','comment','mailMd5','8MDfQRc','barrageIndex','title','sanitizeContent','dom','get','comment-barrage-item','barrageTimer','classList','avatar','5632610YtcmxI','flex','filterAndFlatten','out','</a><div\x20class=\x22barrageNick\x22>','removeBarrageItem','.comment-barrage','/avatar/','none','comments','init','createBarrageItem','addEventListener'];_0x562b=function(){return _0x3031bd;};return _0x562b();}function initializeCommentBarrage(_0x506af1){const _0x438d69=_0xf096ba;if(_0x506af1[_0x438d69(0x159)]===0x0)return;let _0x6d138e=window[_0x438d69(0x12b)];if(_0x6d138e)_0x6d138e[_0x438d69(0x123)]();window[_0x438d69(0x12b)]=new Barrage(_0x506af1);}
6
+ class Barrage {
7
+ constructor(comments) {
8
+ this.comments = comments;
9
+ this.dom = document.querySelector('.comment-barrage');
10
+ this.barrageList = [];
11
+ this.barrageIndex = 0;
12
+ this.barrageTimer = [];
13
+ this.hoverOnCommentBarrage = false;
14
+ this.init();
15
+ }
16
+
17
+ filterAndFlatten(comments) {
18
+ return comments.flatMap(comment => comment.replies ? [comment, ...this.filterAndFlatten(comment.replies)] : [comment]);
19
+ }
20
+
21
+ sanitizeContent(content) {
22
+ return content.replace(/(<([^>]+)>)/ig, '').trim();
23
+ }
24
+
25
+ createBarrageItem(comment) {
26
+ const sanitizedContent = this.sanitizeContent(comment.content);
27
+ if (!sanitizedContent) return false;
28
+
29
+ const barrageItem = document.createElement('div');
30
+ barrageItem.className = 'comment-barrage-item';
31
+ barrageItem.innerHTML = `
32
+ <div class="barrageHead">
33
+ <a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">
34
+ ${GLOBAL_CONFIG.lang.barrage.title}
35
+ </a>
36
+ <div class="barrageNick">${comment.nick}</div>
37
+ <img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}" />
38
+ <a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();">
39
+ <i class="solitude st-close-fill"></i>
40
+ </a>
41
+ </div>
42
+ <a class="barrageContent" href="${comment.id ? `javascript:sco.scrollTo('${comment.id}')` : 'javascript:sco.scrollTo(\'post-comment\')'}">
43
+ ${sanitizedContent}
44
+ </a>
45
+
46
+ `;
47
+ this.dom.appendChild(barrageItem);
48
+ this.barrageTimer.push(barrageItem);
49
+ return true;
50
+ }
51
+
52
+ removeBarrageItem(barrageItem) {
53
+ barrageItem.classList.add('out');
54
+ setTimeout(() => this.dom.removeChild(barrageItem), 1000);
55
+ }
56
+
57
+ manageBarrage() {
58
+ if (this.barrageList.length && !this.hoverOnCommentBarrage) {
59
+ if (!this.createBarrageItem(this.barrageList[this.barrageIndex])) {
60
+ this.barrageIndex = (this.barrageIndex + 1) % this.barrageList.length;
61
+ this.manageBarrage();
62
+ }
63
+ this.barrageIndex = (this.barrageIndex + 1) % this.barrageList.length;
64
+ }
65
+ if (this.barrageTimer.length > Math.min(1, this.barrageList.length) && !this.hoverOnCommentBarrage) {
66
+ this.removeBarrageItem(this.barrageTimer.shift());
67
+ }
68
+ }
69
+
70
+ initBarrage() {
71
+ const isBarrageEnabled = utils.saveToLocal.get('commentBarrageSwitch');
72
+ this.dom.style.display = isBarrageEnabled ? 'flex' : 'none';
73
+ this.barrageList = this.filterAndFlatten(this.comments);
74
+ this.dom.innerHTML = '';
75
+ clearInterval(this.commentInterval);
76
+ this.commentInterval = setInterval(() => this.manageBarrage(), 5000);
77
+ }
78
+
79
+ init() {
80
+ this.initBarrage();
81
+ this.dom.addEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
82
+ this.dom.addEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
83
+ }
84
+
85
+ destroy() {
86
+ clearInterval(this.commentInterval);
87
+ this.dom.removeEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
88
+ this.dom.removeEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
89
+ this.dom.innerHTML = '';
90
+ }
91
+ }
92
+
93
+ function initializeCommentBarrage(comments) {
94
+ if (comments.length === 0) return;
95
+ let existingBarrage = window.currentBarrage;
96
+ if (existingBarrage) existingBarrage.destroy();
97
+ window.currentBarrage = new Barrage(comments);
98
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * EasyDanmaku v1.0.0
3
- * author: Leonus
3
+ * author: @Lea321
4
4
  */
5
5
  class EasyDanmaku{constructor(t){this.container=this.checkParams(t),this.pathname=t.page||null,this.wrapperStyle=t.wrapperStyle||null,this.line=t.line||10,this.speed=t.speed||5,this.runtime=t.runtime||10,this.colourful=t.colourful||!1,this.loop=t.loop||!1,this.hover=t.hover||!1,this.coefficient=t.coefficient||1.38,this.originIndex=0,this.originList=null,this.offsetValue=this.container.offsetHeight/this.line,this.vipIndex=0,this.overflowArr=[],this.clearIng=!1,this.cleartimer=null,this.init(),this.handleEvents(t)}handleEvents(t){this.onComplete=t.onComplete||null,this.onHover=t.onHover||null}init(){this.runstatus=1,this.aisle=[],this.container.style.overflow="hidden",this.hover&&this.handleMouseHover(),"relative"!==Utils.getStyle(this.container,"position")&&"fixed"!==Utils.getStyle(this.container,"position")&&(this.container.style.position="relative");for(let t=0;t<this.line;t++)this.aisle.push({normalRow:!0,vipRow:!0})}checkParams(t){if(!document.querySelector(t.el))throw`Could not find the ${t.el} element`;if(t.wrapperStyle&&"string"!=typeof t.wrapperStyle)throw"The type accepted by the wrapperStyle parameter is string";if(t.line&&"number"!=typeof t.line)throw"The type accepted by the line parameter is number";if(t.speed&&"number"!=typeof t.speed)throw"The type accepted by the speed parameter is number";if(t.colourful&&"boolean"!=typeof t.colourful)throw"The type accepted by the colourful parameter is boolean";if(t.runtime&&"number"!=typeof t.runtime)throw"The type accepted by the runtime parameter is number";if(t.loop&&"boolean"!=typeof t.loop)throw"The type accepted by the loop parameter is boolean";if(t.coefficient&&"number"!=typeof t.coefficient)throw"The type accepted by the coefficient parameter is number";if(t.hover&&"boolean"!=typeof t.hover)throw"The type accepted by the hover parameter is boolean";if(t.onComplete&&"function"!=typeof t.onComplete)throw"The type accepted by the onComplete parameter is function";if(t.onHover&&"function"!=typeof t.onHover)throw"The type accepted by the onHover parameter is function";return document.querySelector(t.el)}send(t,e=null,i=null){if(0==this.runstatus)return void this.overflowArr.push({content:t,normalClass:e});if(t.length<1)return;this.offsetValue=this.container.offsetHeight/this.line;let n=document.createElement("div"),r=0,s=this.speed,o=null,l=0;n.innerHTML=t,n.style.display="inline-block",n.classList.add("default-style"),(e||this.wrapperStyle)&&n.classList.add(e||this.wrapperStyle),function a(){if(r=Math.round(Math.random()*(this.line-1)),this.aisle[r].normalRow){this.aisle[r].normalRow=!1,this.container.appendChild(n),s+=n.offsetWidth/n.parentNode.offsetWidth*2,n.style.cssText=`\n text-align:center;\n min-width:130px;\n will-change: transform;\n position:absolute;\n right: -${n.offsetWidth+130}px;\n transition: transform ${s}s linear;\n transform: translateX(-${n.parentNode.offsetWidth+n.offsetWidth+130}px);\n top: ${r*this.offsetValue}px;\n line-height:${this.offsetValue}px;\n color:${this.colourful?"#"+("00000"+(16777216*Math.random()|0).toString(16)).substr(-6):void 0}\n `;let t=(n.parentNode.offsetWidth+n.offsetWidth)/s/60;o=setInterval((()=>{l+=t,l>n.offsetWidth*this.coefficient&&(this.aisle[r].normalRow=!0,clearInterval(o))}),16.66),setTimeout((()=>{1!=n.getAttribute("relieveDel")&&(i&&i({runtime:s,target:n,width:n.offsetWidth}),n.remove())}),1e3*s)}else{this.aisle.some((t=>!0===t.normalRow))?a.call(this):(()=>{this.overflowArr.push({content:t,normalClass:e}),this.clearIng||this.clearOverflowDanmakuArray()})()}}.call(this)}batchSend(t,e=!1,i=null){let n=this.runtime||1.23*t.length;this.originList=t,this.hasAvatar=e,this.normalClass=i;let r=setInterval((()=>{location.pathname!=this.pathname&&clearInterval(r),this.originIndex>t.length-1?(clearInterval(r),this.originIndex=0,this.onComplete&&this.onComplete(),this.loop&&this.batchSend(this.originList,e,i)):(e?this.send(`${t[this.originIndex].url?'<a href="'+t[this.originIndex].url+'">':""}<img src=${t[this.originIndex].avatar}>\n <p>${t[this.originIndex].content}</p>${t[this.originIndex].url?"</a>":""}\n `,i||this.wrapperStyle):this.send(t[this.originIndex],i||this.wrapperStyle),this.originIndex++)}),n/t.length*1e3)}centeredSend(t,e,i=3e3,n=null){let r=document.createElement("div"),s=0;r.innerHTML=t,(e||this.wrapperStyle)&&r.classList.add(e||this.wrapperStyle),function t(){if(this.aisle[s].vipRow)this.container.appendChild(r),r.style.cssText=`\n position:absolute;\n left:50%;\n transform:translateX(-50%);\n top: ${s*this.offsetValue}px;\n `,this.aisle[s].vipRow=!1,setTimeout((()=>{n&&n({duration:i,target:r,width:r.offsetWidth}),r.remove(),this.aisle[s].vipRow=!0}),i);else{if(s++,s>this.line-1)return;t.call(this)}}.call(this)}play(){const t=this.container.children;for(let e=0;e<t.length;e++)this.controlDanmakurunStatus(t[e],1);this.runstatus=1,0!==this.overflowArr.length&&this.clearOverflowDanmakuArray()}pause(){const t=this.container.children;for(let e=0;e<t.length;e++)this.controlDanmakurunStatus(t[e],0);this.runstatus=0}controlDanmakurunStatus(t,e){const i=0,n=/-(\S*),/;if(e===1){clearTimeout(t.timer);const e=Utils.getStyle(t,"transform").match(n)[1];t.style.transition=`transform ${this.speed}s linear`,t.style.transform=`translateX(-${t.parentNode.offsetWidth+parseInt(e)+t.offsetWidth+130}px)`,t.timer=setTimeout((()=>{t.remove()}),1e3*this.speed)}else if(e===i){clearTimeout(t.timer);const e=Utils.getStyle(t,"transform").match(n)[1];t.style.transition="transform 0s linear",t.style.transform=`translateX(-${e}px)`,t.setAttribute("relieveDel",1)}}handleMouseHover(){Utils.eventDelegation(this.container,"default-style","mouseover",(t=>{t.style["z-index"]=1e3,this.controlDanmakurunStatus(t,0),this.onHover&&this.onHover(t)})),Utils.eventDelegation(this.container,"default-style","mouseout",(t=>{t.style.zIndex=1,1==this.runstatus&&this.controlDanmakurunStatus(t,1)}))}clearOverflowDanmakuArray(){clearInterval(this.cleartimer),this.clearIng=!0;let t=0;this.cleartimer=setInterval((()=>{0===this.overflowArr.length?(t++,t>20&&(clearInterval(this.cleartimer),this.clearIng=!1)):(this.send(this.overflowArr[0].content,this.overflowArr[0].normalClass||this.wrapperStyle),this.overflowArr.shift())}),500)}}class Utils{static getStyle(t,e){return window.getComputedStyle(t,null)[e]}static eventDelegation(t,e,i,n){t.addEventListener(i,(t=>{try{t.target.className.includes(e)?n(t.target):t.target.parentNode.className.includes(e)&&n(t.target.parentNode)}catch(t){}}))}}