hexo-theme-solitude 1.3.1 → 1.4.0

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 (261) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +107 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +13 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.yml +14 -0
  5. package/.github/workflows/npm-publish.yml +21 -0
  6. package/CONTRIBUTING.md +0 -0
  7. package/LICENSE +0 -0
  8. package/README.md +60 -43
  9. package/README_EN.md +60 -42
  10. package/_config.yml +606 -451
  11. package/languages/en-US.yml +3 -23
  12. package/languages/zh-CN.yml +3 -23
  13. package/layout/404.pug +0 -0
  14. package/layout/archive.pug +0 -0
  15. package/layout/category.pug +0 -0
  16. package/layout/includes/body/mode.pug +1 -6
  17. package/layout/includes/console.pug +3 -3
  18. package/layout/includes/footer.pug +16 -15
  19. package/layout/includes/head/config.pug +38 -30
  20. package/layout/includes/head/opengraph.pug +0 -0
  21. package/layout/includes/head/pwa.pug +5 -44
  22. package/layout/includes/head.pug +3 -1
  23. package/layout/includes/header.pug +0 -0
  24. package/layout/includes/inject/body.pug +114 -65
  25. package/layout/includes/inject/head.pug +11 -46
  26. package/layout/includes/layout.pug +1 -2
  27. package/layout/includes/loading.pug +0 -0
  28. package/layout/includes/mixins/articleSort.pug +0 -0
  29. package/layout/includes/mixins/pagination.pug +0 -0
  30. package/layout/includes/nav.pug +1 -1
  31. package/layout/includes/page/about.pug +1 -1
  32. package/layout/includes/page/categories.pug +0 -0
  33. package/layout/includes/page/default.pug +0 -0
  34. package/layout/includes/page/equipment.pug +0 -0
  35. package/layout/includes/page/links.pug +2 -2
  36. package/layout/includes/page/music.pug +0 -0
  37. package/layout/includes/page/not_configured.pug +0 -0
  38. package/layout/includes/page/rss.pug +3 -3
  39. package/layout/includes/page/says.pug +15 -15
  40. package/layout/includes/page/tags.pug +0 -0
  41. package/layout/includes/page/tlink.pug +1 -0
  42. package/layout/includes/recent-posts.pug +0 -0
  43. package/layout/includes/sidebar.pug +0 -0
  44. package/layout/includes/widgets/aside/aside.pug +6 -6
  45. package/layout/includes/widgets/aside/asideAllInfo.pug +0 -0
  46. package/layout/includes/widgets/aside/asideArchive.pug +0 -0
  47. package/layout/includes/widgets/aside/asideCustom.pug +1 -1
  48. package/layout/includes/widgets/aside/asideFlipCard.pug +0 -0
  49. package/layout/includes/widgets/aside/asideInfoCard.pug +3 -3
  50. package/layout/includes/widgets/aside/asideNewestPost.pug +0 -0
  51. package/layout/includes/widgets/aside/asideSwitch.pug +0 -4
  52. package/layout/includes/widgets/aside/asideTag.pug +1 -1
  53. package/layout/includes/widgets/aside/asideToc.pug +0 -0
  54. package/layout/includes/widgets/aside/asideWebInfo.pug +2 -2
  55. package/layout/includes/widgets/home/banner.pug +0 -0
  56. package/layout/includes/widgets/home/bb/json.pug +22 -0
  57. package/layout/includes/widgets/home/bb/local.pug +17 -0
  58. package/layout/includes/widgets/home/bb/memos.pug +25 -0
  59. package/layout/includes/widgets/home/bbTimeList.pug +11 -7
  60. package/layout/includes/widgets/home/categoryBar.pug +0 -0
  61. package/layout/includes/widgets/home/categoryGroup.pug +1 -1
  62. package/layout/includes/widgets/home/hometop.pug +0 -0
  63. package/layout/includes/widgets/home/postList.pug +0 -0
  64. package/layout/includes/widgets/home/topGroup.pug +0 -0
  65. package/layout/includes/widgets/nav/left.pug +0 -0
  66. package/layout/includes/widgets/nav/menu.pug +1 -1
  67. package/layout/includes/widgets/nav/right.pug +6 -5
  68. package/layout/includes/widgets/page/about/authorinfo.pug +10 -9
  69. package/layout/includes/widgets/page/about/award.pug +0 -0
  70. package/layout/includes/widgets/page/about/contentinfo.pug +35 -34
  71. package/layout/includes/widgets/page/about/hobbies.pug +21 -17
  72. package/layout/includes/widgets/page/about/motto.pug +17 -16
  73. package/layout/includes/widgets/page/about/other.pug +16 -16
  74. package/layout/includes/widgets/page/about/personalities.pug +15 -14
  75. package/layout/includes/widgets/page/about/skillsinfo.pug +37 -36
  76. package/layout/includes/widgets/page/about/tenyear.pug +0 -0
  77. package/layout/includes/widgets/page/banner.pug +9 -3
  78. package/layout/includes/widgets/page/equipment/content.pug +0 -0
  79. package/layout/includes/widgets/page/links/banner.pug +14 -12
  80. package/layout/includes/widgets/page/links/linksCard.pug +4 -6
  81. package/layout/includes/widgets/page/links/linksDiscn.pug +8 -0
  82. package/layout/includes/widgets/page/links/linksItem.pug +4 -6
  83. package/layout/includes/widgets/page/says/json.pug +80 -0
  84. package/layout/includes/widgets/page/says/local.pug +48 -0
  85. package/layout/includes/widgets/page/says/memos.pug +109 -0
  86. package/layout/includes/widgets/post/award.pug +0 -0
  87. package/layout/includes/widgets/post/copyright.pug +2 -2
  88. package/layout/includes/widgets/post/post-ai.pug +12 -0
  89. package/layout/includes/widgets/post/postMeta.pug +2 -2
  90. package/layout/includes/widgets/post/postNav.pug +0 -0
  91. package/layout/includes/widgets/post/wave.pug +0 -0
  92. package/layout/includes/widgets/randomlink.pug +1 -1
  93. package/layout/includes/widgets/rightside/index.pug +6 -5
  94. package/layout/includes/widgets/third-party/comments/comment.pug +1 -5
  95. package/layout/includes/widgets/third-party/comments/twikoo.pug +1 -1
  96. package/layout/includes/widgets/third-party/comments/waline.pug +9 -11
  97. package/layout/includes/widgets/third-party/music.pug +1 -1
  98. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -0
  99. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +70 -0
  100. package/layout/includes/widgets/third-party/news-comment/waline.pug +64 -0
  101. package/layout/includes/widgets/third-party/pjax.pug +0 -0
  102. package/layout/includes/widgets/third-party/search/algolia-search.pug +0 -0
  103. package/layout/includes/widgets/third-party/search/index.pug +8 -7
  104. package/layout/includes/widgets/third-party/search/local-search.pug +0 -0
  105. package/layout/index.pug +3 -3
  106. package/layout/page.pug +0 -4
  107. package/layout/post.pug +2 -2
  108. package/layout/tag.pug +0 -0
  109. package/package.json +18 -9
  110. package/plugins.yml +109 -0
  111. package/scripts/event/cdn.js +129 -0
  112. package/scripts/event/init.js +0 -0
  113. package/scripts/event/page.js +1 -21
  114. package/scripts/event/welcome.js +1 -1
  115. package/scripts/filter/checkThemeConfig.js +0 -0
  116. package/scripts/filter/default.js +0 -0
  117. package/scripts/filter/lazyload.js +1 -1
  118. package/scripts/filter/randomPosts.js +0 -0
  119. package/scripts/helper/cdn.js +0 -0
  120. package/scripts/helper/getArchiveLength.js +0 -0
  121. package/scripts/helper/page.js +0 -0
  122. package/scripts/helper/related_post.js +0 -0
  123. package/scripts/helper/stylus.js +0 -0
  124. package/scripts/tags/button.js +0 -0
  125. package/scripts/tags/bvideo.js +0 -0
  126. package/scripts/tags/card.js +0 -0
  127. package/scripts/tags/checkbox.js +0 -0
  128. package/scripts/tags/fold.js +0 -0
  129. package/scripts/tags/image.js +0 -0
  130. package/scripts/tags/inline-image.js +0 -0
  131. package/scripts/tags/label.js +0 -0
  132. package/scripts/tags/link.js +0 -0
  133. package/scripts/tags/media.js +0 -0
  134. package/scripts/tags/note.js +0 -0
  135. package/scripts/tags/span.js +0 -0
  136. package/scripts/tags/tabs.js +0 -0
  137. package/scripts/tags/timeline.js +0 -0
  138. package/scripts/tags/u.js +0 -0
  139. package/source/css/_global/animation.css +0 -0
  140. package/source/css/_global/function.styl +42 -42
  141. package/source/css/_global/index.styl +1 -1
  142. package/source/css/_global/var.styl +0 -0
  143. package/source/css/_layout/basic.styl +10 -12
  144. package/source/css/_layout/header.styl +7 -2
  145. package/source/css/_layout/index.styl +59 -5
  146. package/source/css/_mode/index.styl +1 -17
  147. package/source/css/_page/_home/category-bar.styl +0 -0
  148. package/source/css/_page/_home/home-top.styl +10 -31
  149. package/source/css/_page/_home/index.styl +0 -0
  150. package/source/css/_page/_home/pagination.styl +3 -0
  151. package/source/css/_page/_home/recent-post.styl +10 -3
  152. package/source/css/_page/about/index.styl +0 -0
  153. package/source/css/_page/about/tenyear.styl +0 -0
  154. package/source/css/_page/about.styl +9 -0
  155. package/source/css/_page/category.styl +0 -0
  156. package/source/css/_page/douban.styl +0 -1
  157. package/source/css/_page/equipment.styl +0 -0
  158. package/source/css/_page/error.styl +0 -0
  159. package/source/css/_page/home.styl +0 -0
  160. package/source/css/_page/index.styl +2 -3
  161. package/source/css/_page/links.styl +84 -49
  162. package/source/css/_page/moment.styl +0 -0
  163. package/source/css/_page/music.styl +0 -0
  164. package/source/css/_page/rss.styl +0 -0
  165. package/source/css/_page/says.styl +10 -0
  166. package/source/css/_page/tag.styl +0 -0
  167. package/source/css/_widgets/_aside/allinfo.styl +34 -0
  168. package/source/css/_widgets/_aside/flip.styl +0 -0
  169. package/source/css/_widgets/_aside/index.styl +1 -7
  170. package/source/css/_widgets/_aside/info.styl +0 -0
  171. package/source/css/_widgets/_aside/newPost.styl +0 -0
  172. package/source/css/_widgets/_aside/toc.styl +0 -0
  173. package/source/css/_widgets/_aside/welcome.styl +0 -0
  174. package/source/css/_widgets/_comment/index.styl +0 -0
  175. package/source/css/_widgets/_comment/twikoo.styl +0 -2
  176. package/source/css/_widgets/_comment/waline.styl +0 -0
  177. package/source/css/_widgets/_extra/console.styl +0 -0
  178. package/source/css/_widgets/_extra/fullpage.styl +0 -0
  179. package/source/css/_widgets/_extra/music.styl +1 -1
  180. package/source/css/_widgets/_extra/pace.styl +0 -0
  181. package/source/css/_widgets/_extra/rightmenu.styl +0 -0
  182. package/source/css/_widgets/_mixins/article-sort.styl +0 -0
  183. package/source/css/_widgets/_mixins/footer.styl +1 -2
  184. package/source/css/_widgets/_mixins/other.styl +0 -4
  185. package/source/css/_widgets/_mixins/sidebar.styl +0 -0
  186. package/source/css/_widgets/_post/_highlight/diff.styl +0 -0
  187. package/source/css/_widgets/_post/_highlight/index.styl +0 -1
  188. package/source/css/_widgets/_post/_highlight/theme/default.styl +0 -0
  189. package/source/css/_widgets/_post/_highlight/theme/mac.styl +0 -0
  190. package/source/css/_widgets/_post/_highlight/theme.styl +0 -0
  191. package/source/css/_widgets/_post/commentBarrage.styl +0 -0
  192. package/source/css/_widgets/_post/content.styl +42 -11
  193. package/source/css/_widgets/_post/copyright.styl +0 -0
  194. package/source/css/_widgets/_post/index.styl +1 -1
  195. package/source/css/_widgets/_post/meta.styl +0 -3
  196. package/source/css/_widgets/_post/pagination.styl +1 -1
  197. package/source/css/_widgets/_post/postAI.styl +0 -0
  198. package/source/css/_widgets/_post/relatedPost.styl +0 -0
  199. package/source/css/_widgets/_post/tools.styl +0 -0
  200. package/source/css/_widgets/_search/algolia-search.styl +0 -0
  201. package/source/css/_widgets/_search/local-search.styl +0 -0
  202. package/source/css/_widgets/_tags/button.styl +0 -0
  203. package/source/css/_widgets/_tags/bvideo.styl +0 -0
  204. package/source/css/_widgets/_tags/card.styl +0 -0
  205. package/source/css/_widgets/_tags/checkbox.styl +0 -0
  206. package/source/css/_widgets/_tags/fold.styl +0 -0
  207. package/source/css/_widgets/_tags/image.styl +0 -0
  208. package/source/css/_widgets/_tags/index.styl +0 -0
  209. package/source/css/_widgets/_tags/inline-image.styl +0 -0
  210. package/source/css/_widgets/_tags/label.styl +0 -0
  211. package/source/css/_widgets/_tags/link.styl +4 -2
  212. package/source/css/_widgets/_tags/note.styl +0 -0
  213. package/source/css/_widgets/_tags/span.styl +0 -0
  214. package/source/css/_widgets/_tags/tabs.styl +0 -0
  215. package/source/css/_widgets/_tags/timeline.styl +0 -1
  216. package/source/css/_widgets/index.styl +4 -4
  217. package/source/css/index.styl +0 -0
  218. package/source/img/avatar.png +0 -0
  219. package/source/img/default.png +0 -0
  220. package/source/img/error_load.png +0 -0
  221. package/source/js/{extend/comment/twikoo/commentBarrage.js → comment/twikoo_commentBarrage.js} +0 -0
  222. package/source/js/{extend/comment/waline/commentBarrage.js → comment/waline_commentBarrage.js} +0 -0
  223. package/source/js/covercolor/api.js +95 -0
  224. package/source/js/covercolor/local.js +154 -0
  225. package/source/js/main.js +28 -235
  226. package/source/js/music.js +0 -0
  227. package/source/js/rightside.js +404 -0
  228. package/source/js/{extend/search/algolia-search.js → search/algolia.js} +10 -0
  229. package/source/js/{extend/search/local-search.js → search/local.js} +24 -2
  230. package/source/js/utils.js +75 -1
  231. package/layout/includes/head/fest.pug +0 -22
  232. package/layout/includes/page/echarts.pug +0 -7
  233. package/layout/includes/page/moments.pug +0 -4
  234. package/layout/includes/widgets/aside/asideHistory.pug +0 -8
  235. package/layout/includes/widgets/aside/asideWelcome.pug +0 -12
  236. package/layout/includes/widgets/page/moments/angle.pug +0 -19
  237. package/layout/includes/widgets/page/moments/index.pug +0 -23
  238. package/layout/includes/widgets/page/says/saysBottom.pug +0 -11
  239. package/layout/includes/widgets/page/says/saysContent.pug +0 -6
  240. package/layout/includes/widgets/page/says/saysFunction.pug +0 -10
  241. package/layout/includes/widgets/page/says/saysMeta.pug +0 -7
  242. package/layout/includes/widgets/third-party/ai/index.pug +0 -12
  243. package/layout/includes/widgets/third-party/comments/gitalk.pug +0 -0
  244. package/layout/includes/widgets/third-party/comments/valine.pug +0 -0
  245. package/scripts/helper/echarts.js +0 -407
  246. package/source/css/_widgets/_aside/history.styl +0 -42
  247. package/source/js/extend/comment/twikoo/twikoo.js +0 -67
  248. package/source/js/extend/comment/waline/waline.js +0 -60
  249. package/source/lib/bundle.min.js +0 -27
  250. package/source/lib/circle.min.js +0 -1
  251. package/source/lib/cover-color.min.js +0 -7
  252. package/source/lib/friends_post.js +0 -4
  253. package/source/lib/lazyload.min.js +0 -1
  254. package/source/lib/rightside.min.js +0 -1
  255. package/source/lib/snackbar.min.css +0 -1
  256. package/source/lib/snackbar.min.js +0 -9
  257. package/source/lib/txmap.min.js +0 -1
  258. package/source/lib/universe.min.js +0 -1
  259. package/source/lib/view-image.min.js +0 -6
  260. package/source/lib/waterfall.min.js +0 -1
  261. /package/source/{lib → js}/sco-ai.min.js +0 -0
@@ -0,0 +1,95 @@
1
+ const coverColor = () => {
2
+ const path = document.getElementById("post-cover")?.src;
3
+ if (path) {
4
+ handleApiColor(path);
5
+ }
6
+ }
7
+
8
+ function handleApiColor(path) {
9
+ const cacheGroup = JSON.parse(localStorage.getItem('Solitude')) || {};
10
+ if (cacheGroup.postcolor && cacheGroup.postcolor[path]) {
11
+ const color = cacheGroup.postcolor[path].value;
12
+ const [r, g, b] = color.match(/\w\w/g).map(x => parseInt(x, 16));
13
+ setThemeColors(color, r, g, b);
14
+ } else {
15
+ img2color(path);
16
+ }
17
+ }
18
+
19
+ function img2color(src) {
20
+ const apiUrl = coverColorConfig.api + encodeURIComponent(src);
21
+
22
+ fetch(apiUrl)
23
+ .then(response => response.json())
24
+ .then(data => {
25
+ const color = data.RGB;
26
+ const [r, g, b] = color.match(/\w\w/g).map(x => parseInt(x, 16));
27
+ setThemeColors(color, r, g, b);
28
+ if (coverColorConfig.time !== 0) {
29
+ cacheColor(src, color);
30
+ }
31
+ })
32
+ .catch(error => {
33
+ console.error('请检查API是否正常!\n' + error);
34
+ });
35
+ }
36
+
37
+ function cacheColor(src, color) {
38
+ const expirationTime = Date.now() + coverColorConfig.time;
39
+ const cacheGroup = saveToLocal.get('Solitude') || {};
40
+ cacheGroup.postcolor = cacheGroup.postcolor || {};
41
+ cacheGroup.postcolor[src] = {value: color, expiration: expirationTime};
42
+ localStorage.setItem('Solitude', JSON.stringify(cacheGroup));
43
+ }
44
+
45
+ function setThemeColors(value, r = null, g = null, b = null) {
46
+ if (value) {
47
+ document.documentElement.style.setProperty('--sco-main', value);
48
+ document.documentElement.style.setProperty('--sco-main-op', value + '23');
49
+ document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
50
+ document.documentElement.style.setProperty('--sco-main-none', value + '00');
51
+
52
+ if (r && g && b) {
53
+ var brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
54
+ var cardContents = document.getElementsByClassName('card-content');
55
+ var authorInfo = document.getElementsByClassName('author-info__sayhi');
56
+ for (let i = 0; i < cardContents.length; i++) {
57
+ cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
58
+ }
59
+
60
+ for (let i = 0; i < authorInfo.length; i++) {
61
+ authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
62
+ authorInfo[i].style.setProperty('color', 'var(--sco-white)');
63
+ }
64
+ }
65
+
66
+ document.getElementById("coverdiv").classList.add("loaded");
67
+ initThemeColor();
68
+ } else {
69
+ document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
70
+ document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
71
+ document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
72
+ document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
73
+ initThemeColor();
74
+ }
75
+ }
76
+
77
+ function initThemeColor() {
78
+ const currentTop = window.scrollY || document.documentElement.scrollTop;
79
+ let themeColor;
80
+ if (currentTop > 0) {
81
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
82
+ } else if (PAGE_CONFIG.is_post) {
83
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
84
+ } else {
85
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
86
+ }
87
+ changeThemeColor(themeColor);
88
+ }
89
+
90
+ function changeThemeColor(color) {
91
+ const meta = document.querySelector('meta[name="theme-color"]');
92
+ if (meta) {
93
+ meta.setAttribute('content', color);
94
+ }
95
+ }
@@ -0,0 +1,154 @@
1
+ const coverColor = () => {
2
+ const path = document.getElementById("post-cover")?.src;
3
+ if (path) {
4
+ localColor(path);
5
+ }
6
+ }
7
+
8
+ const localColor = (path) => {
9
+ const img = new Image();
10
+ img.crossOrigin = "Anonymous";
11
+ img.onload = function () {
12
+ const canvas = document.createElement("canvas");
13
+ canvas.width = img.width;
14
+ canvas.height = img.height;
15
+ const ctx = canvas.getContext("2d");
16
+ ctx.drawImage(img, 0, 0);
17
+ const data = ctx.getImageData(0, 0, img.width, img.height).data;
18
+ const {r, g, b} = calculateRGB(data);
19
+ let value = rgbToHex(r, g, b);
20
+ if (getContrastYIQ(value) === "light") {
21
+ value = LightenDarkenColor(value, -50);
22
+ }
23
+ setThemeColors(value, r, g, b);
24
+ };
25
+ img.onerror = function() {
26
+ console.error('图片加载失败');
27
+ };
28
+ img.src = path;
29
+ }
30
+
31
+ function calculateRGB(data) {
32
+ let r = 0, g = 0, b = 0;
33
+ const step = 5;
34
+ for (let i = 0; i < data.length; i += 4 * step) {
35
+ r += data[i];
36
+ g += data[i + 1];
37
+ b += data[i + 2];
38
+ }
39
+ r = Math.floor(r / (data.length / 4 / step));
40
+ g = Math.floor(g / (data.length / 4 / step));
41
+ b = Math.floor(b / (data.length / 4 / step));
42
+ return {r, g, b};
43
+ }
44
+
45
+ function rgbToHex(r, g, b) {
46
+ return "#" + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
47
+ }
48
+
49
+ function LightenDarkenColor(col, amt) {
50
+ let usePound = false;
51
+
52
+ if (col[0] === "#") {
53
+ col = col.slice(1);
54
+ usePound = true;
55
+ }
56
+
57
+ const num = parseInt(col, 16);
58
+ const r = Math.min(255, Math.max(0, (num >> 16) + amt));
59
+ const b = Math.min(255, Math.max(0, ((num >> 8) & 0xff) + amt));
60
+ const g = Math.min(255, Math.max(0, (num & 0xff) + amt));
61
+
62
+ return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
63
+ }
64
+
65
+ function getContrastYIQ(hexcolor) {
66
+ var colorrgb = colorRgb(hexcolor);
67
+ var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
68
+ var red = colors[1];
69
+ var green = colors[2];
70
+ var blue = colors[3];
71
+ var brightness = (red * 299) + (green * 587) + (blue * 114);
72
+ brightness = brightness / 255000;
73
+ return brightness >= 0.5 ? "light" : "dark";
74
+ }
75
+
76
+ function colorRgb(str) {
77
+ const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
78
+ const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
79
+ const HEX_SHORT_LENGTH = 4;
80
+
81
+ if (!str || typeof str !== 'string') {
82
+ return str;
83
+ }
84
+
85
+ const sColor = str.toLowerCase();
86
+ let hexValue = "";
87
+
88
+ if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
89
+ hexValue = sColor.length === HEX_SHORT_LENGTH ?
90
+ sColor.replace(/^#(.)/g, "#$1$1") :
91
+ sColor;
92
+
93
+ const rgbValue = hexValue.slice(1)
94
+ .match(/.{2}/g)
95
+ .map(val => parseInt(val, 16));
96
+
97
+ return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
98
+ } else {
99
+ return sColor;
100
+ }
101
+ }
102
+
103
+ function setThemeColors(value, r = null, g = null, b = null) {
104
+ const cardContents = document.getElementsByClassName('card-content');
105
+ const authorInfo = document.getElementsByClassName('author-info__sayhi');
106
+
107
+ if (value) {
108
+ document.documentElement.style.setProperty('--sco-main', value);
109
+ document.documentElement.style.setProperty('--sco-main-op', value + '23');
110
+ document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
111
+ document.documentElement.style.setProperty('--sco-main-none', value + '00');
112
+
113
+ if (r && g && b) {
114
+ var brightness = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000);
115
+ for (let i = 0; i < cardContents.length; i++) {
116
+ cardContents[i].style.setProperty('--sco-card-bg', 'var(--sco-white)');
117
+ }
118
+
119
+ for (let i = 0; i < authorInfo.length; i++) {
120
+ authorInfo[i].style.setProperty('background', 'var(--sco-white-op)');
121
+ authorInfo[i].style.setProperty('color', 'var(--sco-white)');
122
+ }
123
+ }
124
+
125
+ document.getElementById("coverdiv").classList.add("loaded");
126
+ initThemeColor();
127
+ } else {
128
+ document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
129
+ document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
130
+ document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
131
+ document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
132
+ initThemeColor();
133
+ }
134
+ }
135
+
136
+ function initThemeColor() {
137
+ const currentTop = window.scrollY || document.documentElement.scrollTop;
138
+ let themeColor;
139
+ if (currentTop > 0) {
140
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
141
+ } else if (PAGE_CONFIG.is_post) {
142
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
143
+ } else {
144
+ themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
145
+ }
146
+ changeThemeColor(themeColor);
147
+ }
148
+
149
+ function changeThemeColor(color) {
150
+ const meta = document.querySelector('meta[name="theme-color"]');
151
+ if (meta) {
152
+ meta.setAttribute('content', color);
153
+ }
154
+ }