重构浏览器自动化功能:执行脚本,获取地址等操作,需指定标签页,新增标签页截图功能

This commit is contained in:
fofolee
2025-01-23 00:30:09 +08:00
parent 26360e9643
commit e942259c2e
6 changed files with 366 additions and 211 deletions

View File

@@ -116,8 +116,10 @@ const getOptimalSelector = () => {
`;
};
const getSelector = async () => {
return await executeScript(`
const getSelector = async (tab) => {
return await executeScript(
tab,
`
return new Promise((resolve) => {
// 创建高亮元素
const highlight = document.createElement('div');
@@ -172,7 +174,8 @@ const getSelector = async () => {
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('click', handleClick, true);
});
`);
`
);
};
module.exports = {