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

宇起密码管理

Package Overview
Versions
1
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.76
to
1.77
+268
-249
base/background.js

@@ -5,6 +5,6 @@ //导入

if (!port) {
//定时任务2s再连接
//定时任务2s再连接
connect();
// setTimeout(connect,10000);
connect();
// setTimeout(connect,10000);
}

@@ -16,100 +16,99 @@ box = 0;

browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
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.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" });
}
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.type === "neteaseDomain") {
console.log(
"[background] 接收网易域名:",
request.fhostUrl,
request.mainUrl,
);
//获取当前的port状态
if (request.stateMsg === "getState") {
// 存储当前网易邮箱域名
currentNeteaseDomain = {
fhostUrl: request.fhostUrl,
mainUrl: request.mainUrl,
};
if (!port) {
//返回response
sendResponse({ res: "disconnect" });
} else if (port) {
if (port) {
var data = {
fhostUrl: request.fhostUrl,
mainUrl: request.mainUrl,
};
console.log("[background] 发送给后端:", JSON.stringify(data));
sendNativeMessage(data);
}
sendResponse({ res: "success" });
}
sendResponse({ res: "connected" });
//询问middleAPP IPC的当前状态
var data = { command: 'getIpcState' }
sendNativeMessage(data);
}
//获取当前的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" });
}
if (request.stateMsg === "reConnectReq") {
//发送新的连接请求
connect();
if (port === null) {
sendResponse({ res: "fail" });
} else {
sendResponse({ res: "success" });
}
}
});
browser.runtime.onStartup.addListener(function () {
// 在这里编写你想要执行的代码
if (!port) {
// connect();
}
// 在这里编写你想要执行的代码
if (!port) {
// connect();
}
});
function disConnect() {
var data = { command: 'closeConnection' }
sendNativeMessage(data);
var data = { command: "closeConnection" };
sendNativeMessage(data);
}
//nativeMessage连接
function connect() {
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);
}
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.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;
}
browser.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.url && tab.url && !tab.url.includes("email.163.com")) {
currentNeteaseDomain = null;
}
});

@@ -119,71 +118,71 @@

function onNativeMessage(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) {
// 如果是网易邮箱页面且有缓存的域名,使用缓存的域名
if (currentTab.url.includes("email.163.com") && currentNeteaseDomain) {
console.log(
"[background] requestUrl: 使用缓存的网易域名:",
currentNeteaseDomain,
);
sendNativeMessage(currentNeteaseDomain);
return;
}
if (message.command == "requestUrl") {
// 获取 URL
var url = new URL(currentTab.url);
// 提取主域名
var domain = url.hostname;
//发送当前的fhostUrl
browser.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var currentTab = tabs[0];
// console.log(currentTab)
if (currentTab && currentTab.url) {
var urlInfo = getFullAndMainDomain(domain);
// 如果是网易邮箱页面且有缓存的域名,使用缓存的域名
if (currentTab.url.includes('email.163.com') && currentNeteaseDomain) {
console.log('[background] requestUrl: 使用缓存的网易域名:', currentNeteaseDomain);
sendNativeMessage(currentNeteaseDomain);
return;
}
//返回全域名 给上位机做判断
var data = {
fhostUrl: urlInfo.fullDomain,
mainUrl: urlInfo.mainDomain,
};
console.log("[background] requestUrl: 使用标准域名:", data);
sendNativeMessage(data);
} else {
var data = { fhostUrl: "null" };
sendNativeMessage(data);
}
});
}
// 获取 URL
var url = new URL(currentTab.url);
// 提取主域名
var domain = url.hostname;
//填充密码
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 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,
});
});
}
//返回全域名 给上位机做判断
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) {
}
})
}
//上位机与中间程序通信断开的处理
if (message.command == "ipcDisconnect") {
//发送消息到popup
browser.runtime.sendMessage({
stateMsg: "ipcDisconnect",
function(response) {},
});
}
}

@@ -193,125 +192,145 @@

function onDisconnected() {
console.log('[background] 原生应用连接断开');
port = null;
//尝试重新连接
setTimeout(function() {
console.log('[background] 尝试重新连接原生应用...');
connect();
}, 10000);
//发送已断开的消息到popup
try {
browser.runtime.sendMessage({
stateMsg: "disconnected"
}, function(response) {
if (browser.runtime.lastError) {
console.error('[background] 发送断开消息失败:', browser.runtime.lastError);
}
});
} catch (error) {
console.error('[background] 发送断开消息异常:', error);
}
console.log("[background] 原生应用连接断开");
port = null;
//尝试重新连接
setTimeout(function () {
console.log("[background] 尝试重新连接原生应用...");
connect();
}, 10000);
//发送已断开的消息到popup
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) {
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();
}
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 });
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"]');
if (checkbox) {
checkbox.forEach(function (element) {
if (!element.checked) {
element.click();
}
})
// checkbox.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();
}
//填充完毕后 按下回车
var button = form.querySelector('[type="submit"],button');
button.click();
// 查找包含 "登录" 文字的按钮
const buttonsWithLoginText = Array.from(
document.querySelectorAll("button"),
).filter((button) => button.textContent.includes("登录"));
//填充完毕后 按下回车
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("登录"));
// 查找包含 "登录" 文字的超链接
const linksWithLoginText = Array.from(document.querySelectorAll('a'))
.filter(link => link.textContent.includes('登录'));
// 输出结果
}
// 输出结果
}
}
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 };
}
// 拆分域名部分
let domainParts = url.split('/')[0].split('.');
// 检查是否是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(".");
// 特殊处理双层域名
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 };
}

@@ -325,2 +325,3 @@ const possibleSelectors = [

input.name === "user" ||
input.name === "j_username" ||
input.name === "UserID" ||

@@ -327,0 +328,0 @@ input.name === "userId" ||

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

"name": "\u5b87\u8d77\u5bc6\u7801\u7ba1\u7406",
"version": "1.76",
"version": "1.77",
"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

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