SimpCity Redirect Bypass

Decode base64 redirect links and go directly to target

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         SimpCity Redirect Bypass
// @namespace    sleazyfork.org
// @version      1.0
// @description  Decode base64 redirect links and go directly to target
// @match        *://simpcity.cr/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    function decodeBase64Url(b64) {
        try {
            return atob(b64);
        } catch (e) {
            return null;
        }
    }

    function processLinks(root = document) {
        const links = root.querySelectorAll('a[href*="/redirect/?to="]');

        links.forEach(link => {
            try {
                const url = new URL(link.href);
                const encoded = url.searchParams.get('to');

                if (!encoded) return;

                const decoded = decodeBase64Url(encoded);
                if (!decoded || !decoded.startsWith('http')) return;

                // Replace the link target
                link.href = decoded;

                // Optional: remove tracking junk
                link.removeAttribute('rel');
                link.removeAttribute('target');

            } catch (e) {
                // ignore malformed URLs
            }
        });
    }

    // Initial run
    processLinks();

    // Watch for dynamically added content (AJAX, infinite scroll, etc.)
    const observer = new MutationObserver(mutations => {
        for (const m of mutations) {
            for (const node of m.addedNodes) {
                if (node.nodeType === 1) {
                    processLinks(node);
                }
            }
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();