测试网页加载速度
// ==UserScript==
// @name 网页加载速度测试
// @author DeepSeek
// @version 3.1.5
// @description 测试网页加载速度
// @match *://*/*
// @run-at document-start
// @grant none
// @namespace https://gf.qytechs.cn/users/452911
// ==/UserScript==
(function() {
// 创建显示元素
const loadTimeElement = document.createElement('div');
// 白色背景黑色文字的简洁样式,固定在底部居中
loadTimeElement.style.cssText = `
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(255, 255, 255, 0.98);
padding: 12px 24px;
border-radius: 8px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
color: #222;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-size: 15px;
font-weight: 500;
line-height: 1.5;
text-align: center;
z-index: 999999;
border: 1px solid rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
max-width: 90vw;
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
white-space: nowrap;
`;
// 添加动画效果
const style = document.createElement('style');
style.textContent = `
@keyframes fadeInScale {
0% { opacity: 0; transform: translateX(-50%) scale(0.95); }
100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes fadeOutScale {
0% { opacity: 1; transform: translateX(-50%) scale(1); }
100% { opacity: 0; transform: translateX(-50%) scale(0.95); }
}
`;
document.head.appendChild(style);
const startTime = performance.now();
window.addEventListener('load', () => {
const endTime = performance.now();
const timeElapsed = endTime - startTime;
loadTimeElement.textContent = `页面加载耗时: ${timeElapsed.toFixed(2)} ms`;
// 添加淡入动画
loadTimeElement.style.animation = 'fadeInScale 0.25s cubic-bezier(0.2, 0, 0, 1.2) forwards';
document.body.appendChild(loadTimeElement);
// 淡出消失
setTimeout(() => {
loadTimeElement.style.animation = 'fadeOutScale 0.25s ease forwards';
setTimeout(() => {
loadTimeElement.remove();
}, 100);
}, 1500);
});
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址