Work.ink Auto Access Script

Automatically clicks through access/skip buttons on work.ink

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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         Work.ink Auto Access Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically clicks through access/skip buttons on work.ink
// @author       You
// @match        *://*.work.ink/*
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(async function () {
    const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

    const waitForElement = (selector, timeout = 5000, interval = 100) => {
        return new Promise((resolve, reject) => {
            const start = Date.now();
            const check = () => {
                const el = document.querySelector(selector);
                if (el) return resolve(el);
                if (Date.now() - start > timeout) return reject();
                setTimeout(check, interval);
            };
            check();
        });
    };

    const clickMultipleTimes = async (element, times = 5, delay = 250) => {
        for (let i = 0; i < times; i++) {
            element.click();
            await sleep(delay);
        }
    };

    try {
        let el = await waitForElement('.accessBtn');
        el.click();

        el = await waitForElement('#access-offers');
        await clickMultipleTimes(el);

        el = await waitForElement('div.button.large.accessBtn.pos-relative.svelte-iyommg');
        el.click();

        try {
            el = await waitForElement('.skipBtn');
            el.click();
        } catch {
            el = await waitForElement('#access-offers');
            await clickMultipleTimes(el);
            return;
        }

        try {
            el = await waitForElement('.closelabel');
            el.click();
        } catch {
            el = await waitForElement('#access-offers');
            await clickMultipleTimes(el);
            return;
        }

        el = await waitForElement('button.w-full.bg-gray-100');
        el.click();

        el = await waitForElement('button.w-full.bg-emerald-600.text-white.rounded-full');
        await clickMultipleTimes(el);
    } catch (e) {
        console.warn("Script error:", e);
    }
})();