[in]失败后停止【值/表达式】True
[in]操作类型【值/表达式】RunScript
[in]超时时间(ms)【值/表达式】3000
[in]标签页Id【值/表达式】
连接的浏览器:chrome
[in]运行脚本的框架【值/表达式】all
[in]脚本内容【值/表达式】(function() {\r\n
console.log("开始执行名称获取脚本...");\r\n
\r\n
function getSVGNameIntelligently() {\r\n
// 1. 尝试从对话框标题获取名称\r\n
const dialogTitles = document.querySelectorAll('.top-title > span:first-child, .dialog-title, .title-text');\r\n
if (dialogTitles.length > 0) {\r\n
for (let title of dialogTitles) {\r\n
if (title.textContent && title.textContent.trim()) {\r\n
console.log("✅ 获取到名称:", title.textContent.trim());\r\n
return title.textContent.trim();\r\n
}\r\n
}\r\n
}\r\n
\r\n
// 2. 尝试获取当前活跃的对话框标题\r\n
const activeDialogs = document.querySelectorAll('[id^="body_dlg_"]');\r\n
for (let dialog of activeDialogs) {\r\n
if (window.getComputedStyle(dialog).display !== 'none') {\r\n
const titleElement = dialog.querySelector('.top-title > span:first-child');\r\n
if (titleElement && titleElement.textContent) {\r\n
console.log("✅ 从活跃对话框获取到名称:", titleElement.textContent.trim());\r\n
return titleElement.textContent.trim();\r\n
}\r\n
}\r\n
}\r\n
\r\n
// 3. 尝试根据当前显示的对话框ID获取对应标题\r\n
const currentDialogId = document.querySelector('[id^="body_dlg_"]:not([style*="display: none"])');\r\n
if (currentDialogId) {\r\n
const titleSelector = `#${currentDialogId.id} > div.top-title > span:first-child`;\r\n
const specificTitle = document.querySelector(titleSelector);\r\n
if (specificTitle && specificTitle.textContent) {\r\n
console.log("✅ 从特定ID对话框获取到名称:", specificTitle.textContent.trim());\r\n
return specificTitle.textContent.trim();\r\n
}\r\n
}\r\n
\r\n
// 4. 尝试获取页面中任何可能的标题\r\n
const possibleTitles = document.querySelectorAll('h1, h2, h3, .title, .heading');\r\n
for (let title of possibleTitles) {\r\n
if (title.textContent && title.textContent.trim()) {\r\n
console.log("✅ 从页面标题获取到名称:", title.textContent.trim());\r\n
return title.textContent.trim();\r\n
}\r\n
}\r\n
\r\n
console.log("❌ 未能获取到名称");\r\n
return ""; // 返回空字符串而不是错误信息\r\n
}\r\n
\r\n
// 直接获取名称并返回\r\n
const name = getSVGNameIntelligently();\r\n
return name; // 只返回名称,不返回其他信息\r\n
})();
[in]从脚本手动返回数据【值/表达式】False
[in]执行环境【值/表达式】
[out]原始返回结果=>svgName下架\n
625 书签\n
耗时:24ms