hexo-theme-solitude 2.0.10 → 2.0.12-rc.1
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.
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -8
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/README_zh-Hans.md +1 -1
- package/README_zh-Hant.md +1 -1
- package/SECURITY.md +4 -4
- package/_config.yml +9 -28
- package/layout/includes/console.pug +1 -1
- package/layout/includes/inject/body.pug +9 -5
- package/layout/includes/nav.pug +2 -2
- package/layout/includes/widgets/aside/aside.pug +1 -1
- package/layout/includes/widgets/home/postList.pug +1 -20
- package/layout/includes/widgets/page/links/banner.pug +14 -14
- package/layout/includes/widgets/post/post-ai.pug +1 -1
- package/layout/includes/widgets/randomlink.pug +1 -2
- package/layout/includes/widgets/third-party/tianli-talk.pug +1 -1
- package/package.json +4 -3
- package/plugins.yml +5 -4
- package/scripts/event/cdn.js +7 -2
- package/scripts/event/merge_config.js +5 -15
- package/source/css/_global/function.styl +1 -1
- package/source/css/_layout/console.styl +7 -4
- package/source/css/_layout/recent-post.styl +26 -46
- package/source/css/_page/_home/home-top.styl +3 -8
- package/source/css/_page/music.styl +8 -0
- package/source/css/_page/recentcomment.styl +1 -3
- package/source/css/_post/meta.styl +2 -2
- package/source/css/_post/postAI.styl +6 -4
- package/source/css/_tags/gallery.styl +2 -1
- package/source/css/third_party/tianli_talk.styl +1 -1
- package/source/css/var.styl +7 -7
- package/source/js/covercolor/ave.js +58 -0
- package/source/js/covercolor/local.js +10 -82
- package/source/js/main.js +5 -6
- package/source/js/music.js +2 -9
- package/source/js/third_party/barrage.min.js +1 -1
- package/source/js/third_party/post_ai.min.js +1 -0
- package/source/js/tw_cn.js +55 -87
- package/.editorconfig +0 -9
- package/.github/workflows/stale.yml +0 -19
- package/source/img/avatar.avif +0 -0
- package/source/img/happy-sticker.avif +0 -0
- package/source/js/third_party/efu_ai.min.js +0 -6
@@ -28,6 +28,7 @@
|
|
28
28
|
justify-content start
|
29
29
|
flex-wrap wrap
|
30
30
|
align-content space-between
|
31
|
+
width 100%
|
31
32
|
gap .5rem
|
32
33
|
|
33
34
|
+maxWidth1200()
|
@@ -79,7 +80,7 @@
|
|
79
80
|
.top-post-item
|
80
81
|
display flex
|
81
82
|
flex-direction column
|
82
|
-
|
83
|
+
flex 1 1 30%
|
83
84
|
align-items flex-start
|
84
85
|
background var(--efu-card-bg)
|
85
86
|
border-radius 12px
|
@@ -92,10 +93,6 @@
|
|
92
93
|
box-shadow var(--efu-shadow-border)
|
93
94
|
min-width fit-content
|
94
95
|
|
95
|
-
&:nth-last-child(2):nth-child(1),
|
96
|
-
&:nth-last-child(1):nth-child(2)
|
97
|
-
width calc(100% / 2 - 0.5rem)
|
98
|
-
|
99
96
|
+maxWidth1200()
|
100
97
|
width 200px
|
101
98
|
min-width 200px
|
@@ -272,9 +269,7 @@
|
|
272
269
|
color var(--efu-white)
|
273
270
|
position relative
|
274
271
|
background-size 200%
|
275
|
-
|
276
|
-
&:not(:last-child)
|
277
|
-
margin-right 10px
|
272
|
+
margin-right 10px
|
278
273
|
|
279
274
|
&:hover
|
280
275
|
background-position 100% 0
|
@@ -5,6 +5,14 @@ body[data-type=music]
|
|
5
5
|
#page-header.not-top-img #nav .back-home-button
|
6
6
|
color var(--efu-white)
|
7
7
|
|
8
|
+
#page-header #nav #nav-right .nav-button a.console_switchbutton label i
|
9
|
+
background: var(--efu-white)
|
10
|
+
|
11
|
+
#page-header #nav #nav-right .nav-button a.console_switchbutton
|
12
|
+
&:hover
|
13
|
+
label i
|
14
|
+
background var(--efu-card-bg)
|
15
|
+
|
8
16
|
.page
|
9
17
|
.layout#content-inner
|
10
18
|
background none
|
@@ -1,15 +1,13 @@
|
|
1
1
|
div.console_recentcomments
|
2
2
|
display flex
|
3
3
|
flex-wrap wrap
|
4
|
-
gap
|
4
|
+
gap 8px
|
5
5
|
min-height 100px
|
6
6
|
width 100%
|
7
|
-
margin-top .5rem
|
8
7
|
|
9
8
|
.comment-card
|
10
9
|
position relative
|
11
10
|
width calc(100% / 3 - 8px)
|
12
|
-
min-width fit-content
|
13
11
|
background var(--efu-card-bg)
|
14
12
|
border-radius 12px
|
15
13
|
border var(--style-border-always)
|
@@ -114,7 +114,7 @@
|
|
114
114
|
overflow hidden
|
115
115
|
margin 0 -20% 0 auto
|
116
116
|
transform rotate(10deg) translateY(-8%) scale(1.8)
|
117
|
-
filter blur(
|
117
|
+
filter blur(30px)
|
118
118
|
opacity 0
|
119
119
|
|
120
120
|
&.loaded
|
@@ -383,4 +383,4 @@
|
|
383
383
|
background var(--efu-hovertext)
|
384
384
|
border-radius 12px 12px 0 0
|
385
385
|
+minWidth768()
|
386
|
-
min-height 250px
|
386
|
+
min-height 250px
|
@@ -16,7 +16,6 @@
|
|
16
16
|
color var(--efu-lighttext)
|
17
17
|
border-radius 8px
|
18
18
|
align-items center
|
19
|
-
padding 0 12px
|
20
19
|
user-select none
|
21
20
|
|
22
21
|
.ai-title-left
|
@@ -116,7 +115,6 @@
|
|
116
115
|
.ai-bottom
|
117
116
|
width 100%
|
118
117
|
margin-top 12px
|
119
|
-
padding 0 12px
|
120
118
|
display flex
|
121
119
|
|
122
120
|
.ai-tips
|
@@ -126,5 +124,9 @@
|
|
126
124
|
|
127
125
|
.ai-report
|
128
126
|
font-size 12px
|
129
|
-
color var(--efu-secondtext)
|
130
|
-
white-space nowrap
|
127
|
+
color var(--efu-secondtext) !important
|
128
|
+
white-space nowrap
|
129
|
+
border-bottom none!important
|
130
|
+
|
131
|
+
&:hover
|
132
|
+
background: none !important
|
package/source/css/var.styl
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
error_img = hexo-config('errorpage.img')
|
2
2
|
|
3
3
|
$dark_theme = convert(hexo-config('theme_color.dark'))
|
4
|
-
$dark_theme_op = convert(hexo-config('theme_color.
|
5
|
-
$dark_theme_op_deep = convert(hexo-config('theme_color.
|
6
|
-
$dark_theme_none = convert(hexo-config('theme_color.
|
4
|
+
$dark_theme_op = convert(hexo-config('theme_color.dark') + '23')
|
5
|
+
$dark_theme_op_deep = convert(hexo-config('theme_color.dark') + 'dd')
|
6
|
+
$dark_theme_none = convert(hexo-config('theme_color.dark') + '00')
|
7
7
|
$light_theme = convert(hexo-config('theme_color.light'))
|
8
|
-
$light_theme_op = convert(hexo-config('theme_color.
|
9
|
-
$light_theme_op_deep = convert(hexo-config('theme_color.
|
10
|
-
$light_theme_none = hexo-config('theme_color.
|
8
|
+
$light_theme_op = convert(hexo-config('theme_color.light') + '23')
|
9
|
+
$light_theme_op_deep = convert(hexo-config('theme_color.light') + 'dd')
|
10
|
+
$light_theme_none = convert(hexo-config('theme_color.light') + '00')
|
11
11
|
|
12
12
|
$todayCardColor = convert(hexo-config('hometop.recommendList.color'))
|
13
13
|
|
@@ -29,4 +29,4 @@ $line-height-code-block = 1.6
|
|
29
29
|
$font-size = unquote(hexo-config('font.font-size'))
|
30
30
|
$code-font-size = unquote(hexo-config('font.code-font-size'))
|
31
31
|
$font-family = unquote(hexo-config('font.font-family'))
|
32
|
-
$code-font-family = unquote(hexo-config('font.code-font-family'))
|
32
|
+
$code-font-family = unquote(hexo-config('font.code-font-family'))
|
@@ -0,0 +1,58 @@
|
|
1
|
+
const coverColor = () => {
|
2
|
+
const path = document.getElementById("post-cover")?.src;
|
3
|
+
path ? handleApiColor(path) : setDefaultThemeColors();
|
4
|
+
}
|
5
|
+
|
6
|
+
const handleApiColor = (path) => {
|
7
|
+
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
|
8
|
+
const color = cacheGroup.postcolor?.[path]?.value;
|
9
|
+
color ? setThemeColors(color) : img2color(path);
|
10
|
+
}
|
11
|
+
|
12
|
+
const img2color = (src) => {
|
13
|
+
fetch(`${src}?imageAve`)
|
14
|
+
.then(response => response.json())
|
15
|
+
.then(({ RGB }) => {
|
16
|
+
RGB = `#${RGB.slice(2)}`;
|
17
|
+
setThemeColors(RGB);
|
18
|
+
cacheColor(src, RGB);
|
19
|
+
})
|
20
|
+
.catch(console.error);
|
21
|
+
}
|
22
|
+
|
23
|
+
const setThemeColors = (value) => {
|
24
|
+
if (!value) return setDefaultThemeColors();
|
25
|
+
const [r, g, b] = value.match(/\w\w/g).map(x => parseInt(x, 16));
|
26
|
+
const [main, op, opDeep, none] = [`${value}`, `${value}23`, `${value}dd`, `${value}00`];
|
27
|
+
document.documentElement.style.setProperty('--efu-main', main);
|
28
|
+
document.documentElement.style.setProperty('--efu-main-op', op);
|
29
|
+
document.documentElement.style.setProperty('--efu-main-op-deep', opDeep);
|
30
|
+
document.documentElement.style.setProperty('--efu-main-none', none);
|
31
|
+
adjustBrightness(r, g, b);
|
32
|
+
document.getElementById("coverdiv").classList.add("loaded");
|
33
|
+
initThemeColor();
|
34
|
+
}
|
35
|
+
|
36
|
+
const setDefaultThemeColors = () => {
|
37
|
+
const vars = ['--efu-theme', '--efu-theme-op', '--efu-theme-op-deep', '--efu-theme-none'];
|
38
|
+
vars.forEach((varName, i) => document.documentElement.style.setProperty(['--efu-main', '--efu-main-op', '--efu-main-op-deep', '--efu-main-none'][i], `var(${varName})`));
|
39
|
+
initThemeColor();
|
40
|
+
}
|
41
|
+
|
42
|
+
const cacheColor = (src, color) => {
|
43
|
+
const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || { postcolor: {} };
|
44
|
+
cacheGroup.postcolor[src] = { value: color, expiration: Date.now() + coverColorConfig.time };
|
45
|
+
localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
|
46
|
+
}
|
47
|
+
|
48
|
+
const adjustBrightness = (r, g, b) => {
|
49
|
+
if (Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000) < 125) {
|
50
|
+
document.querySelectorAll('.card-content').forEach(item =>
|
51
|
+
item.style.setProperty('--efu-card-bg', 'var(--efu-white)')
|
52
|
+
);
|
53
|
+
document.querySelectorAll('.author-info__sayhi').forEach(item => {
|
54
|
+
item.style.setProperty('background', 'var(--efu-white-op)');
|
55
|
+
item.style.setProperty('color', 'var(--efu-white)');
|
56
|
+
});
|
57
|
+
}
|
58
|
+
}
|
@@ -12,93 +12,21 @@ function setDefaultThemeColors() {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
const localColor = path => {
|
15
|
+
var colorThief = new ColorThief();
|
15
16
|
const img = new Image();
|
16
17
|
img.crossOrigin = "Anonymous";
|
17
|
-
img.onload = () => setThemeColors(
|
18
|
+
img.onload = () => setThemeColors(rgbToHex(colorThief.getColor(img)));
|
18
19
|
img.onerror = () => console.error('Image Error');
|
19
20
|
img.src = path;
|
20
21
|
}
|
21
22
|
|
22
|
-
const
|
23
|
-
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return getContrastYIQ(value) === "light" ? LightenDarkenColor(value, -50) : LightenDarkenColor(value, 20);
|
30
|
-
}
|
31
|
-
|
32
|
-
function calculateRGB(data) {
|
33
|
-
let r = 0, g = 0, b = 0;
|
34
|
-
const step = 5;
|
35
|
-
for (let i = 0; i < data.length; i += 4 * step) {
|
36
|
-
r += data[i];
|
37
|
-
g += data[i + 1];
|
38
|
-
b += data[i + 2];
|
39
|
-
}
|
40
|
-
r = Math.floor(r / (data.length / 4 / step));
|
41
|
-
g = Math.floor(g / (data.length / 4 / step));
|
42
|
-
b = Math.floor(b / (data.length / 4 / step));
|
43
|
-
return {r, g, b};
|
44
|
-
}
|
45
|
-
|
46
|
-
function rgbToHex(r, g, b) {
|
47
|
-
return "#" + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
|
48
|
-
}
|
49
|
-
|
50
|
-
function LightenDarkenColor(col, amt) {
|
51
|
-
let usePound = false;
|
52
|
-
|
53
|
-
if (col[0] === "#") {
|
54
|
-
col = col.slice(1);
|
55
|
-
usePound = true;
|
56
|
-
}
|
57
|
-
|
58
|
-
const num = parseInt(col, 16);
|
59
|
-
const r = Math.min(255, Math.max(0, (num >> 16) + amt * 2));
|
60
|
-
const b = Math.min(255, Math.max(0, ((num >> 8) & 0xff) + amt * 2));
|
61
|
-
const g = Math.min(255, Math.max(0, (num & 0xff) + amt * 2));
|
62
|
-
|
63
|
-
return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
|
64
|
-
}
|
65
|
-
|
66
|
-
function getContrastYIQ(hexcolor) {
|
67
|
-
let colorrgb = colorRgb(hexcolor);
|
68
|
-
let colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
69
|
-
let red = colors[1];
|
70
|
-
let green = colors[2];
|
71
|
-
let blue = colors[3];
|
72
|
-
let brightness = (red * 299) + (green * 587) + (blue * 114);
|
73
|
-
brightness = brightness / 255000;
|
74
|
-
return brightness >= 0.5 ? "light" : "dark";
|
75
|
-
}
|
76
|
-
|
77
|
-
function colorRgb(str) {
|
78
|
-
const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
|
79
|
-
const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
|
80
|
-
const HEX_SHORT_LENGTH = 4;
|
81
|
-
|
82
|
-
if (!str || typeof str !== 'string') {
|
83
|
-
return str;
|
84
|
-
}
|
85
|
-
|
86
|
-
const sColor = str.toLowerCase();
|
87
|
-
let hexValue = "";
|
88
|
-
|
89
|
-
if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
|
90
|
-
hexValue = sColor.length === HEX_SHORT_LENGTH ?
|
91
|
-
sColor.replace(/^#(.)/g, "#$1$1") :
|
92
|
-
sColor;
|
93
|
-
|
94
|
-
const rgbValue = hexValue.slice(1)
|
95
|
-
.match(/.{2}/g)
|
96
|
-
.map(val => parseInt(val, 16));
|
97
|
-
|
98
|
-
return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
|
99
|
-
} else {
|
100
|
-
return sColor;
|
101
|
-
}
|
23
|
+
const rgbToHex = ([r, g, b]) => {
|
24
|
+
const hex = '#' + [r, g, b].map(x => {
|
25
|
+
const component = Math.floor(x * 0.8);
|
26
|
+
const hexValue = component.toString(16);
|
27
|
+
return hexValue.length === 1 ? '0' + hexValue : hexValue;
|
28
|
+
}).join('');
|
29
|
+
return hex;
|
102
30
|
}
|
103
31
|
|
104
32
|
function setThemeColors(value, r = null, g = null, b = null) {
|
@@ -139,4 +67,4 @@ function setThemeColors(value, r = null, g = null, b = null) {
|
|
139
67
|
document.documentElement.style.setProperty('--efu-main-none', 'var(--efu-theme-none)');
|
140
68
|
initThemeColor();
|
141
69
|
}
|
142
|
-
}
|
70
|
+
}
|
package/source/js/main.js
CHANGED
@@ -27,10 +27,9 @@ const sidebarFn = () => {
|
|
27
27
|
});
|
28
28
|
}
|
29
29
|
const scrollFn = () => {
|
30
|
-
const innerHeight = window.innerHeight;
|
31
30
|
let initTop = 0;
|
32
31
|
const $header = document.getElementById('page-header');
|
33
|
-
const throttledScroll = utils.throttle((
|
32
|
+
const throttledScroll = utils.throttle(() => {
|
34
33
|
initThemeColor();
|
35
34
|
const currentTop = window.scrollY || document.documentElement.scrollTop;
|
36
35
|
const isDown = scrollDirection(currentTop);
|
@@ -155,10 +154,10 @@ const sco = {
|
|
155
154
|
$console.classList.toggle("on", this.musicPlaying);
|
156
155
|
if (this.musicPlaying) {
|
157
156
|
$meting.aplayer.play();
|
158
|
-
rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.stop) && ($rm_icon.className = 'solitude st-pause-fill')
|
157
|
+
(typeof rm !== 'undefined') && rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.stop) && ($rm_icon.className = 'solitude st-pause-fill')
|
159
158
|
} else {
|
160
159
|
$meting.aplayer.pause();
|
161
|
-
rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.start) && ($rm_icon.className = 'solitude st-play-fill')
|
160
|
+
(typeof rm !== 'undefined') && rm?.menuItems.music[0] && ($rm_text.textContent = GLOBAL_CONFIG.right_menu.music.start) && ($rm_icon.className = 'solitude st-play-fill')
|
162
161
|
}
|
163
162
|
},
|
164
163
|
switchCommentBarrage() {
|
@@ -598,7 +597,7 @@ class tabs {
|
|
598
597
|
|
599
598
|
static clickFnOfTabs() {
|
600
599
|
document.querySelectorAll('#article-container .tab > button').forEach((item) => {
|
601
|
-
item.addEventListener('click', function (
|
600
|
+
item.addEventListener('click', function () {
|
602
601
|
const that = this;
|
603
602
|
const $tabItem = that.parentNode;
|
604
603
|
if (!$tabItem.classList.contains('active')) {
|
@@ -668,7 +667,7 @@ window.refreshFn = () => {
|
|
668
667
|
lazyload.enable && utils.lazyloadImg();
|
669
668
|
lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar,.gallery-group img, .no-lightbox)"));
|
670
669
|
randomlink && randomLinksList();
|
671
|
-
post_ai && is_post &&
|
670
|
+
post_ai && is_post && ai.init();
|
672
671
|
sco.switchComments();
|
673
672
|
initObserver();
|
674
673
|
if (is_home) {
|
package/source/js/music.js
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
* Music Player
|
3
|
-
* @description Initialize the music player and add event listeners to control the player
|
4
|
-
*/
|
5
|
-
class ScoMusicPlayer {
|
1
|
+
class MusicPlayer {
|
6
2
|
constructor() {
|
7
3
|
this.init();
|
8
4
|
}
|
@@ -113,11 +109,8 @@ class ScoMusicPlayer {
|
|
113
109
|
}
|
114
110
|
}
|
115
111
|
|
116
|
-
/**
|
117
|
-
* Initialize the music player
|
118
|
-
*/
|
119
112
|
function initializeMusicPlayer() {
|
120
113
|
let exitingMusic = window.scoMusic;
|
121
114
|
if (exitingMusic) exitingMusic.destroy();
|
122
|
-
window.scoMusic = new
|
115
|
+
window.scoMusic = new MusicPlayer();
|
123
116
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Barrage Comment
|
3
|
-
* author: @
|
3
|
+
* author: @everfu
|
4
4
|
* date: 2024-04-28
|
5
5
|
*/
|
6
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);}
|
@@ -0,0 +1 @@
|
|
1
|
+
class POST_AI{constructor(){this.root="https://summary.tianli0.top";this.aiTalkMode=false;this.aiPostExplanation='';this.config=GLOBAL_CONFIG.post_ai;this.scoGPTIsRunning=false;console.log(' %c TianliGPT %c 文章摘要 %c https://postchat.zhheo.com','background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff','background:#ff9a9a ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff','background:unset ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff')}init(){if(!document.querySelector(".ai-explanation"))return;this.scoGPTIsRunning=false;this.aiPostExplanation=PAGE_CONFIG.ai_text?PAGE_CONFIG.ai_text+"":false;if(!this.aiPostExplanation){this.generate()}else{this.aiShowAnimation(Promise.resolve(this.aiPostExplanation))}this.AIEngine()}getTitleAndContent(){const e=document.getElementById("article-container");const t=document.title;const n=e.getElementsByTagName("p");const i=e.querySelectorAll("h1, h2, h3, h4, h5");return(t+" "+Array.from(i).concat(Array.from(n)).map(e=>e.innerText.replace(/https?:\/\/[^\s]+/g,"")).join(" ")).slice(0,1000)}async generate(){this.aiShowAnimation(this.fetch(document.title,this.getTitleAndContent(),this.config.key))}async fetch(title,content,key){const url=`${this.root}/?content=${encodeURIComponent(content)}&title=${title}&key=${encodeURIComponent(key)}&url=${encodeURIComponent(window.location.href)}`;const response=await fetch(url);const data=await response.json();if(response.ok){this.aiPostExplanation=data.summary;return data.summary}else{console.error("Request failed:",data.err_msg);return data.err_msg}}aiShowAnimation(promise,onComplete=false){const explanationElement=document.querySelector(".ai-explanation");const tagElement=document.querySelector(".ai-tag");if(!explanationElement||this.scoGPTIsRunning)return;this.scoGPTIsRunning=true;this.cleanSuggestions();tagElement.classList.add("loadingAI");explanationElement.style.display="block";explanationElement.innerHTML='生成中...<span class="blinking-cursor"></span>';setTimeout(()=>{let startTime,update,currentIndex=0,isIntersecting=true,isInitial=true;const observer=new IntersectionObserver(entries=>{isIntersecting=entries[0].isIntersecting;if(isIntersecting)requestAnimationFrame(update)},{threshold:0});promise.then(result=>{startTime=performance.now();update=()=>{if(currentIndex<result.length&&isIntersecting){const now=performance.now();const timeElapsed=now-startTime;const char=result.slice(currentIndex,currentIndex+1);const isPunctuation=/[,。!、?,.!?]/.test(char);const isAlphaNumeric=/[a-zA-Z0-9]/.test(char);const delay=isPunctuation?100*Math.random()+100:(isAlphaNumeric?10:25);if(timeElapsed>=delay){explanationElement.innerText=result.slice(0,currentIndex+1);startTime=now;currentIndex++;if(currentIndex<result.length){explanationElement.innerHTML=result.slice(0,currentIndex)+'<span class="blinking-cursor"></span>'}else{explanationElement.innerHTML=result;explanationElement.style.display="block";this.scoGPTIsRunning=false;tagElement.classList.remove("loadingAI");observer.disconnect();if(onComplete)this.createSuggestions()}}if(isIntersecting)requestAnimationFrame(update)}};if(isIntersecting&&isInitial){requestAnimationFrame(update);isInitial=false}observer.observe(explanationElement)}).catch(error=>{console.error("检索信息失败:",error);explanationElement.innerHTML="检索信息失败";explanationElement.style.display="block";this.scoGPTIsRunning=false;tagElement.classList.remove("loadingAI");observer.disconnect()})},2000)}AIEngine(){const e=document.querySelector(".ai-tag");if(e){e.addEventListener("click",()=>{if(!this.scoGPTIsRunning){this.aiTalkMode=true;this.aiShowAnimation(Promise.resolve(this.config.talk),true)}})}}cleanSuggestions(){const e=document.querySelector(".ai-suggestions");if(e){e.innerHTML=""}else{console.error("没有这个元素:'ai-suggestions'")}}createSuggestions(){if(this.aiTalkMode){this.cleanSuggestions();this.createSuggestionItemWithAction("这篇文章讲了什么?",()=>{if(this.aiPostExplanation===""){this.generate()}else{this.aiShowAnimation(Promise.resolve(this.aiPostExplanation),true)}});if(this.config.randomPost){this.createSuggestionItemWithAction("带我去看看其他文章",()=>toRandomPost())}this.aiTalkMode=true}}createSuggestionItemWithAction(text,action){const suggestions=document.querySelector(".ai-suggestions");if(!suggestions){console.error("无法找到具有class为ai-suggestions的元素");return}const item=document.createElement("div");item.classList.add("ai-suggestions-item");item.textContent=text;item.addEventListener("click",action);suggestions.appendChild(item)}}const ai=new POST_AI();
|