Greasy Fork is available in English.

Unban Tiktok

Bypass the TikTok Ban

// ==UserScript==
// @name         Unban Tiktok
// @namespace    https://github.com/Oqarshi/Invite
// @version      1.7
// @description  Bypass the TikTok Ban
// @author       Oqarshi
// @match        *://www.tiktok.com/*
// @match        *://proxyium.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // ==============================================
    // Disclaimer Alert
    // ==============================================
    if (window.location.hostname === 'www.tiktok.com') {
        alert("DISCLAIMER: TikTok has been unbanned in the USA for now. If you do not need this userscript anymore remove it or disable it.");
    }

    // ==============================================
    // Toast Notification System
    // ==============================================

    // Create the toast container
    const toastContainer = document.createElement('div');
    toastContainer.id = 'toast-container';
    document.body.appendChild(toastContainer);

    // Define toast styles
    const styles = `
        #toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }

        .toast {
            position: relative;
            min-width: 250px;
            padding: 15px 20px;
            margin-bottom: 10px;
            border-radius: 5px;
            color: white;
            font-family: 'Arial', sans-serif;
            font-size: 14px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            opacity: 0;
            transform: translateX(100%);
            animation: slideIn 0.5s ease-out forwards, bounce 0.5s ease-out, fadeOut 0.5s ease-out 7.5s forwards;
            display: flex;
            align-items: center;
        }

        .toast.success {
            background-color: #4CAF50;
        }

        .toast.error {
            background-color: #F44336;
        }

        .toast.warning {
            background-color: #FF9800;
        }

        .toast.info {
            background-color: #2196F3;
        }

        .toast::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background-color: rgba(255, 255, 255, 0.5);
            animation: progressBar 8s linear forwards;
        }

        .toast .icon {
            margin-right: 10px;
            font-size: 20px;
        }

        @keyframes slideIn {
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        @keyframes fadeOut {
            to {
                opacity: 0;
                transform: translateX(100%);
            }
        }

        @keyframes progressBar {
            to {
                width: 0;
            }
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {
                transform: translateY(0);
            }
            40% {
                transform: translateY(-20px);
            }
            60% {
                transform: translateY(-10px);
            }
        }
    `;

    // Add styles to the document
    const styleSheet = document.createElement('style');
    styleSheet.type = 'text/css';
    styleSheet.innerText = styles;
    document.head.appendChild(styleSheet);

    /**
     * Displays a toast notification.
     * @param {string} message - The message to display in the toast.
     * @param {string} type - The type of toast (success, error, warning, info).
     * @param {string} icon - The icon to display in the toast.
     */
    function notifications(message, type, icon) {
        const toast = document.createElement('div');
        toast.className = `toast ${type}`;

        // Add icon
        const iconElement = document.createElement('span');
        iconElement.className = 'icon';
        iconElement.innerHTML = icon;
        toast.appendChild(iconElement);

        // Add message
        const messageElement = document.createElement('span');
        messageElement.innerText = message;
        toast.appendChild(messageElement);

        toastContainer.appendChild(toast);

        // Remove the toast after the animation ends
        setTimeout(() => {
            toast.remove();
        }, 8000);
    }

    // ==============================================
    // TikTok Unblocking Logic
    // ==============================================

    // Check if the current URL is TikTok
    if (window.location.hostname === 'www.tiktok.com') {
        // Redirect to Proxyium/website-unblocker
        window.location.href = "https://proxyium.com/website-unblocker";
    }

    // Check if the current URL is Proxyium and the user came from TikTok
    if (window.location.hostname === 'proxyium.com' && document.referrer.includes('tiktok.com')) {
        // Wait for the page to load
        window.addEventListener('load', function () {
            // Show "Unblocking TikTok" notification
            notifications('Unblocking TikTok...', 'info', '🔓');

            /**
             * Sets the VPN to Poland by selecting the appropriate option in the dropdown.
             */
            const setVPNToPoland = () => {
                const proxyCountrySelect = document.getElementById('proxy_country');
                if (proxyCountrySelect) {
                    proxyCountrySelect.value = 'pl';
                    console.log('VPN set to Poland.');
                    notifications('VPN set to Poland.', 'success', '✅');
                } else {
                    console.error('Could not find the proxy country select element.');
                    notifications('Failed to set VPN.', 'error', '❌');
                }
            };

            /**
             * Types 'tiktok.com' into the search bar.
             */
            const typeTikTokURL = () => {
                const searchInput = document.getElementById('unique-form-control');
                if (searchInput) {
                    searchInput.value = 'tiktok.com';
                    console.log('Typed "tiktok.com" in the search bar.');
                } else {
                    console.error('Could not find the search input element.');
                    notifications('Failed to type TikTok URL.', 'error', '❌');
                }
            };

            /**
             * Submits the form to redirect to TikTok.
             */
            const submitForm = () => {
                const submitButton = document.getElementById('unique-btn-blue');
                if (submitButton) {
                    submitButton.click();
                    console.log('Form submitted.');
                    notifications('Redirecting to TikTok...', 'info', '⏳');
                } else {
                    console.error('Could not find the submit button.');
                    notifications('Failed to submit form.', 'error', '❌');
                }
            };

            // Execute the functions in sequence
            setVPNToPoland();
            typeTikTokURL();
            submitForm();
        });
    }
})();