From 4e761b21174078ec7fe78ae44940db4148e5d0f9 Mon Sep 17 00:00:00 2001 From: ZiG60020405 <47026578+zhichaoxi2006@users.noreply.github.com> Date: Sun, 2 Jun 2024 16:50:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0get.plainText=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/extra/skill.js | 12 ++++++------ character/yingbian/skill.js | 2 +- noname/get/index.js | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/character/extra/skill.js b/character/extra/skill.js index 8d2cf937e..07fb96d74 100644 --- a/character/extra/skill.js +++ b/character/extra/skill.js @@ -1438,7 +1438,7 @@ const skills = { var info = lib.character[name]; if ( info[3].some(function (skill) { - var info = get.skillInfoTranslation(skill); + var info = get.plainText(get.skillInfoTranslation(skill)); if (!info.includes("【杀】")) return false; var list = get.skillCategoriesOf(skill, player); list.remove("锁定技"); @@ -1470,7 +1470,7 @@ const skills = { var name = button.link; var info = lib.character[name]; var skills = info[3].filter(function (skill) { - var info = get.skillInfoTranslation(skill); + var info = get.plainText(get.skillInfoTranslation(skill)); if (!info.includes("【杀】")) return false; var list = get.skillCategoriesOf(skill, get.player()); list.remove("锁定技"); @@ -1509,7 +1509,7 @@ const skills = { node = ui.create.buttonPresets.character(item, "character", position, noclick); const info = lib.character[item]; const skills = info[3].filter(function (skill) { - var info = get.skillInfoTranslation(skill); + var info = get.plainText(get.skillInfoTranslation(skill)); if (!info.includes("【杀】")) return false; var list = get.skillCategoriesOf(skill, get.player()); list.remove("锁定技"); @@ -1588,7 +1588,7 @@ const skills = { var maxHp = get.infoMaxHp(info[2]); if (maxHp != 1) card.distance = { attackFrom: 1 - maxHp }; var skills = info[3].filter(function (skill) { - var info = get.skillInfoTranslation(skill); + var info = get.plainText(get.skillInfoTranslation(skill)); if (!info.includes("【杀】")) return false; var list = get.skillCategoriesOf(skill, get.player()); list.remove("锁定技"); @@ -1617,10 +1617,10 @@ const skills = { if (skills.length) { for (var skill of skills) { if (lib.skill[skill].nobracket) { - append += '
' + get.translation(skill) + '
' + get.skillInfoTranslation(skill) + "


"; + append += '
' + get.translation(skill) + '
' + get.plainText(get.skillInfoTranslation(skill)) + "


"; } else { var translation = lib.translate[skill + "_ab"] || get.translation(skill).slice(0, 2); - append += '
【' + translation + '】
' + get.skillInfoTranslation(skill) + "


"; + append += '
【' + translation + '】
' + get.plainText(get.skillInfoTranslation(skill)) + "


"; } } str = str.slice(0, str.length - 8); diff --git a/character/yingbian/skill.js b/character/yingbian/skill.js index 52e8458d4..25019f6ca 100644 --- a/character/yingbian/skill.js +++ b/character/yingbian/skill.js @@ -1750,7 +1750,7 @@ const skills = { var skill = lib.skill[j]; if (!skill || skill.juexingji || skill.hiddenSkill || skill.zhuSkill || skill.dutySkill || skill.chargeSkill || lib.skill.bolan.banned.includes(j)) continue; if (skill.init || (skill.ai && (skill.ai.combo || skill.ai.notemp || skill.ai.neg))) continue; - var info = lib.translate[j + "_info"]; + var info = get.plainText(lib.translate[j + "_info"]); if (info && info.indexOf("出牌阶段限一次") != -1) skills.add(j); } } diff --git a/noname/get/index.js b/noname/get/index.js index 2ff7d104c..c4826002b 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -974,6 +974,16 @@ export class Get { return target; } + /** + * 用于将HTML代码转换为纯文本。 + * @param { string } htmlContent + * @returns { string } + */ + plainText(htmlContent) { + var parser = new DOMParser(); + var doc = parser.parseFromString(htmlContent || '', 'text/html'); + return doc.body.textContent || doc.body.innerText; + } inpilefull(type) { var list = []; for (var i in lib.cardPile) {