no message

This commit is contained in:
yinjun.chen1
2026-09-15 15:08:36 +08:00
parent ebcd21587f
commit f305b0fb63
+20 -6
View File
@@ -1,6 +1,20 @@
const t = (key, ...args) => chrome.i18n.getMessage(key, args) || key;
async function safeStorageGet(area, keys) {
try {
return await chrome.storage[area].get(keys);
} catch {
return {};
}
}
async function safeStorageSet(area, items) {
try {
await chrome.storage[area].set(items);
} catch {}
}
// 2FA / 验证码检测:检测到则不自动提交,仅填充
function detectCaptcha() {
// reCAPTCHA
@@ -290,36 +304,36 @@ function attemptKey(envId, domain) {
async function getDomainAttempts(envId, domain) {
const key = attemptKey(envId, domain);
const data = await chrome.storage.local.get("loginAttempts");
const data = await safeStorageGet("local", "loginAttempts");
const attempts = data.loginAttempts || {};
return attempts[key] || { count: 0, lastAttempt: 0 };
}
async function incrementDomainAttempts(envId, domain) {
const key = attemptKey(envId, domain);
const data = await chrome.storage.local.get("loginAttempts");
const data = await safeStorageGet("local", "loginAttempts");
const attempts = data.loginAttempts || {};
const cur = attempts[key] || { count: 0, lastAttempt: 0 };
cur.count += 1;
cur.lastAttempt = Date.now();
attempts[key] = cur;
await chrome.storage.local.set({ loginAttempts: attempts });
await safeStorageSet("local", { loginAttempts: attempts });
return cur;
}
async function resetDomainAttempts(envId, domain) {
const key = attemptKey(envId, domain);
const data = await chrome.storage.local.get("loginAttempts");
const data = await safeStorageGet("local", "loginAttempts");
const attempts = data.loginAttempts || {};
if (attempts[key]) {
delete attempts[key];
await chrome.storage.local.set({ loginAttempts: attempts });
await safeStorageSet("local", { loginAttempts: attempts });
}
}
async function loadAllConfigs() {
const data = await chrome.storage.session.get("environments");
const data = await safeStorageGet("session", "environments");
const environments = data.environments || [];
const all = [];
environments.forEach((env) => {