Work.ink Auto Access Script

Automatically clicks through access/skip buttons on work.ink

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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);
    }
})();