feat: implement custom node.js sync server and secure extension client with login/register UI

This commit is contained in:
jason
2026-03-03 23:50:26 +08:00
parent 0803f9cc14
commit fc4898a9ee
8 changed files with 629 additions and 99 deletions

View File

@@ -139,6 +139,78 @@ function autoFillLogin(username, password) {
passwordEl.focus();
setNativeValue(passwordEl, password);
triggerEvents(passwordEl);
// --- New: Auto-click Login Button ---
setTimeout(() => {
// 常规登录按钮选择器
const loginButtonSelectors = [
'button[type="submit"]',
'input[type="submit"]',
'button.login-btn',
'button.submit-btn',
'#login-btn',
'.login-button',
'button.ant-btn-primary' // 适配 Ant Design
];
let loginBtn = null;
for (const selector of loginButtonSelectors) {
const btn = document.querySelector(selector);
if (btn && btn.offsetWidth > 0 && btn.offsetHeight > 0) {
loginBtn = btn;
break;
}
}
// 如果没有按选择器找到,尝试按文本内容查找
if (!loginBtn) {
const allBtns = document.querySelectorAll('button, div[role="button"], span');
for (const btn of allBtns) {
const text = btn.innerText || btn.textContent;
if (btn.offsetWidth > 0 && btn.offsetHeight > 0 &&
(text.includes('登录') || text.includes('Log In') || text.includes('Login')) &&
btn.tagName !== 'BODY') {
loginBtn = btn;
break;
}
}
}
if (loginBtn) {
console.log("[QuickPurge] Login button found, clicking...");
loginBtn.click();
// --- New: Secondary Confirmation Auto-click ---
// 登录后开启定时检测,识别“账号已登录”确认弹窗
let confirmTries = 0;
const confirmInterval = setInterval(() => {
confirmTries++;
const allBtns = document.querySelectorAll('button, div[role="button"], span');
let confirmBtn = null;
for (const btn of allBtns) {
const text = (btn.innerText || btn.textContent).trim();
// 匹配“确认”、“继续登录”等文字,且由于是弹窗按钮,通常会有特定的类名
if (btn.offsetWidth > 0 && btn.offsetHeight > 0 &&
(text === '确认' || text === '确定' || text === '继续登录' || text === 'Confirm') &&
btn.tagName !== 'BODY') {
confirmBtn = btn;
break;
}
}
if (confirmBtn) {
console.log("[QuickPurge] Secondary confirmation button found, clicking...");
confirmBtn.click();
clearInterval(confirmInterval);
}
if (confirmTries > 20) { // 最多检测 5 秒 (250mx * 20)
clearInterval(confirmInterval);
}
}, 250);
}
}, 300); // 填充完后等待 300ms 点击,确保框架已处理输入
}, 50);
return true;