web.de-Login

Auto login e click Weiter su millionenklick.web.de

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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

})();