|
|
| 第28行: |
第28行: |
| } | | } |
| }); | | }); |
|
| |
| document.addEventListener("DOMContentLoaded", async () => {
| |
| // 选择要替换的 SVG img
| |
| const poweredSvgImg = document.querySelector('#footer-poweredbyico img[alt="Powered by MyWiki"]');
| |
| if (!poweredSvgImg) return;
| |
|
| |
| const resp = await fetch(poweredSvgImg.src);
| |
| const svgText = await resp.text();
| |
|
| |
| // 创建内联 SVG
| |
| const wrapper = document.createElement("a");
| |
| wrapper.href = "https://ztm0929.me/";
| |
| wrapper.className = "cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled";
| |
| wrapper.target = "_blank";
| |
| wrapper.innerHTML = svgText;
| |
|
| |
| // 替换原来的 img
| |
| poweredSvgImg.replaceWith(wrapper);
| |
|
| |
| // 设置默认颜色
| |
| setLogoMode(document.body.classList.contains('skin-theme-clientpref-night') ? 'night' : 'day');
| |
|
| |
| // 可选:监听用户点击按钮切换主题
| |
| document.querySelector('#toggle-theme')?.addEventListener('click', () => {
| |
| const mode = document.body.classList.contains('skin-theme-clientpref-night') ? 'day' : 'night';
| |
| document.body.classList.toggle('skin-theme-clientpref-night');
| |
| document.body.classList.toggle('skin-theme-clientpref-day');
| |
| setLogoMode(mode);
| |
| });
| |
| });
| |
|
| |
| // 动态修改 SVG 填充颜色
| |
| function setLogoMode(mode) {
| |
| const svg = document.querySelector('#footer-poweredbyico a svg');
| |
| if (!svg) return;
| |
|
| |
| const fills = {
| |
| day: ['#666', '#333', '#1a1a1a', '#000'], // path1~path4
| |
| night: ['#999', '#ccc', '#e6e6e6', '#fff']
| |
| };
| |
|
| |
| ['path1','path2','path3','path4'].forEach((cls, idx) => {
| |
| const el = svg.querySelector('.' + cls);
| |
| if (el) el.setAttribute('fill', fills[mode][idx]);
| |
| });
| |
| }
| |