gartic Croxyproxy IP Selecter 120 IP for gartic.io

Install this script and visit: https://gartic.io/?javVvadIPselector

// ==UserScript==
// @name        gartic Croxyproxy IP Selecter 120 IP for gartic.io
// @match       https://www.croxyproxy.com/*
// @match       https://www.croxyproxy.com/
// @match       https://gartic.io/*
// @grant       none
// @version     1.2
// @author      iiJavad
// @description Install this script and visit: https://gartic.io/?javVvadIPselector
// @namespace https://greasyfork.org/users/1302740
// ==/UserScript==

const proxylist = [];
const numProxies = 120;

for (let i = 0; i < numProxies / 2; i++) {
    const ip = `185.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}`;
    proxylist.push({ id: i + 1, ip });
}

for (let i = numProxies / 2; i < numProxies; i++) {
    const ip = `108.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}`;
    proxylist.push({ id: i + 1, ip });
}

let currentPage = 1;
const itemsPerPage = 10;

function addCustomStyles() {
    const style = document.createElement('style');
    style.textContent = `
        body { background-color: #d4f1c5; color: #005700; font-size: var(--font-size, 16px); }
        body.dark { background-color: #2c2c2c; color: #d4f1c5; }
        .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; }
        .header { text-align: center; margin-bottom: 20px; }
        .proxies { background: #005700; color: #d4f1c5; width: 80%; display: flex; flex-wrap: wrap; justify-content: center; padding: 20px; border-radius: 10px; }
        .proxy-item { border-radius: 5px; margin: 10px; padding: 10px; background: #004d00; color: #d4f1c5; text-decoration: none; display: inline-block; transition: all 0.3s ease; }
        .proxy-item:hover { background: #006600; transform: scale(1.1); }
        .copy-button { margin-left: 10px; }
        .search { margin-bottom: 20px; }
        .search input { padding: 10px; border-radius: 5px; border: 1px solid #005700; }
        .search button { padding: 10px; border-radius: 5px; background: #005700; color: #d4f1c5; border: none; cursor: pointer; transition: background 0.3s ease; }
        .search button:hover { background: #006600; }
        .pagination { margin-top: 20px; }
        .page-item { cursor: pointer; margin: 0 5px; }
        .dark-mode-toggle { margin-top: 20px; cursor: pointer; }
    `;
    document.head.appendChild(style);
}

function saveToHistory(ip) {
    let history = JSON.parse(localStorage.getItem('ipHistory')) || [];
    if (!history.includes(ip)) {
        history.push(ip);
        localStorage.setItem('ipHistory', JSON.stringify(history));
    }
}

function renderProxyList() {
    const container = document.createElement('div');
    container.className = 'container';

    const header = document.createElement('div');
    header.className = 'header';
    header.innerHTML = `<h4>javVvad Croxyproxy IP Selector <b>Available: ${proxylist.length}</b></h4>`;

    const searchBox = document.createElement('div');
    searchBox.className = 'search';
    searchBox.innerHTML = `
        <input type="text" id="search-input" placeholder="جستجو بر اساس IP..." />
        <button id="search-button">جستجو</button>
        <input type="text" id="range-input" placeholder="جستجو بر اساس محدوده IP (مثلاً 185)" />
    `;

    const proxyContainer = document.createElement('div');
    proxyContainer.className = 'proxies';
    proxyContainer.id = 'proxy-list';

    const renderPage = () => {
        proxyContainer.innerHTML = '';
        const start = (currentPage - 1) * itemsPerPage;
        const end = start + itemsPerPage;
        const paginatedList = proxylist.slice(start, end);

        paginatedList.forEach(item => {
            const proxyItem = document.createElement('div');
            proxyItem.className = 'proxy-item';
            proxyItem.innerHTML = `
                ${item.ip}
                <button class="copy-button" onclick="navigator.clipboard.writeText('${item.ip}')">کپی</button>
            `;
            proxyItem.onclick = () => {
                saveToHistory(item.ip);
                window.open(`https://www.croxyproxy.com/?javVvadnext=${item.id}`, '_blank');
            };
            proxyContainer.appendChild(proxyItem);
        });

        updatePagination();
    };

    const pagination = document.createElement('div');
    pagination.className = 'pagination';

    const updatePagination = () => {
        pagination.innerHTML = '';
        const totalPages = Math.ceil(proxylist.length / itemsPerPage);

        for (let i = 1; i <= totalPages; i++) {
            const pageItem = document.createElement('span');
            pageItem.className = 'page-item';
            pageItem.textContent = i;
            pageItem.addEventListener('click', () => {
                currentPage = i;
                renderPage();
            });
            pagination.appendChild(pageItem);
        }
    };

    const darkModeToggle = document.createElement('button');
    darkModeToggle.className = 'dark-mode-toggle';
    darkModeToggle.textContent = 'تغییر به حالت تاریک';
    darkModeToggle.addEventListener('click', () => {
        document.body.classList.toggle('dark');
        localStorage.setItem('darkMode', document.body.classList.contains('dark'));
    });

    container.appendChild(header);
    container.appendChild(searchBox);
    container.appendChild(proxyContainer);
    container.appendChild(pagination);
    container.appendChild(darkModeToggle);
    document.body.innerHTML = '';
    document.body.appendChild(container);

    document.getElementById('search-button').addEventListener('click', () => {
        const searchTerm = document.getElementById('search-input').value.toLowerCase();
        const rangeTerm = document.getElementById('range-input').value;
        const filteredList = proxylist.filter(item => {
            return item.ip.toLowerCase().includes(searchTerm) &&
                   (rangeTerm === '' || item.ip.startsWith(rangeTerm));
        });

        proxyContainer.innerHTML = '';
        filteredList.forEach(item => {
            const proxyItem = document.createElement('div');
            proxyItem.className = 'proxy-item';
            proxyItem.innerHTML = `
                ${item.ip}
                <button class="copy-button" onclick="navigator.clipboard.writeText('${item.ip}')">کپی</button>
            `;
            proxyItem.onclick = () => {
                saveToHistory(item.ip);
                window.open(`https://www.croxyproxy.com/?javVvadnext=${item.id}`, '_blank');
            };
            proxyContainer.appendChild(proxyItem);
        });
    });

    renderPage();
}

// Load settings from localStorage
window.onload = () => {
    const darkMode = localStorage.getItem('darkMode') === 'true';
    if (darkMode) {
        document.body.classList.add('dark');
    }
};

// Initialization
if (window.location.href.indexOf("javVvadIPselector") > -1) {
    addCustomStyles();
    renderProxyList();
}

if (window.location.href.indexOf("javVvadnext") > -1) {
    localStorage.setItem("javVvadnext", window.location.href.split("javVvadnext=")[1]);
    let inter = setInterval(() => {
        if (document.querySelector(".proxyFormPremium")) {
            clearInterval(inter);
            document.querySelector('input[id="url"]').value = "gartic.io";
            document.querySelector('i[class="fa fa-arrow-right"]').dispatchEvent(new MouseEvent("click", { bubbles: true, button: 0 }));
        }
    }, 100);
}

if (window.location.href.indexOf("servers") > -1) {
    let inter = setInterval(() => {
        if (document.querySelector("input[name=proxyServerId]")) {
            document.body.innerHTML += `
                <form class="myform" method="POST" action="/requests?fso=">
                    <input type="hidden" name="url" value="gartic.io">
                    <input type="hidden" name="proxyServerId" value="${localStorage.getItem("javVvadnext")}">
                    <input type="hidden" name="csrf" value="${document.querySelector("input[name=csrf]").value}">
                                        <input type="hidden" name="demo" value="0">
                    <input type="hidden" name="frontOrigin" value="https://www.croxyproxy.com">
                </form>
            `;
            document.querySelector(".myform").submit();
            clearInterval(inter);
        }
    }, 100);
}