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.

100 lines
3.5 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. function getQueryVariable(variable){
  44. var query = window.location.search.substring(1);
  45. var vars = query.split("&");
  46. for (var i=0;i<vars.length;i++) {
  47. var pair = vars[i].split("=");
  48. if(pair[0] == variable){return pair[1];}
  49. }
  50. return(false);
  51. }
  52. var keyword = decodeURI(getQueryVariable("kw"));
  53. if (!keyword) return;
  54. // 转义正则表达式特殊字符,避免安全问题
  55. const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  56. // 创建不区分大小写的正则表达式(全局匹配)
  57. const regex = new RegExp(`(${escapedKeyword})`, 'gi');
  58. // 递归遍历并高亮文本节点
  59. function highlightTextNodes(element) {
  60. $(element).contents().each(function() {
  61. if (this.nodeType === Node.TEXT_NODE) {
  62. const $this = $(this);
  63. const text = $this.text();
  64. // 使用正则替换并保留原始大小写
  65. if (regex.test(text)) {
  66. const replaced = text.replace(regex, '<mark>$1</mark>');
  67. $this.replaceWith(replaced);
  68. }
  69. } else if (
  70. this.nodeType === Node.ELEMENT_NODE &&
  71. !$(this).is('script, style, noscript, textarea')
  72. ) {
  73. highlightTextNodes(this);
  74. }
  75. });
  76. }
  77. $('section').each(function() {
  78. highlightTextNodes(this);
  79. });
  80. });
  81. today = new Date();
  82. timeold = (today.getTime() - lastUpdated.getTime());
  83. secondsold = Math.floor(timeold / 1000);
  84. e_daysold = timeold / (24 * 60 * 60 * 1000);
  85. daysold = Math.floor(e_daysold);
  86. if (daysold > 90) {
  87. $("html")[0].style = "-webkit-filter: grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(graysale=1);";
  88. $("html")[0].innerHTML = $("html")[0].innerHTML.replace(/Mayx/g, "Ghost");
  89. console.warn("Mayx may already be Dead");
  90. }
  91. var message_Path = '/Live2dHistoire/live2d/';
  92. var talkAPI = BlogAPI + "/ai_chat";

Powered by TurnKey Linux.