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.

119 lines
4.0 KiB

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

Powered by TurnKey Linux.