New:Socket for Asana Is Now Available.Learn more
Get Started

宇起密码管理

Package Overview
Versions
2
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yuqi@yuqidata.com - firefox Package Compare versions

Comparing version
1.75
to
1.76
+272
-197
base/background.js

@@ -0,238 +1,313 @@

//导入
// importScripts("./crypto-js.min.js");
port = null;
if (!port) {
connect();
console.log("这里是初始化启动");
//定时任务2s再连接
connect();
// setTimeout(connect,10000);
}
box = 0;
// 存储当前网易邮箱域名
var currentNeteaseDomain = null;
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.msg === "fillForm") {
}
//获取当前的port状态
if (request.stateMsg === "getState") {
if (!port) {
//返回response
sendResponse({ res: "disconnect" });
} else if (port) {
sendResponse({ res: "connected" });
//询问middleAPP IPC的当前状态
var data = { command: "getIpcState" };
sendNativeMessage(data);
if (request.msg === "fillForm") {
//获取填充的数据
// var data = request.msgData;
// browser.tabs.query({ active: true, currentWindow: true }, tabs => {
// //执行填充脚本
// const tab = tabs[0];
// browser.scripting.executeScript({
// target: { tabId: tab.id },
// function: autofillCredentials,
// args:[request.msgData]
// });
// });
}
}
if (request.stateMsg === "reConnectReq") {
//发送新的连接请求
connect();
if (port === null) {
sendResponse({ res: "fail" });
} else {
sendResponse({ res: "success" });
// 处理网易邮箱域名
if (request.type === "neteaseDomain") {
console.log('[background] 接收网易域名:', request.fhostUrl, request.mainUrl);
// 存储当前网易邮箱域名
currentNeteaseDomain = {
fhostUrl: request.fhostUrl,
mainUrl: request.mainUrl
};
if (port) {
var data = {
fhostUrl: request.fhostUrl,
mainUrl: request.mainUrl
};
// console.log('[background] 发送给后端:', JSON.stringify(data));
sendNativeMessage(data);
}
sendResponse({ res: "success" });
}
}
//获取当前的port状态
if (request.stateMsg === "getState") {
if (!port) {
//返回response
sendResponse({ res: "disconnect" });
} else if (port) {
sendResponse({ res: "connected" });
//询问middleAPP IPC的当前状态
var data = { command: 'getIpcState' }
sendNativeMessage(data);
}
}
if (request.stateMsg === "reConnectReq") {
//发送新的连接请求
connect();
if (port === null) {
sendResponse({ res: "fail" });
} else {
sendResponse({ res: "success" });
}
}
});
// 初始化时设置全局变量
// browser.runtime.onInstalled.addListener(function (details) {
// connect();
// });
browser.runtime.onStartup.addListener(function () {
console.log("插件已启动!");
// 在这里编写你想要执行的代码
// connect();
// 在这里编写你想要执行的代码
if (!port) {
// connect();
}
});
function disConnect() {
console.log("连接已被关闭");
var data = { command: "closeConnection" };
sendNativeMessage(data);
var data = { command: 'closeConnection' }
sendNativeMessage(data);
}
//nativeMessage连接
function connect() {
var hostName = "com.yuqidata.y05";
console.log("正在连接本地应用....: " + hostName);
port = browser.runtime.connectNative(hostName);
console.log(port);
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
try {
var hostName = "com.yuqidata.y05";
port = browser.runtime.connectNative(hostName);
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
console.log('[background] 成功连接到原生应用:', hostName);
} catch (error) {
console.error('[background] 连接原生应用失败:', error);
port = null;
// 10秒后重试
setTimeout(connect, 10000);
}
}
// 监听标签页切换,清理网易邮箱域名缓存
browser.tabs.onActivated.addListener(function() {
currentNeteaseDomain = null;
});
browser.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.url && tab.url && !tab.url.includes('email.163.com')) {
currentNeteaseDomain = null;
}
});
//监听来自应用程序的消息
function onNativeMessage(message) {
console.log("Received message: " + JSON.stringify(message));
if (message.command == "requestUrl") {
//发送当前的fhostUrl
browser.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var currentTab = tabs[0];
console.log(currentTab);
if (currentTab && currentTab.url) {
// getCurPageInfo();
// 获取 URL
var url = new URL(currentTab.url);
// 提取主域名
var domain = url.hostname;
var urlInfo = getFullAndMainDomain(domain);
//返回全域名 给上位机做判断
var data = {
fhostUrl: urlInfo.fullDomain,
mainUrl: urlInfo.mainDomain,
// boxLength: box,
};
// // 只保存主域名信息
sendNativeMessage(data);
} else {
var data = { fhostUrl: "null" };
sendNativeMessage(data);
}
});
}
//填充密码
if (message.pwd) {
browser.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const tab = tabs[0];
// 获取 URL
var url = new URL(tab.url);
// 提取主域名
var domain = url.hostname;
var urlInfo = getFullAndMainDomain(domain);
if (message.command == "requestUrl") {
var msgData = {
account: message.account,
pwd: message.pwd,
pass: message.pass,
curUrl: urlInfo.fullDomain,
};
//发送到注入脚本中 填充密码
browser.tabs.sendMessage(tab.id, {
stateMsg: "fillAction",
dataMsg: msgData,
});
});
}
//上位机与中间程序通信断开的处理
if (message.command == "ipcDisconnect") {
//发送消息到popup
browser.runtime.sendMessage({
stateMsg: "ipcDisconnect",
function(response) {
// console.log(response.farewell);
},
});
}
//发送当前的fhostUrl
browser.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var currentTab = tabs[0];
// console.log(currentTab)
if (currentTab && currentTab.url) {
// 如果是网易邮箱页面且有缓存的域名,使用缓存的域名
if (currentTab.url.includes('email.163.com') && currentNeteaseDomain) {
console.log('[background] requestUrl: 使用缓存的网易域名:', currentNeteaseDomain);
sendNativeMessage(currentNeteaseDomain);
return;
}
// 获取 URL
var url = new URL(currentTab.url);
// 提取主域名
var domain = url.hostname;
var urlInfo = getFullAndMainDomain(domain);
//返回全域名 给上位机做判断
var data = {
fhostUrl: urlInfo.fullDomain,
mainUrl: urlInfo.mainDomain
}
// console.log('[background] requestUrl: 使用标准域名:', data)
sendNativeMessage(data);
} else {
var data = { fhostUrl: "null" }
sendNativeMessage(data);
}
});
}
//填充密码
if (message.pwd) {
browser.tabs.query({ active: true, currentWindow: true }, tabs => {
const tab = tabs[0];
// 获取 URL
var url = new URL(tab.url);
// 提取主域名+--
var domain = url.hostname;
var urlInfo = getFullAndMainDomain(domain);
var msgData = {
account: message.account,
pwd: message.pwd,
pass: message.pass,
curUrl: urlInfo.fullDomain
}
//发送到注入脚本中填充
browser.tabs.sendMessage(tab.id, { stateMsg: "fillAction", dataMsg: msgData });
});
}
//上位机与中间程序通信断开的处理
if (message.command == "ipcDisconnect") {
//发送消息到popup
browser.runtime.sendMessage({
stateMsg: "ipcDisconnect", function(response) {
}
})
}
}
//监听断开应用程序时
function onDisconnected() {
console.log("Failed to connect: " + browser.runtime);
port = null;
setTimeout(connect, 10000);
if (!port) {
console.log('[background] 原生应用连接断开');
port = null;
//尝试重新连接
setTimeout(function() {
console.log('[background] 尝试重新连接原生应用...');
connect();
}, 10000);
//发送已断开的消息到popup
browser.runtime.sendMessage({
stateMsg: "disconnected",
function(response) {
console.log(response.farewell);
},
});
}
try {
browser.runtime.sendMessage({
stateMsg: "disconnected"
}, function(response) {
if (browser.runtime.lastError) {
console.error('[background] 发送断开消息失败:', browser.runtime.lastError);
}
});
} catch (error) {
console.error('[background] 发送断开消息异常:', error);
}
}
//发送消息
function sendNativeMessage(data) {
// var message = { "fhostUrl": "www.baidu.com" };
port.postMessage(data);
console.log("Sent message: " + JSON.stringify(data));
try {
if (port) {
port.postMessage(data);
// console.log('[background] 成功发送消息:', JSON.stringify(data));
} else {
console.error('[background] 端口未连接,无法发送消息:', JSON.stringify(data));
}
} catch (error) {
console.error('[background] 发送消息失败:', error);
// 尝试重新连接
if (!port) {
console.log('[background] 尝试重新连接...');
connect();
}
}
}
function autofillCredentials(data) {
const usernameInput = document.querySelectorAll(
'input[type="email"],input[type="text"],input[type="text"][name="userName"], input[type="email"][name="userName"], input[type="account"][name="userName"],input[placeholder="邮箱"]'
);
// 修改密码输入框选择器,排除验证码输入框
const passwordInput = document.querySelectorAll(
'input[type="password"],input[name="password"][type="password"]'
);
if (usernameInput && passwordInput) {
usernameInput.forEach(function (element) {
//模拟键盘输入
var event = new Event("input", { bubbles: true });
element.value = data.account;
element.dispatchEvent(event);
});
passwordInput.forEach(function (element) {
var event = new Event("input", { bubbles: true });
element.value = data.pwd;
element.dispatchEvent(event);
});
var form = passwordInput[0].closest("form");
//用户协议勾选
var checkbox = form.querySelectorAll(
'input[type="checkbox"][name="isAgree"],input[type="checkbox"]'
);
const usernameInput = document.querySelectorAll('input[type="email"],input[type="text"],input[type="text"][name="userName"], input[type="email"][name="userName"], input[type="account"][name="userName"],input[placeholder="邮箱"]');
const passwordInput = document.querySelectorAll('input[type="password"],input[name="password"][type="password"]');
if (usernameInput && passwordInput) {
usernameInput.forEach(function (element) {
//模拟键盘输入
var event = new Event('input', { bubbles: true });
if (checkbox) {
checkbox.forEach(function (element) {
if (!element.checked) {
element.click();
element.value = data.account;
element.dispatchEvent(event);
})
passwordInput.forEach(function (element) {
var event = new Event('input', { bubbles: true });
element.value = data.pwd;
element.dispatchEvent(event);
})
var form = passwordInput[0].closest('form');
//用户协议勾选
var checkbox = form.querySelectorAll('input[type="checkbox"][name="isAgree"],input[type="checkbox"]');
if (checkbox) {
checkbox.forEach(function (element) {
if (!element.checked) {
element.click();
}
})
// checkbox.click();
}
});
// checkbox.click();
//填充完毕后 按下回车
var button = form.querySelector('[type="submit"],button');
button.click();
// 查找包含 "登录" 文字的按钮
const buttonsWithLoginText = Array.from(document.querySelectorAll('button'))
.filter(button => button.textContent.includes('登录'));
// 查找包含 "登录" 文字的超链接
const linksWithLoginText = Array.from(document.querySelectorAll('a'))
.filter(link => link.textContent.includes('登录'));
// 输出结果
}
//填充完毕后 按下回车
var button = form.querySelector('[type="submit"],button');
console.log(button);
button.click();
// 查找包含 "登录" 文字的按钮
const buttonsWithLoginText = Array.from(
document.querySelectorAll("button")
).filter((button) => button.textContent.includes("登录"));
// 查找包含 "登录" 文字的超链接
const linksWithLoginText = Array.from(
document.querySelectorAll("a")
).filter((link) => link.textContent.includes("登录"));
// 输出结果
console.log('包含 "登录" 文字的按钮:', buttonsWithLoginText);
console.log('包含 "登录" 文字的超链接:', linksWithLoginText);
}
}
function getFullAndMainDomain(url) {
// 移除协议部分和前导的 www.
url = url.replace(/^(https?:\/\/)?(www\.)?/, "");
// 移除协议部分和前导的 www.
url = url.replace(/^(https?:\/\/)?(www\.)?/, '');
// 检查是否是IP地址
const ipPattern =
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if (ipPattern.test(url)) {
return { fullDomain: url, mainDomain: url };
}
// 检查是否是IP地址
const ipPattern = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if (ipPattern.test(url)) {
return { fullDomain: url, mainDomain: url };
}
// 拆分域名部分
let domainParts = url.split('/')[0].split('.');
// 拆分域名部分
let domainParts = url.split("/")[0].split(".");
// 特殊处理双层域名
const commonTlds = ['com', 'org', 'net', 'gov', 'edu', 'mil', 'int'];
const countryTlds = ['cn', 'uk', 'jp', 'kr', 'au', 'br', 'in', 'ru', 'de', 'fr'];
// 特殊处理双层域名
const commonTlds = ["com", "org", "net", "gov", "edu", "mil", "int"];
const countryTlds = [
"cn",
"uk",
"jp",
"kr",
"au",
"br",
"in",
"ru",
"de",
"fr",
];
let mainDomain;
let domainLength = domainParts.length;
let mainDomain;
let domainLength = domainParts.length;
if (domainLength >= 3 && countryTlds.includes(domainParts[domainLength - 1]) && commonTlds.includes(domainParts[domainLength - 2])) {
mainDomain = domainParts.slice(domainLength - 3).join('.');
} else {
mainDomain = domainParts.slice(domainLength - 2).join('.');
}
if (
domainLength >= 3 &&
countryTlds.includes(domainParts[domainLength - 1]) &&
commonTlds.includes(domainParts[domainLength - 2])
) {
mainDomain = domainParts.slice(domainLength - 3).join(".");
} else {
mainDomain = domainParts.slice(domainLength - 2).join(".");
}
// 重新组装完整域名
let fullDomain = domainParts.join('.');
// 重新组装完整域名
let fullDomain = domainParts.join(".");
return { fullDomain: fullDomain, mainDomain: mainDomain };
return { fullDomain: fullDomain, mainDomain: mainDomain };
}

@@ -110,2 +110,89 @@ const possibleSelectors = [

// 网易邮箱检测 - 只在 https://email.163.com/ 页面
(function() {
if (!window.location.href.includes('email.163.com')) {
return;
}
function sendDomain() {
const loginBoxes = document.querySelectorAll('.u-urs-login');
let fhostUrl = 'email.163.com';
let mainUrl = '163.com';
let activeBoxType = 'mail-163';
console.log('检测登录框,总数:', loginBoxes.length);
for (const box of loginBoxes) {
console.log('登录框class:', box.className);
if (!box.classList.contains('tab-hidden')) {
if (box.classList.contains('mail-126')) {
fhostUrl = 'www.126.com';
mainUrl = '126.com';
activeBoxType = 'mail-126';
break;
} else if (box.classList.contains('mail-yeah')) {
fhostUrl = 'www.yeah.net';
mainUrl = 'yeah.net';
activeBoxType = 'mail-yeah';
break;
}
}
}
console.log('当前激活登录框类型:', activeBoxType);
console.log('发送域名:', { fhostUrl, mainUrl });
browser.runtime.sendMessage({
type: 'neteaseDomain',
fhostUrl: fhostUrl,
mainUrl: mainUrl
}, function(response) {
if (browser.runtime.lastError) {
console.error('[content] 发送消息失败:', browser.runtime.lastError);
} else {
console.log('[content] 消息发送成功:', response);
}
});
}
// 页面加载后检测
setTimeout(sendDomain, 500);
// 监听切换 - 优化监听逻辑
const observer = new MutationObserver(function(mutations) {
let shouldSend = false;
mutations.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
const target = mutation.target;
if (target.classList.contains('u-urs-login')) {
shouldSend = true;
}
}
});
if (shouldSend) {
console.log('检测到class变化,重新发送域名');
sendDomain();
}
});
// 监听所有登录框
document.querySelectorAll('.u-urs-login').forEach(box => {
observer.observe(box, { attributes: true, attributeFilter: ['class'] });
});
// 如果页面动态加载,重新监听
const checkAndObserve = () => {
const newBoxes = document.querySelectorAll('.u-urs-login');
newBoxes.forEach(box => {
if (!box.hasAttribute('data-observed')) {
box.setAttribute('data-observed', 'true');
observer.observe(box, { attributes: true, attributeFilter: ['class'] });
}
});
};
// 定期检查新元素
setInterval(checkAndObserve, 500);
})();
// 选中操作函数

@@ -157,8 +244,3 @@ function checkboxOperation(checkbox) {

const dispatched = element.dispatchEvent(event);
console.log(
`${event.type} 键已模拟触发于:`,
element,
"事件分发结果:",
dispatched
);
});

@@ -177,3 +259,3 @@ } catch (error) {

event.preventDefault();
console.log("已阻止表单默认提交刷新:", form);
};

@@ -185,3 +267,3 @@ form.addEventListener("submit", preventRefresh, { once: true });

const dispatched = form.dispatchEvent(submitEvent);
console.log("模拟表单提交事件:", dispatched ? "成功" : "失败");

@@ -194,3 +276,3 @@ // 如果有提交按钮,模拟点击

submitButton.click();
console.log("触发提交按钮点击:", submitButton);
}

@@ -201,3 +283,3 @@ }

element.click();
console.log(`触发${type}点击:`, element);
return true;

@@ -302,3 +384,3 @@ }

(input.type === "text" &&
!input.name &&
!input.name &&
!input.id &&

@@ -326,3 +408,6 @@ (labelText.includes("手机号") ||

(input.type === "password" && input.name !== "rpwd") ||
input.name === "password";
input.name === "password" ||
input.id === "inputPswd" ||
(input.placeholder && input.placeholder.includes("密码")) ||
(input.type === "text" && input.onfocus && input.onfocus.toString().includes("password"));

@@ -344,6 +429,2 @@ return (

usernameInput.forEach(function (element) {
console.log("找到用户名输入框:", element);
console.log("输入框类名:", element.className);
console.log("输入框父容器:", element.closest("div"));
const mEvent = new MouseEvent("click", {

@@ -363,3 +444,3 @@ view: window,

element.dispatchEvent(event);
console.log("已填充用户名:", data.account);
});

@@ -378,2 +459,9 @@

element.focus();
// 如果是动态类型密码框,先触发focus事件让type变为password
if (element.id === "inputPswd" || (element.type === "text" && element.onfocus)) {
const focusEvent = new Event("focus", { bubbles: true });
element.dispatchEvent(focusEvent);
}
const event = new Event("input", { bubbles: true });

@@ -386,5 +474,6 @@ element.value = data.pwd;

setTimeout(() => {
// 在提交前勾选隐私协议
checkPrivacyAgreement();
console.log("隐私协议已尝试勾选");
// 在提交前勾选隐私协议,仅当 data.pass == 1 时勾选
if (data.pass == 1) {
checkPrivacyAgreement();
}

@@ -408,6 +497,3 @@ const form = element.closest("form");

typeButton.click();
console.log(
'电子税务局点击了 type="button" 的按钮:',
typeButton
);
return;

@@ -430,3 +516,3 @@ }

// customSubmitDiv.click();
// console.log("触发自定义登录 div 点击:", customSubmitDiv);
// return;

@@ -441,3 +527,3 @@ // }

submitButton.click();
console.log("尝试点击提交按钮:", submitButton);
}, 200);

@@ -456,3 +542,3 @@ }

// 只有账号框时,填充后不提交,仅记录日志
console.log("仅找到用户名输入框,已填充账号,未执行提交");
}

@@ -499,4 +585,3 @@ } else {

function autofillCredentials(data) {
console.log("YuQi AutoFill was called");
console.log(data)
// 如果只有勾选隐私协议

@@ -503,0 +588,0 @@ if (data.pwd === "*") {

@@ -5,3 +5,3 @@ {

"name": "\u5b87\u8d77\u5bc6\u7801\u7ba1\u7406",
"version": "1.75",
"version": "1.76",
"icons": {

@@ -8,0 +8,0 @@ "48": "/icons/yq120.png"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet