web.de-Login

Auto login e click Weiter su millionenklick.web.de

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

Advertisement:

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

})();