// ==UserScript==
// @name         企信登录（内网）
// @namespace    http://tampermonkey.net/
// @version      2025-04-17
// @description  try to take over the world!
// @author       You
// @match        https://qx.ynydtk.cn:8443/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ynydtk.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
	const users = {
        "杜奕新": { phone: "15198716095", password: "Q{dr.086589)", left: "0px" },
        "郭希恒": { phone: "18519953030", password: "G99o09%79f1#", left: "100px" },
        "张成伟": { phone: "15987134500", password: "Zcw@#$4500", left: "200px" }
    };

    const accountInput = document.querySelector("input[placeholder=\"请输入手机号\"]");
    const passwordInput = document.querySelector("input[placeholder=\"请输入密码\"]");
    function createButton(text, userData) {
        const button = document.createElement("button");
        button.textContent = text;
        Object.assign(button.style, {
            backgroundColor: "#6672fb",
            border: "none",
            color: "white",
            textAlign: "center",
            textDecoration: "none",
            display: "inline-block",
            fontSize: "16px",
            margin: "4px 2px",
            cursor: "pointer",
            borderRadius: "5px",
            transition: "box-shadow 0.3s ease-in-out",
            height: "30px",
            width: "85px",
            position: "absolute",
            top: "-40px",
            left: userData.left
        });
        button.addEventListener("mouseover", () => button.style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2)");
        button.addEventListener("mouseout", () => button.style.boxShadow = "none");
        button.addEventListener("click", () => {
            fillInputs(userData.phone, userData.password);
           });
        return button;
    }

    function fillInputs(phone, password) {
        if (accountInput) simulateInput(accountInput, phone);
        if (passwordInput) simulateInput(passwordInput, password);
    }

    function simulateInput(element, text) {
        element.value = text;
        element.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
		const captchaInput = document.querySelector("input[placeholder=\"请输入验证码\"]");
		captchaInput.focus();
    }

    accountInput.style.position = "relative";
    Object.entries(users).forEach(([name, data]) => {
        const button = createButton(name, data);
        accountInput.parentNode.insertBefore(button, accountInput);
    });
})();