是不是觉得页面刷着很单调?
那么,让LinuxDo动起来吧,感受页面呼吸的感觉。
同时,页面也将有立体感,不再是平面的感觉了
建议暗色模式下使用
让LinuxDo呼吸起来
// ==UserScript==
// @name LinuxDo 动起来优化版
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 让 LinuxDo 更炫酷,性能更优!
// @author NullUser
// @match https://linux.do/*
// @match https://www.isharkfly.com/*
// @grant GM_addStyle
// ==/UserScript==
(function () {
'use strict';
// 应用呼吸效果
function applyBreathingEffect(element) {
let scale = 1;
let direction = 1; // 1 表示放大,-1 表示缩小
const animate = () => {
// 计算新比例和光晕透明度
scale += direction * 0.001;
if (scale >= 1.1) direction = -1;
if (scale <= 0.9) direction = 1;
const shadowOpacity = 0.5 + Math.abs(scale - 1) * 0.5;
// 应用动画效果
element.style.transform = `scale(${scale})`;
element.style.boxShadow = `0 0 20px rgba(255, 255, 255, ${shadowOpacity})`;
// 动画循环
requestAnimationFrame(animate);
};
animate();
}
// 处理图片元素
function enhanceImages() {
const images = document.querySelectorAll('img');
images.forEach((img) => {
// 避免重复处理
if (img.dataset.enhanced) return;
img.dataset.enhanced = true;
// 应用圆角样式
if (img.classList.contains('signature-img') || img.classList.contains('emoji')) {
img.style.borderRadius = '8px';
}
// 应用呼吸效果
applyBreathingEffect(img);
});
}
// 观察页面变化
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.addedNodes.length > 0) {
enhanceImages();
break; // 减少循环次数
}
}
});
// 开始观察
observer.observe(document.body, { childList: true, subtree: true });
// 初始加载
enhanceImages();
})();