Duck Easter Egg (Query Triggered)

Plays looping duck music and shows a walking duck animation when the URL query ?q=duck is present.

目前為 2025-11-25 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Duck Easter Egg (Query Triggered)
// @namespace    https://greasyfork.org/users/yourname
// @version      1.1
// @description  Plays looping duck music and shows a walking duck animation when the URL query ?q=duck is present.
// @author       You
// @license      MIT
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    const url = new URL(window.location.href);
    const query = url.searchParams.get("q");

    if (query && query.toLowerCase() === "duck") {
        const audioUrl = "https://drive.google.com/uc?export=download&id=1u9n_SO6itk8gxWnl14w_3H-73A1pvq8x";

        const audioEl = document.createElement("audio");
        audioEl.src = audioUrl;
        audioEl.loop = true;
        audioEl.volume = 0.5;
        audioEl.style.display = "none";
        document.body.appendChild(audioEl);

        audioEl.play().catch(err => {
            console.error("Autoplay Blocked:", err);
        });

        setTimeout(() => {
            const s = document.createElement("style");
            s.innerHTML = `
                @keyframes duckWalk {
                    0% { left: -100px; }
                    100% { left: 100%; }
                }
            `;
            document.head.appendChild(s);

            const duck = document.createElement("img");
            duck.src = "https://upload.wikimedia.org/wikipedia/commons/a/a0/Cartoon_steamer_duck_walking_animation.gif";
            duck.id = "walkingDuck";
            duck.style.cssText = `
                position: fixed;
                bottom: 0;
                width: 100px;
                z-index: 999999;
                pointer-events: none;
                animation: duckWalk 15s linear infinite;
            `;
            document.body.appendChild(duck);
        }, 5000);
    }
})();