work.ink bypasser

automatically bypasses all the annoying steps on work.ink so u can get to ur destination faster. works on brave, chrome + other chromium browsers :3

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         work.ink bypasser
// @namespace    https://stup1dkidd.carrd.co
// @version      1.4.9
// @description  automatically bypasses all the annoying steps on work.ink so u can get to ur destination faster. works on brave, chrome + other chromium browsers :3
// @author       chickennuggets0389
// @match        *://*.work.ink/*
// @match        https://workink.click/*
// @match        *://pass.work.ink/*
// @match        *://*/direct/?*
// @grant        none
// @icon         https://i.ibb.co/RpcvxzWz/favicon-V2-1.png
// @license      GPLv3.0-or-later
// ==/UserScript==

(function() {
    'use strict';

    // --- Part 1: Ad & Popup Hiding ---
    const filters = `
        [id^="bsa-zone_"],
        ins:nth-of-type(1) {
            display: none !important;
        }
        .main-modal {
            display: flex !important;
        }
    `;

    // Hide paywall — svelte-uutib1 is paywall, svelte-1cewne6 is Sign In
    setInterval(() => {
        document.querySelectorAll('.main-modal').forEach(el => {
            if (el.classList.contains('svelte-uutib1')) {
                el.style.setProperty('display', 'none', 'important');
                el.style.setProperty('pointer-events', 'none', 'important');
            }
        });
    }, 100);

    function addStyles(css) {
        const style = document.createElement('style');
        style.textContent = css;
        (document.head || document.documentElement).appendChild(style);
    }
    addStyles(filters);

    // --- Background Customizer ---
    (function() {
        const STORAGE_KEY = 'workink_bg_data';
        const PRESETS = [
            { label: 'night',   value: 'linear-gradient(135deg, #1a1a2e, #16213e, #0f3460)' },
            { label: 'aurora',  value: 'linear-gradient(135deg, #2d1b69, #11998e)' },
            { label: 'sunset',  value: 'linear-gradient(135deg, #ff6b6b, #feca57)' },
            { label: 'galaxy',  value: 'linear-gradient(135deg, #0f0c29, #302b63, #24243e)' },
            { label: 'forest',  value: 'linear-gradient(135deg, #134e5e, #71b280)' },
            { label: 'candy',   value: 'linear-gradient(135deg, #fc5c7d, #6a3093)' },
            { label: 'dark',    value: 'linear-gradient(135deg, #1a1a1a, #2d2d2d)' },
            { label: 'none',    value: '' },
        ];

        function applyBg(value, isUrl) {
            if (!value) {
                document.body.style.backgroundImage = '';
                document.body.style.background = '';
            } else if (isUrl) {
                document.body.style.background = '';
                document.body.style.backgroundImage = `url(${value})`;
                document.body.style.backgroundSize = 'cover';
                document.body.style.backgroundPosition = 'center';
                document.body.style.backgroundRepeat = 'no-repeat';
                document.body.style.backgroundAttachment = 'fixed';
            } else {
                document.body.style.backgroundImage = '';
                document.body.style.background = value;
                document.body.style.backgroundSize = 'cover';
                document.body.style.backgroundAttachment = 'fixed';
            }
        }

        const saved = localStorage.getItem(STORAGE_KEY);
        if (saved) {
            const parsed = JSON.parse(saved);
            applyBg(parsed.value, parsed.isUrl);
        }

        function saveBg(value, isUrl) {
            localStorage.setItem(STORAGE_KEY, JSON.stringify({ value, isUrl }));
            applyBg(value, isUrl);
            closePanel();
        }

        function resetBg() {
            localStorage.removeItem(STORAGE_KEY);
            applyBg('', false);
            closePanel();
        }

        // --- Panel ---
        let panelOpen = false;
        let panel = null;

        function closePanel() {
            if (panel) { panel.remove(); panel = null; panelOpen = false; }
        }

        function openPanel() {
            if (panelOpen) { closePanel(); return; }
            panelOpen = true;
            panel = document.createElement('div');
            panel.style.cssText = `
                position: fixed; bottom: 64px; right: 16px; z-index: 999999;
                width: 280px; background: #1a1a1a; border-radius: 12px;
                border: 1px solid rgba(255,255,255,0.1);
                font-family: sans-serif; overflow: hidden;
                box-shadow: 0 8px 32px rgba(0,0,0,0.5);
            `;
            panel.innerHTML = `
                <div style="padding:12px 16px;border-bottom:1px solid rgba(255,255,255,0.08);display:flex;justify-content:space-between;align-items:center;">
                    <span style="font-size:13px;font-weight:600;color:#fff">background</span>
                    <span id="bg-close" style="font-size:12px;color:#888;cursor:pointer;padding:2px 6px;border-radius:4px;background:rgba(255,255,255,0.05)">✕</span>
                </div>
                <div style="padding:12px 16px;border-bottom:1px solid rgba(255,255,255,0.08);">
                    <div style="font-size:10px;color:#666;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px">from your pc</div>
                    <button id="bg-upload" style="width:100%;padding:8px;border:1px dashed rgba(255,255,255,0.15);border-radius:8px;background:rgba(255,255,255,0.04);color:#aaa;font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px;">
                        ↑ pick image or gif
                    </button>
                </div>
                <div style="padding:12px 16px;border-bottom:1px solid rgba(255,255,255,0.08);">
                    <div style="font-size:10px;color:#666;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px">from url</div>
                    <input id="bg-url" type="text" placeholder="paste image or gif url..." style="width:100%;padding:7px 10px;border:1px solid rgba(255,255,255,0.1);border-radius:8px;background:rgba(255,255,255,0.05);color:#fff;font-size:12px;outline:none;box-sizing:border-box;" />
                    <button id="bg-url-apply" style="margin-top:8px;width:100%;padding:7px;border-radius:8px;background:#009974;color:white;border:none;font-size:12px;cursor:pointer;font-weight:600;">apply</button>
                </div>
                <div style="padding:12px 16px;border-bottom:1px solid rgba(255,255,255,0.08);">
                    <div style="font-size:10px;color:#666;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px">presets</div>
                    <div id="bg-presets" style="display:grid;grid-template-columns:repeat(4,1fr);gap:6px;"></div>
                </div>
                <div style="padding:10px 16px;display:flex;justify-content:space-between;align-items:center;">
                    <button id="bg-reset" style="font-size:11px;color:#666;background:none;border:none;cursor:pointer;padding:0;">reset to default</button>
                    <span style="font-size:10px;color:#444;">v1.4.0</span>
                </div>
            `;
            document.body.appendChild(panel);

            // Presets
            const presetsEl = panel.querySelector('#bg-presets');
            PRESETS.forEach(p => {
                const el = document.createElement('div');
                el.style.cssText = `height:44px;border-radius:8px;cursor:pointer;border:2px solid transparent;background-size:cover;background-position:center;position:relative;overflow:hidden;`;
                if (p.value) el.style.background = p.value;
                else el.style.cssText += 'background:#fff;border-color:rgba(0,0,0,0.1);';
                el.innerHTML = `<span style="position:absolute;bottom:3px;left:0;right:0;text-align:center;font-size:9px;color:${p.label==='none'?'#333':'#fff'};text-shadow:0 1px 3px rgba(0,0,0,0.8);">${p.label}</span>`;
                el.onmouseenter = () => el.style.borderColor = '#009974';
                el.onmouseleave = () => el.style.borderColor = 'transparent';
                el.onclick = () => saveBg(p.value, false);
                presetsEl.appendChild(el);
            });

            panel.querySelector('#bg-close').onclick = closePanel;
            panel.querySelector('#bg-reset').onclick = resetBg;
            panel.querySelector('#bg-url-apply').onclick = () => {
                const url = panel.querySelector('#bg-url').value.trim();
                if (url) saveBg(url, true);
            };

            // File upload
            const fileInput = document.createElement('input');
            fileInput.type = 'file';
            fileInput.accept = 'image/*,.gif';
            fileInput.style.display = 'none';
            fileInput.onchange = () => {
                const file = fileInput.files[0];
                if (!file) return;
                const reader = new FileReader();
                reader.onload = (ev) => saveBg(ev.target.result, true);
                reader.readAsDataURL(file);
            };
            document.body.appendChild(fileInput);
            panel.querySelector('#bg-upload').onclick = () => fileInput.click();

            // Close on outside click
            setTimeout(() => {
                document.addEventListener('click', (e) => {
                    if (!panel?.contains(e.target) && e.target !== triggerBtn) closePanel();
                }, { once: true });
            }, 100);
        }

        // --- Trigger button ---
        const triggerBtn = document.createElement('button');
        triggerBtn.innerHTML = '&#128444;';
        triggerBtn.title = 'change background';
        triggerBtn.style.cssText = `
            position: fixed; bottom: 16px; right: 16px; z-index: 99999;
            width: 40px; height: 40px; border-radius: 50%;
            background: #009974; color: white; font-size: 16px;
            border: none; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        `;
        triggerBtn.onclick = openPanel;

        const append = () => { document.body.appendChild(triggerBtn); };
        if (document.body) append();
        else document.addEventListener('DOMContentLoaded', append);
    })();

    // --- Ko-fi Donation Popup ---
    (function() {
        const KOFI_KEY = 'workink_kofi_dismissed';
        if (localStorage.getItem(KOFI_KEY)) return;

        setTimeout(() => {
            const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
            const bg = isDark ? '#1a1a1a' : '#ffffff';
            const text = isDark ? '#ccc' : '#333';
            const sub = isDark ? '#888' : '#999';
            const border = isDark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.08)';

            const popup = document.createElement('div');
            popup.style.cssText = `position:fixed;bottom:72px;right:16px;z-index:9999999;width:260px;background:${bg};border-radius:12px;border:1px solid ${border};font-family:sans-serif;box-shadow:0 8px 32px rgba(0,0,0,0.2);overflow:hidden;`;
            popup.innerHTML = `
                <div style="padding:14px 16px 10px;">
                    <div style="font-size:13px;font-weight:600;color:${text};margin-bottom:4px;">hey! enjoying the bypasser? ☕</div>
                    <div style="font-size:11px;color:${sub};line-height:1.5;">if this saved u time, consider buying me a coffee — it helps keep the script updated!</div>
                </div>
                <div style="padding:0 16px 12px;display:flex;flex-direction:column;gap:8px;">
                    <a href="https://ko-fi.com/stup1dkidd" target="_blank" style="display:block;text-align:center;padding:8px;background:#009974;color:white;border-radius:8px;font-size:12px;font-weight:600;text-decoration:none;">buy me a coffee ☕</a>
                    <button id="kofi-close" style="background:none;border:none;font-size:11px;color:${sub};cursor:pointer;padding:0;text-align:center;">maybe later</button>
                </div>
                <div style="padding:8px 16px;border-top:1px solid ${border};display:flex;align-items:center;gap:6px;">
                    <input type="checkbox" id="kofi-nope" style="cursor:pointer;" />
                    <label for="kofi-nope" style="font-size:10px;color:${sub};cursor:pointer;">don't show again</label>
                </div>
            `;
            document.body.appendChild(popup);

            const close = () => {
                if (popup.querySelector('#kofi-nope').checked) {
                    localStorage.setItem(KOFI_KEY, '1');
                }
                popup.remove();
            };

            popup.querySelector('#kofi-close').onclick = close;
            popup.querySelector('a').onclick = close;
        }, 30000); // show after 30s
    })();

    // --- Settings Panel ---
    (function() {
        const SETTINGS_KEY = 'workink_settings';
        const DEFAULTS = {
            autoClick: true,
            autoRetry: true,
            retryTimeout: 10,
            destWait: 20,
            notifications: true,
            hideTrending: false,
            hideSidebar: false,
            hideFooter: false,
        };

        function loadSettings() {
            try { return Object.assign({}, DEFAULTS, JSON.parse(localStorage.getItem(SETTINGS_KEY))); }
            catch(e) { return Object.assign({}, DEFAULTS); }
        }

        function saveSettings(s) {
            localStorage.setItem(SETTINGS_KEY, JSON.stringify(s));
            applySettings(s);
        }

        function applySettings(s) {
            // Auto-retry timeout
            window._workinkRetryTimeout = s.retryTimeout * 1000;
            // Dest wait
            window._workinkDestWait = s.destWait * 1000;
            window._workinkAutoClick = s.autoClick;
            // Notifications
            window._workinkNotifications = s.notifications;
            // Homepage hiding
            const style = document.getElementById('workink-hide-style') || (() => {
                const el = document.createElement('style');
                el.id = 'workink-hide-style';
                document.head.appendChild(el);
                return el;
            })();
            let css = '';
            if (s.hideTrending) css += '[class*="linkcont"], [class*="grid"] a { display: none !important; }';
            if (s.hideSidebar) css += 'aside, [class*="sidebar"] { display: none !important; }';
            if (s.hideFooter) css += 'footer, [class*="footer"] { display: none !important; }';
            style.textContent = css;
        }

        const settings = loadSettings();
        applySettings(settings);

        // Style sliders to match the panel theme
        const sliderStyle = document.createElement('style');
        sliderStyle.textContent = `
            .workink-slider { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: rgba(128,128,128,0.2); outline: none; cursor: pointer; }
            .workink-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #009974; cursor: pointer; }
            .workink-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #009974; cursor: pointer; border: none; }
        `;
        document.head.appendChild(sliderStyle);

        const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
        const bg = isDark ? '#1a1a1a' : '#ffffff';
        const border = isDark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.08)';
        const text = isDark ? '#ccc' : '#333';
        const sub = isDark ? '#666' : '#999';
        const sectionLabel = isDark ? '#555' : '#bbb';
        const panelBorder = isDark ? '1px solid rgba(255,255,255,0.08)' : '1px solid rgba(0,0,0,0.08)';
        const resetColor = isDark ? '#555' : '#aaa';
        const versionColor = isDark ? '#444' : '#ccc';

        let panelOpen = false;
        let panel = null;

        function toggle(id, s, key) {
            s[key] = !s[key];
            saveSettings(s);
            const el = document.getElementById(id);
            if (el) {
                el.style.background = s[key] ? '#009974' : (isDark ? '#333' : '#ddd');
                el.querySelector('div').style.left = s[key] ? 'auto' : '2px';
                el.querySelector('div').style.right = s[key] ? '2px' : 'auto';
            }
        }

        function makeToggle(id, on) {
            return `<div id="${id}" style="width:36px;height:20px;background:${on ? '#009974' : (isDark ? '#333' : '#ddd')};border-radius:10px;position:relative;cursor:pointer;flex-shrink:0;transition:background 0.15s;">
                <div style="width:16px;height:16px;background:white;border-radius:50%;position:absolute;top:2px;${on ? 'right:2px' : 'left:2px'};transition:left 0.15s,right 0.15s;"></div>
            </div>`;
        }

        function makeRow(label, desc, toggleId, on) {
            return `<div style="padding:8px 16px;display:flex;justify-content:space-between;align-items:center;gap:12px;">
                <div>
                    <div style="font-size:12px;color:${text};">${label}</div>
                    <div style="font-size:10px;color:${sub};">${desc}</div>
                </div>
                ${makeToggle(toggleId, on)}
            </div>`;
        }

        function makeSlider(label, desc, id, valId, min, max, val) {
            return `<div style="padding:8px 16px;display:flex;justify-content:space-between;align-items:center;gap:12px;">
                <div>
                    <div style="font-size:12px;color:${text};">${label}</div>
                    <div style="font-size:10px;color:${sub};">${desc}</div>
                </div>
                <div style="display:flex;align-items:center;gap:6px;flex-shrink:0;">
                    <input type="range" id="${id}" min="${min}" max="${max}" value="${val}" step="1" class="workink-slider" style="width:70px;" />
                    <span id="${valId}" style="font-size:12px;color:#009974;min-width:28px;">${val}s</span>
                </div>
            </div>`;
        }

        function openPanel() {
            if (panelOpen) { closePanel(); return; }
            panelOpen = true;
            const s = loadSettings();
            panel = document.createElement('div');
            panel.style.cssText = `position:fixed;bottom:64px;right:62px;z-index:999999;width:300px;background:${bg};border-radius:12px;border:${panelBorder};font-family:sans-serif;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.2);`;
            panel.innerHTML = `
                <div style="padding:12px 16px;border-bottom:${panelBorder};display:flex;justify-content:space-between;align-items:center;">
                    <span style="font-size:13px;font-weight:600;color:${text};">settings</span>
                    <div style="display:flex;align-items:center;gap:8px;">
                        <span style="font-size:10px;color:${sectionLabel};background:rgba(128,128,128,0.1);padding:2px 8px;border-radius:4px;">v1.4.3</span>
                        <span id="settings-close" style="font-size:12px;color:${sub};cursor:pointer;padding:2px 6px;border-radius:4px;background:rgba(128,128,128,0.1);">✕</span>
                    </div>
                </div>
                <div style="padding:8px 0;">
                    <div style="padding:4px 16px 6px;font-size:10px;color:${sectionLabel};text-transform:uppercase;letter-spacing:.06em;">bypasser</div>
                    ${makeRow('auto-click destination', 'automatically clicks go to destination', 'tog-click', s.autoClick)}
                    <div id="wait-row" style="opacity:${s.autoClick ? '1' : '0.4'};pointer-events:${s.autoClick ? 'auto' : 'none'};transition:opacity 0.15s;">
                    ${makeSlider('destination wait', 'delay before clicking button', 'sl-wait', 'sl-wait-val', 5, 30, s.destWait)}
                    </div>
                    ${makeRow('auto-retry on stuck', 'reloads when verifying too long', 'tog-retry', s.autoRetry)}
                    ${makeSlider('retry timeout', 'seconds before retrying', 'sl-retry', 'sl-retry-val', 5, 30, s.retryTimeout)}
                    ${makeRow('notifications', 'ping when done', 'tog-notif', s.notifications)}
                </div>
                <div style="border-top:${panelBorder};padding:8px 0;">
                    <div style="padding:4px 16px 6px;font-size:10px;color:${sectionLabel};text-transform:uppercase;letter-spacing:.06em;">homepage</div>
                    ${makeRow('hide trending links', 'removes the link grid', 'tog-trend', s.hideTrending)}
                    ${makeRow('hide sidebar', 'removes creator list', 'tog-side', s.hideSidebar)}
                    ${makeRow('hide footer', 'removes bottom links', 'tog-foot', s.hideFooter)}
                </div>
                <div style="border-top:${panelBorder};padding:10px 16px;display:flex;justify-content:space-between;align-items:center;">
                    <button id="settings-reset" style="font-size:11px;color:${resetColor};background:none;border:none;cursor:pointer;padding:0;">reset all</button>
                    <span style="font-size:10px;color:${versionColor};">work.ink bypasser</span>
                </div>
            `;
            document.body.appendChild(panel);

            panel.querySelector('#settings-close').onclick = closePanel;
            panel.querySelector('#tog-click').onclick = () => {
                toggle('tog-click', loadSettings(), 'autoClick');
                const s = loadSettings();
                const row = document.getElementById('wait-row');
                if (row) { row.style.opacity = s.autoClick ? '1' : '0.4'; row.style.pointerEvents = s.autoClick ? 'auto' : 'none'; }
            };
            panel.querySelector('#tog-retry').onclick = () => toggle('tog-retry', loadSettings(), 'autoRetry');
            panel.querySelector('#tog-notif').onclick = () => toggle('tog-notif', loadSettings(), 'notifications');
            panel.querySelector('#tog-trend').onclick = () => toggle('tog-trend', loadSettings(), 'hideTrending');
            panel.querySelector('#tog-side').onclick = () => toggle('tog-side', loadSettings(), 'hideSidebar');
            panel.querySelector('#tog-foot').onclick = () => toggle('tog-foot', loadSettings(), 'hideFooter');

            panel.querySelector('#sl-retry').oninput = function() {
                document.getElementById('sl-retry-val').textContent = this.value + 's';
                const s = loadSettings(); s.retryTimeout = parseInt(this.value); saveSettings(s);
            };
            panel.querySelector('#sl-wait').oninput = function() {
                document.getElementById('sl-wait-val').textContent = this.value + 's';
                const s = loadSettings(); s.destWait = parseInt(this.value); saveSettings(s);
            };

            panel.querySelector('#settings-reset').onclick = () => {
                localStorage.removeItem(SETTINGS_KEY);
                closePanel();
                setTimeout(openPanel, 50);
            };

            setTimeout(() => {
                document.addEventListener('click', (e) => {
                    if (!panel?.contains(e.target) && e.target !== settingsBtn) closePanel();
                }, { once: true });
            }, 100);
        }

        function closePanel() {
            if (panel) { panel.remove(); panel = null; panelOpen = false; }
        }

        const settingsBtn = document.createElement('button');
        settingsBtn.innerHTML = '&#9881;';
        settingsBtn.title = 'bypasser settings';
        settingsBtn.style.cssText = `position:fixed;bottom:16px;right:62px;z-index:99999;width:40px;height:40px;border-radius:50%;background:#009974;color:white;font-size:16px;border:none;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,0.3);`;
        settingsBtn.onclick = openPanel;

        const append = () => document.body.appendChild(settingsBtn);
        if (document.body) append();
        else document.addEventListener('DOMContentLoaded', append);
    })();

    // Remove any injected stylesheets that hide the main-modal (from old cached script versions)
    setInterval(() => {
        for (const sheet of [...document.styleSheets]) {
            try {
                for (const rule of [...sheet.cssRules]) {
                    if (rule.cssText?.includes('main-modal') && rule.cssText?.includes('display: none') ||
                        rule.cssText?.includes('bg-black') && rule.cssText?.includes('display: none')) {
                        sheet.deleteRule([...sheet.cssRules].indexOf(rule));
                    }
                }
            } catch(e) {}
        }
    }, 100);

    // --- Notification when "That was easy!" page is reached ---
    function notifyDone() {
        const notify = () => new Notification('Bypasser', {
            body: 'Done! Go To Destination is ready to click.',
            icon: 'https://www.google.com/s2/favicons?domain=work.ink&sz=64'
        });
        if (Notification.permission === 'granted') {
            notify();
        } else if (Notification.permission !== 'denied') {
            Notification.requestPermission().then(p => { if (p === 'granted') notify(); });
        }
    }

    // Auto-retry if stuck on verifying for 10s
    let verifyingFirstSeen = null;
    setInterval(() => {
        const isVerifying = document.body?.innerText?.includes('Verifying your progress');
        if (isVerifying) {
            if (!verifyingFirstSeen) verifyingFirstSeen = Date.now();
            if (Date.now() - verifyingFirstSeen > (window._workinkRetryTimeout || 10000)) {
                verifyingFirstSeen = null;
                location.reload();
            }
        } else {
            verifyingFirstSeen = null;
        }
    }, 500);

    // Poll for the "That was easy!" text
    const doneCheckInterval = setInterval(() => {
        if (document.body?.innerText?.includes('That was easy')) {
            clearInterval(doneCheckInterval);
            if (window._workinkNotifications !== false) notifyDone();
        }
    }, 500);

    // Dismiss adblocker screen + hide article overlay
    setInterval(() => {
        // Remove adblocker screen
        document.querySelectorAll('button').forEach(btn => {
            if (btn.innerText?.trim() === 'Refresh Page') {
                btn.closest('div[class*="flex"]')?.parentElement?.remove();
            }
        });

        // Rename "Continue browsing" overlay to look cooler
        document.querySelectorAll('.modalwrapper .title.alt').forEach(el => {
            if (el.innerText?.includes('Continue browsing')) el.innerText = 'Bypassing...';
        });
        document.querySelectorAll('.modalwrapper .subtitle').forEach(el => {
            if (el.innerText?.includes('Accept cookies')) el.innerText = 'Please wait... (Every message like this usually takes 10-15s to process)';
        });
    }, 50);

    function forceClick(btn) {
        btn.click();
        btn.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true }));
        btn.dispatchEvent(new MouseEvent('mouseup',   { bubbles: true, cancelable: true }));
        btn.dispatchEvent(new MouseEvent('click',     { bubbles: true, cancelable: true }));
        btn.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true }));
        btn.dispatchEvent(new PointerEvent('pointerup',   { bubbles: true }));
        if (btn.tagName === 'A' && btn.href) window.location.href = btn.href;
    }

    // Wait 10s after 'Proceed To Destination' / 'Go to Destination' appears before clicking
    let destClicked = false;
    let destFirstSeenAt2 = null;
    const destInterval = setInterval(() => {
        if (destClicked) { clearInterval(destInterval); return; }
        const btn = document.querySelector('.accessBtn');
        if (!btn) { destFirstSeenAt2 = null; return; }
        if (!destFirstSeenAt2) { destFirstSeenAt2 = Date.now(); return; }
        if (!window._workinkAutoClick) return;
        if (Date.now() - destFirstSeenAt2 < (window._workinkDestWait || 20000)) return;
        destClicked = true;
        clearInterval(destInterval);
        forceClick(btn);
    }, 50);

    // --- Part 2: WebSocket Patch for Extension/App Bypass (Works on Opera and others) ---
    (async () => {
        if (window.location.hostname.includes("r.")) window.location.hostname = window.location.hostname.replace("r.", "");
        if (window.location.hostname === "work.ink") {
            const [encodedUserId, linkCustom] = decodeURIComponent(window.location.pathname.slice(1)).split("/").slice(-2);
            const BASE = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
            const loopTimes = encodedUserId.length;
            let decodedUserId = BASE.indexOf(encodedUserId[0]);
            for (let i = 1; i < loopTimes; i++) decodedUserId = 62 * decodedUserId + BASE.indexOf(encodedUserId[i]);

            const payloads = {
                social: (url) => JSON.stringify({
                    type: "c_social_started",
                    payload: {
                        url
                    }
                }),
                readArticles: {
                    1: JSON.stringify({
                        type: "c_monetization",
                        payload: {
                            type: "readArticles",
                            payload: { event: "start" }
                        }
                    }),
                    2: JSON.stringify({
                        type: "c_monetization",
                        payload: {
                            type: "readArticles",
                            payload: { event: "closeClicked" }
                        }
                    })
                },
                browserExtension: {
                    1: JSON.stringify({
                        type: "c_monetization",
                        payload: {
                            type: "browserExtension",
                            payload: {
                                event: "start"
                            }
                        }
                    }),
                    2: (token) => JSON.stringify({
                        type: "c_monetization",
                        payload: {
                            type: "browserExtension",
                            payload: {
                                event: "confirm",
                                token
                            }
                        }
                    })
                },

            };

            // Patch WebSocket to intercept messages and skip monetization steps
            // NOTE: We do NOT intercept recaptcha — let the real Cloudflare solve it naturally
            const _origWSSend = WebSocket.prototype.send;
            WebSocket.prototype.send = function(data) {
                // If this is a fake captcha payload from old script versions, drop it
                try {
                    const parsed = JSON.parse(data);
                    if (parsed.type === "c_recaptcha" && parsed.payload?.token === "patched_bypass") return;
                } catch(e) {}
                _origWSSend.call(this, data);
            };

            // Listen to all WebSocket messages globally via a shared handler
            const _origWSAddListener = WebSocket.prototype.addEventListener;
            WebSocket.prototype.addEventListener = function(type, handler, opts) {
                if (type === 'message') {
                    const wrappedHandler = async (e) => {
                        const sleep = ms => new Promise(r => setTimeout(r, ms));
                        let data;
                        try { data = JSON.parse(e.data); } catch(err) { return handler(e); }
                        if (data.error) return;
                        const payload = data.payload;

                        switch (data.type) {
                            case "s_link_info":
                                if (payload.socials) socials.push(...payload.socials);
                                const monetizationTypes = ["readArticles", "browserExtension"];
                                for (const type of monetizationTypes) {
                                    if (payload.monetizationScript?.includes(type)) {
                                        activeMonetizationTypes.push(type);
                                    }
                                }
                                break;
                            case "s_recaptcha_okay":
                                // Real captcha passed — now skip the monetization steps
                                if (socials.length) {
                                    for (const social of socials) {
                                        _origWSSend.call(this, payloads.social(social.url));
                                        await sleep(2000);
                                    }
                                }
                                for (const type of activeMonetizationTypes) {
                                    switch (type) {
                                        case "readArticles":
                                            _origWSSend.call(this, payloads.readArticles["1"]);
                                            await sleep(500);
                                            _origWSSend.call(this, payloads.readArticles["2"]);
                                            break;
                                        case "browserExtension":
                                            _origWSSend.call(this, payloads.browserExtension["1"]);
                                            break;
                                    }
                                }
                                break;
                            case "s_monetization":
                                if (payload.type === "browserExtension") {
                                    _origWSSend.call(this, payloads.browserExtension["2"](payload.payload.token));
                                }
                                break;
                            case "s_link_destination":
                                const url = new URL(payload.url);
                                localStorage.clear(window.location.href);
                                if (url.searchParams.has("duf")) {
                                    window.location.href = window.atob(url.searchParams.get("duf").split("").reverse().join(""));
                                } else {
                                    window.location.href = payload.url;
                                }
                                break;
                        }
                        handler(e);
                    };
                    return _origWSAddListener.call(this, type, wrappedHandler, opts);
                }
                return _origWSAddListener.call(this, type, handler, opts);
            };

            let socials = [];
            let activeMonetizationTypes = [];
        } else if (window.location.hostname == "pass.work.ink") {
            // Just close — this is an article tracking tab we don't need
            window.close();
            setTimeout(() => window.close(), 300);
        } else if (window.location.hostname == "workink.click") {
            // Close this tab immediately — it's just an article popup we don't need
            window.close();
            setTimeout(() => window.close(), 500);
            document.body.innerHTML = "";
            history.back();
            const uuid = new URLSearchParams(window.location.search).get("t");
            fetch(`https://redirect-api.work.ink/externalPopups/${uuid}/pageOpened`);
            await new Promise(r => setTimeout(r, 11 * 1000));
            const { destination } = await fetch(`https://redirect-api.work.ink/externalPopups/${uuid}/destination`).then(r => r.json());
            const url = new URL(destination);
            if (url.searchParams.has("duf")) {
                window.location.href = window.atob(url.searchParams.get("duf").split("").reverse().join(""));
            } else {
                window.location.href = destination;
            }
        } else {
            if (new URL(window.location.href).searchParams.has("duf")) {
                var link = document.createElement("a");
                link.referrerPolicy = "no-referrer";
                link.rel = "noreferrer";
                link.href = window.atob(new URL(window.location.href).searchParams.get("duf").split("").reverse().join(""));
                link.click();
            }
        }
    })();

    // --- Part 3: Button Clicker & Tab Blocker ---

    // Block workink.click and pass.work.ink tabs
    const origOpen = window.open;
    window.open = function(url, target, features) {
        if (url && (url.includes('workink.click') || url.includes('pass.work.ink'))) return null;
        return origOpen.call(window, url, target, features);
    };
    // Block .cta-btn and any _blank link from opening new tabs
    document.addEventListener('click', (e) => {
        if (e._fromBypass) return;
        const cta = e.target.closest('.cta-btn');
        if (cta) { e.preventDefault(); e.stopPropagation(); return; }
        const a = e.target.closest('a');
        if (a && (a.target === '_blank' || a.href?.includes('pass.work.ink') || a.href?.includes('workink.click'))) {
            e.preventDefault();
            e.stopPropagation();
        }
    }, true);

    // Single smart clicker — priority order, stops after destination is reached
    let finalClicked = false;
    let destFirstSeenAt = null;
    // Reset timers when URL changes but keep a per-url click guard
    let lastHref = location.href;
    const clickedUrls = new Set();
    setInterval(() => {
        if (location.href !== lastHref) {
            lastHref = location.href;
            destFirstSeenAt = null;
            // Only reset finalClicked if this URL hasn't been clicked yet
            if (!clickedUrls.has(location.href)) {
                finalClicked = false;
            }
        }
        if (finalClicked) clickedUrls.add(location.href);
    }, 500);
    setInterval(() => {
        if (finalClicked) return;

        // Priority 1: article Learn more button — click to progress through articles
        // Use stopImmediatePropagation trick to bypass our own _blank blocker
        const article = document.querySelector('.cta-btn');
        if (article) {
            // Fire a non-cancelable event to register the click without navigating
            const evt = new MouseEvent('click', { bubbles: true, cancelable: false });
            evt._fromBypass = true;
            article.dispatchEvent(evt);
            return;
        }

        // Priority 3: accessBtn (verifying step) — only click if no Sign In modal is visible
        const access = document.querySelector('.button.large.accessBtn');
        if (access) {
            const modal = document.querySelector('.main-modal');
            const signInVisible = modal && modal.offsetParent !== null && getComputedStyle(modal).display !== 'none';
            if (signInVisible) return; // don't click if login modal is showing
            const text = access.innerText?.trim().toLowerCase();
            if (text.includes('destination') || text.includes('proceed') || text.includes('continue')) {
                forceClick(access);
            }
        }
    }, 500);
})();