Mayx's Home Page https://mabbs.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.3 KiB

  1. var message_Path = '/Live2dHistoire/live2d/';
  2. var talkAPI = BlogAPI + "/ai_chat";
  3. (function () {
  4. var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
  5. .text($backToTopTxt).attr("title", $backToTopTxt).click(function () {
  6. $("html, body").animate({ scrollTop: 0 }, 120);
  7. }), $backToTopFun = function () {
  8. var st = $(document).scrollTop(), winh = $(window).height();
  9. (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
  10. };
  11. $(window).bind("scroll", $backToTopFun);
  12. $(function () { $backToTopFun(); });
  13. })();
  14. $(function () {
  15. $("div#landlord").mouseenter(function () {
  16. $("div.live_ico_box").fadeIn();
  17. });
  18. $("div#landlord").mouseleave(function () {
  19. $("div.live_ico_box").fadeOut();
  20. });
  21. function showHitS(hits) {
  22. $.get(BlogAPI + "/count_click?id=" + hits.id, function (data) {
  23. hits.innerHTML = Number(data);
  24. });
  25. }
  26. function showHitCount() {
  27. var visitors = $(".visitors-index");
  28. for (var i = 0; i < visitors.length; i++) {
  29. showHitS(visitors[i]);
  30. }
  31. }
  32. function addCount() {
  33. var visitors = $(".visitors");
  34. $.get(BlogAPI + "/count_click_add?id=" + visitors[0].id, function (data) {
  35. visitors[0].innerHTML = Number(data);
  36. });
  37. }
  38. if ($('.visitors').length == 1) {
  39. addCount();
  40. } else if ($('.visitors-index').length > 0) {
  41. showHitCount();
  42. }
  43. });
  44. $(function () {
  45. const urlParams = new URLSearchParams(window.location.search);
  46. const keyword = urlParams.get('kw')?.trim();
  47. if (!keyword) return;
  48. // 转义正则表达式特殊字符,避免安全问题
  49. const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  50. // 创建不区分大小写的正则表达式(全局匹配)
  51. const regex = new RegExp(`(${escapedKeyword})`, 'gi');
  52. // 递归遍历并高亮文本节点
  53. const escapeHTML = str => str.replace(/[&<>"']/g,
  54. tag => ({
  55. '&': '&amp;',
  56. '<': '&lt;',
  57. '>': '&gt;',
  58. '"': '&quot;',
  59. "'": '&#39;'
  60. }[tag] || tag));
  61. function highlightTextNodes(element) {
  62. $(element).contents().each(function () {
  63. if (this.nodeType === Node.TEXT_NODE) {
  64. const $this = $(this);
  65. const text = escapeHTML($this.text());
  66. // 使用正则替换并保留原始大小写
  67. if (regex.test(text)) {
  68. const replaced = text.replace(regex, '<mark>$1</mark>');
  69. $this.replaceWith(replaced);
  70. }
  71. } else if (
  72. this.nodeType === Node.ELEMENT_NODE &&
  73. !$(this).is('script, style, noscript, textarea')
  74. ) {
  75. highlightTextNodes(this);
  76. }
  77. });
  78. }
  79. $('section').each(function () {
  80. highlightTextNodes(this);
  81. });
  82. });
  83. $(function () {
  84. var codeBlocks = document.querySelectorAll('div.highlight');
  85. codeBlocks.forEach(function (codeBlock) {
  86. var copyButton = document.createElement('button');
  87. copyButton.className = 'copy';
  88. copyButton.type = 'button';
  89. copyButton.innerText = '📋';
  90. codeBlock.append(copyButton);
  91. copyButton.addEventListener('click', function () {
  92. var code = codeBlock.querySelector('pre code').innerText.trim();
  93. window.navigator.clipboard.writeText(code)
  94. .then(() => {
  95. copyButton.innerText = '✅';
  96. })
  97. .catch(err => {
  98. copyButton.innerText = '❌';
  99. console.error('Failed to copy:', err);
  100. });
  101. setTimeout(function () {
  102. copyButton.innerText = '📋';
  103. }, 1500);
  104. });
  105. });
  106. });
  107. today = new Date();
  108. timeold = (today.getTime() - lastUpdated.getTime());
  109. secondsold = Math.floor(timeold / 1000);
  110. e_daysold = timeold / (24 * 60 * 60 * 1000);
  111. daysold = Math.floor(e_daysold);
  112. if (daysold > 90) {
  113. $("html")[0].style = "-webkit-filter: grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(graysale=1);";
  114. $("html")[0].innerHTML = $("html")[0].innerHTML.replace(/Mayx/g, "Ghost");
  115. console.warn("Mayx may already be Dead");
  116. }

Powered by TurnKey Linux.