// ==UserScript== // @name 网页加载速度测试 // @author ChatGPT // @version 3.1.4 // @description 测试网页加载速度 // @match *://*/* // @run-at document-start // @grant none // @namespace https://greasyfork.org/users/452911 // @downloadURL https://update.greasyfork.icu/scripts/461511/%E7%BD%91%E9%A1%B5%E5%8A%A0%E8%BD%BD%E9%80%9F%E5%BA%A6%E6%B5%8B%E8%AF%95.user.js // @updateURL https://update.greasyfork.icu/scripts/461511/%E7%BD%91%E9%A1%B5%E5%8A%A0%E8%BD%BD%E9%80%9F%E5%BA%A6%E6%B5%8B%E8%AF%95.meta.js // ==/UserScript== (function() { // 创建显示元素 const loadTimeElement = document.createElement('div'); // 白色背景黑色文字的简洁样式,确保居中 loadTimeElement.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -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: translate(-50%, -50%) scale(0.95); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } } @keyframes fadeOutScale { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -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)} 毫秒`; // 添加淡入动画 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(); }, 50); }, 1500); }); })();