SlidySim Online Long Replay Links Fix

Resolves the "URI Too Long" error when loading large replays on SlidySim Online and bypasses Google redirect error page

// ==UserScript==
// @name         SlidySim Online Long Replay Links Fix
// @version      1.2.0
// @description  Resolves the "URI Too Long" error when loading large replays on SlidySim Online and bypasses Google redirect error page
// @author       dphdmn
// @match        https://slidysim.online/*
// @match        https://www.google.com/url?q=https://slidysim.online/*
// @icon         https://raw.githubusercontent.com/dphdmn/openslidy/refs/heads/main/images/eggIcon.ico
// @license      MIT
// @namespace    dphdmn
// ==/UserScript==
/* global loadCustomReplay */

(function() {
    'use strict';

    const ERROR_MESSAGE = 'Error: URI Too Long';
    const GOOGLE_ERROR_MESSAGE = 'The page you were on is trying to send you to an invalid URL (https://slidysim';
    const STORAGE_KEY = 'slidysim_replay_data';
    const REPLAY_URL = 'https://slidysim.online/replay';

    const saveReplayData = data => localStorage.setItem(STORAGE_KEY, data);
    const loadReplayData = () => localStorage.getItem(STORAGE_KEY);
    const clearReplayData = () => localStorage.removeItem(STORAGE_KEY);

    const handleSlidySimReplay = () => {
        if (document.body.textContent.includes(ERROR_MESSAGE)) {
            saveReplayData(window.location.href);
            window.location.href = REPLAY_URL;
        } else if (window.location.pathname === '/replay') {
            const replayData = loadReplayData();
            if (!replayData) return;

            try {
                const urlParams = new URL(replayData).searchParams;
                const replayParam = urlParams.get('r');
                if (replayParam) {
                    loadCustomReplay(replayParam);
                    clearReplayData();
                }
            } catch (error) {
                // Silently ignore invalid URLs
            }
        }
    };

    const handleGoogleRedirect = () => {
        if (document.body.textContent.includes(GOOGLE_ERROR_MESSAGE)) {
            const match = document.body.textContent.match(/URL \((https:\/\/slidysim[^)]+)\)/);
            if (match && match[1]) {
                window.location.href = match[1];
            }
        }
    };

    if (window.location.hostname === 'www.google.com') {
        handleGoogleRedirect();
    } else if (window.location.hostname === 'slidysim.online') {
        handleSlidySimReplay();
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址