web.de-Login

Auto login e click Weiter su millionenklick.web.de

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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();

})();