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.1 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. function highlightTextNodes(element) {
  54. $(element).contents().each(function () {
  55. if (this.nodeType === Node.TEXT_NODE) {
  56. const $this = $(this);
  57. const text = $this.text();
  58. // 使用正则替换并保留原始大小写
  59. if (regex.test(text)) {
  60. const replaced = text.replace(regex, '<mark>$1</mark>');
  61. $this.replaceWith(replaced);
  62. }
  63. } else if (
  64. this.nodeType === Node.ELEMENT_NODE &&
  65. !$(this).is('script, style, noscript, textarea')
  66. ) {
  67. highlightTextNodes(this);
  68. }
  69. });
  70. }
  71. $('section').each(function () {
  72. highlightTextNodes(this);
  73. });
  74. });
  75. $(function () {
  76. var codeBlocks = document.querySelectorAll('div.highlight');
  77. codeBlocks.forEach(function (codeBlock) {
  78. var copyButton = document.createElement('button');
  79. copyButton.className = 'copy';
  80. copyButton.type = 'button';
  81. copyButton.innerText = '📋';
  82. codeBlock.append(copyButton);
  83. copyButton.addEventListener('click', function () {
  84. var code = codeBlock.querySelector('pre code').innerText.trim();
  85. window.navigator.clipboard.writeText(code)
  86. .then(() => {
  87. copyButton.innerText = '✅';
  88. })
  89. .catch(err => {
  90. copyButton.innerText = '❌';
  91. console.error('Failed to copy:', err);
  92. });
  93. setTimeout(function () {
  94. copyButton.innerText = '📋';
  95. }, 1500);
  96. });
  97. });
  98. });
  99. today = new Date();
  100. timeold = (today.getTime() - lastUpdated.getTime());
  101. secondsold = Math.floor(timeold / 1000);
  102. e_daysold = timeold / (24 * 60 * 60 * 1000);
  103. daysold = Math.floor(e_daysold);
  104. if (daysold > 90) {
  105. $("html")[0].style = "-webkit-filter: grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(graysale=1);";
  106. $("html")[0].innerHTML = $("html")[0].innerHTML.replace(/Mayx/g, "Ghost");
  107. console.warn("Mayx may already be Dead");
  108. }

Powered by TurnKey Linux.