一个能自动填写HMV用户名和密码的油猴脚本

水一篇文章

抓包了auth.php的登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
POST /login/auth.php HTTP/1.1
Host: hackmyvm.eu
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br, zstd
Content-Type: application/x-www-form-urlencoded
Content-Length: 45
Origin: https://hackmyvm.eu
Connection: keep-alive
Referer: https://hackmyvm.eu/login/
Cookie: PHPSESSID=c16a43q3gtbg7bu59ing2p0o2u
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i

admin=you_know_who&password_usuario=i_dont_know

之后又把HMV登录界面的html下载下来让ai分析

于是就有了如下的脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// ==UserScript==
// @name HackMyVM Auto Fill (ID-Based)
// @namespace http://tampermonkey.net/
// @version 2026-01-09
// @description 基于HTML源码优化的自动填充脚本
// @author kaada
// @match https://hackmyvm.eu/login/*
// @grant none
// @run-at document-end
// ==/UserScript==

(function() {
'use strict';

// === ⚙️ 配置区域 ===
const CONFIG = {
username: "填你自己的",
password: "填你自己的", // 你的密码
autoSubmit: false // 设为 true 可自动点击登录
};

// === 🔧 模拟真实输入函数 ===
// 即使页面是纯 HTML,模拟事件也能防止浏览器不记录自动填充的值
function simulateInput(element, value) {
if (!element) return;
element.focus();
element.value = value;
element.dispatchEvent(new Event('input', { bubbles: true }));
element.dispatchEvent(new Event('change', { bubbles: true }));
element.blur(); // 失去焦点,有时能触发网页的验证逻辑
}

// === 🔄 轮询检测逻辑 ===
let attempt = 0;
const maxAttempts = 30; // 尝试约 15 秒

const timer = setInterval(() => {
attempt++;

// 1. 使用 ID 选择器 (基于你提供的 HTML)
const userField = document.getElementById('inputEmail');
const passField = document.getElementById('inputPassword');

// 2. 查找提交按钮 (定位到 form-signin 类下的 submit 按钮)
const submitBtn = document.querySelector('.form-signin button[type="submit"]');

if (userField && passField) {
console.log("✅ [HackMyVM] 找到输入框 (ID匹配),正在填充...");

// 执行填充
simulateInput(userField, CONFIG.username);
simulateInput(passField, CONFIG.password);

// 停止轮询
clearInterval(timer);

// 自动提交逻辑
if (CONFIG.autoSubmit && submitBtn) {
console.log("🚀 [HackMyVM] 正在自动点击登录...");
submitBtn.click();
}
} else {
console.log(`⏳ [HackMyVM] 等待元素加载... (${attempt}/${maxAttempts})`);
}

// 超时处理
if (attempt >= maxAttempts) {
clearInterval(timer);
console.error("❌ [HackMyVM] 脚本超时:未找到 id='inputEmail' 或 id='inputPassword'。");
}

}, 500); // 每 500ms 检查一次

虽然很水,不过因为HMV的session时长太短了,觉得还是比较有用的。


一个能自动填写HMV用户名和密码的油猴脚本
http://example.com/2026/01/09/一个能自动填写HMV用户名和密码的油猴脚本/
Author
Skyarrow
Posted on
January 9, 2026
Licensed under