web.de-Login

Auto login e click Weiter su millionenklick.web.de

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name         web.de-Login
// @namespace    http://tampermonkey.net/
// @version      25.0
// @icon         https://i.imgur.com/GbIXQZ2.png
// @description  Auto login e click Weiter su millionenklick.web.de
// @author       Franz
// @match        *://millionenklick.web.de/*
// @run-at       document-idle
// @grant        GM_getValue
// @grant        GM_setValue
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

    function setInputValue(el, value) {
        const nativeSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
        nativeSetter.call(el, value);
        el.dispatchEvent(new Event('input', { bubbles: true }));
        el.dispatchEvent(new Event('change', { bubbles: true }));
    }

    function clickAtElement(el) {
        const rect = el.getBoundingClientRect();
        const x = rect.left + rect.width / 2;
        const y = rect.top + rect.height / 2;
        const target = document.elementFromPoint(x, y) || el;
        ['mouseover', 'mousedown', 'mouseup', 'click'].forEach(type => {
            target.dispatchEvent(new MouseEvent(type, { bubbles: true, cancelable: true, clientX: x, clientY: y }));
        });
    }

    async function getCredentials() {
        let username = GM_getValue('wde_user', '');
        let password = GM_getValue('wde_pass', '');
        if (!username || !password) {
            username = prompt('Username (salvato per le prossime volte):');
            password = prompt('Password (salvata per le prossime volte):');
            if (!username || !password) return null;
            GM_setValue('wde_user', username);
            GM_setValue('wde_pass', password);
        }
        return { username, password };
    }

    async function run() {
        const url = window.location.href;

        // === FASE 1: Pagina login — compila e clicca login ===
        const usernameField = document.getElementById('mioklickuser');
        if (usernameField) {
            const passwordField = document.getElementById('mioklickpassword');
            const loginBtn = document.getElementById('login');

            const creds = await getCredentials();
            if (!creds) return;

            setInputValue(usernameField, creds.username);
            setInputValue(passwordField, creds.password);
            await delay(300);

            console.log('[web.de] Click Login');
            sessionStorage.setItem('wde_phase', 'weiter');
            clickAtElement(loginBtn);
            return;
        }

        // === FASE 2: Su /spielen — clicca Weiter ===
        if (url.includes('/spielen')) {
            if (sessionStorage.getItem('wde_phase') !== 'weiter') return;

            await delay(1000);
            const weiterBtn = document.getElementById('weiter');
            if (weiterBtn) {
                console.log('[web.de] Click Weiter');
                clickAtElement(weiterBtn);
                sessionStorage.setItem('wde_phase', 'done');
            } else {
                console.warn('[web.de] Weiter non trovato');
            }
            return;
        }

        // === Reset ===
        if (sessionStorage.getItem('wde_phase') === 'done') {
            sessionStorage.removeItem('wde_phase');
        }
    }

    run();

})();