前言:请务必支持哪吒监控的著作权,请不要将这些代码用于商业用途,谢谢🙏

如果本文有用的话欢迎您收藏+给我点鸡腿,这对我有很大的帮助,谢谢🙏


功能

  • 替换指定的图片(如 Logo、头像、动画图)。
  • 替换文字内容(如项目名称、版权信息、版本号)。
  • 通过 DOM 监听确保替换在页面动态更新时依旧生效。

使用方法

  1. 插入代码
    将以下脚本完整复制后插入仪表盘自定义代码的输入框:

    <script>(function() {  function replaceImage(selector, oldSrc, newSrc) {    const el = document.querySelector(selector);    if (el && el.getAttribute("src") === oldSrc) {      el.setAttribute("src", newSrc);    }  }  function replaceText(selector, oldText, newText) {    const el = document.querySelector(selector);    if (!el) return;    el.childNodes.forEach(node => {      if (node.nodeType === Node.TEXT_NODE && node.textContent.includes(oldText)) {        node.textContent = node.textContent.replace(oldText, newText);      }    });  }  function apply() {    replaceImage('img[alt="animated-man"]', '/dashboard/animated-man.webp', '小人图片链接');    replaceImage('img[src="/dashboard/logo.svg"]', '/dashboard/logo.svg', '自定义LOGO链接');    replaceImage('img[src="https://api.dicebear.com/7.x/notionists/svg?seed=admin"]', 'https://api.dicebear.com/7.x/notionists/svg?seed=admin', '头像链接');    replaceText('a[href="/dashboard"]', '哪吒监控', 'conan的监控');    replaceText('footer', '哪吒监控', 'conan的探针');    replaceText('footer', '1.13.0', 'v114.514');  }    apply();  const observer = new MutationObserver(apply);  observer.observe(document.documentElement, { childList: true, subtree: true });})();</script>
  2. 自行修改
    脚本中含有的修改项如不需要请删去,参数各位想必都看得懂我就不多说了,但是有一点需要提醒,脚本里替换头像的原头像链接是根据您的面板登录用户名而定的,比如我的登录用户名是admin,那头像的原链接就是https://api.dicebear.com/7.x/notionists/svg?seed=admin ,但是如果您修改了登录用户名,那头像原链接最后的seed也就要一起修改,否则无法生效。

  3. 点击保存
    在页面底部点击保存后,不出意外的话页面会自动刷新。


后记

如果你想替换别的元素也不是不可以,参考脚本中的语法对资源进行定位后就可以替换,目前脚本仅支持替换图片和文字。