跳到正文

个人记录

原神启动脚本

Asahina_Mafuyu约 6 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 6 分钟

版本

  1. v1当前
代码
// ==UserScript==
// @name         洛谷启动界面效果
// @version      1.0
// @description  在打开洛谷首页时,依次显示logo和“健康刷题忠告”的动画界面。
// @match        https://www.luogu.com.cn/
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const css = `
        @font-face {
            font-family: 'HYWenHei';
            src: local('汉仪文黑-85W Heavy'),
                 url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@700;900&display=swap');
            font-weight: 900;
            font-style: normal;
        }
        #ovl {
            position: fixed; top: 0; left: 0;
            width: 100vw; height: 100vh;
            background-color: white; z-index: 99999999;
            display: flex; justify-content: center; align-items: center;
            opacity: 1; transition: opacity 2s ease-in-out;
            font-family: 'HYWenHei', 'Microsoft YaHei', sans-serif;
            color: black;
        }
        #img {
            position: absolute; opacity: 0;
            transition: opacity 2s ease-in-out;
            max-width: 80vw; max-height: 80vh;
        }
        #ovl .txt {
            position: absolute; text-align: center; line-height: 2;
            opacity: 0; transition: opacity 2s ease-in-out;
        }
        #ovl h1 { font-size: 32px; margin-bottom: 20px; }
        #ovl p { font-size: 24px; margin: 10px 0; }
        #ovl .tip {
            position: absolute; bottom: 20px; left: 20px;
            font-size: 16px; opacity: 0;
            transition: opacity 2s ease-in-out;
        }
    `;

    const html = `
        <img id="img" src="https://youke1.picui.cn/s1/2025/09/09/68bfcc8b131db.png">
        <div class="txt">
            <h1>健康刷题忠告</h1>
            <p>抵制不良水题,拒绝盗版水题。</p>
            <p>注意自我保护,谨防受骗上当。</p>
            <p>适度水题益脑,沉迷水题伤身。</p>
            <p>合理安排时间,享受健康生活。</p>
        </div>
    `;

    GM_addStyle(css);

    const ovl = document.createElement('div');
    ovl.id = 'ovl';
    ovl.innerHTML = html;
    document.documentElement.appendChild(ovl);

    const img = ovl.querySelector('#img');
    const txt = ovl.querySelector('.txt');
    const tip = ovl.querySelector('.tip');

    // 添加ESC键跳过功能
    document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape') {
            ovl.style.opacity = '0';
            setTimeout(() => { ovl.remove(); }, 500);
        }
    });

    // 动画时间线
    setTimeout(() => {
        if (img) img.style.opacity = '1';
        if (tip) tip.style.opacity = '1';
    }, 1000);

    setTimeout(() => {
        if (img) img.style.opacity = '0';
    }, 6000);

    setTimeout(() => { if (txt) txt.style.opacity = '1'; }, 8000);
    setTimeout(() => { if (txt) txt.style.opacity = '0'; }, 13000);

    setTimeout(() => {
        ovl.style.pointerEvents = 'none';
        ovl.style.opacity = '0';
    }, 15000);

    setTimeout(() => { ovl.remove(); }, 17000);

})();
原文