From b9ed29dc4424ad0abf9d72d258cbac2e02afc155 Mon Sep 17 00:00:00 2001 From: dengshenkk Date: Tue, 16 May 2023 16:34:57 +0800 Subject: [PATCH] Update content.js fix #113 --- src/content.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/content.js b/src/content.js index bca5555..3b31b3b 100644 --- a/src/content.js +++ b/src/content.js @@ -6,6 +6,30 @@ document.onkeyup = (e) => { } } +function escapeChars(str) { + // 替换<, >, {, }, (, ), ;字符为实体字符 + return str.replace(/[<>{}();]/g, function(match) { + switch (match) { + case '<': + return '<'; + case '>': + return '>'; + case '{': + return '{'; + case '}': + return '}'; + case '(': + return '('; + case ')': + return ')'; + case ';': + return ';'; + default: + return match; + } + }); +} + $(document).ready(() => { var actions = []; var isFiltered = false; @@ -98,9 +122,9 @@ $(document).ready(() => { img = ""+action.emojiChar+"" } if (index != 0) { - return $("
"+img+"
"+action.title+"
"+action.url+"
"+keys+"
Select
")[0] + return $("
"+img+"
"+action.title+"
"+action.url+"
"+keys+"
Select
")[0] } else { - return $("
"+img+"
"+action.title+"
"+action.url+"
"+keys+"
Select
")[0] + return $("
"+img+"
"+action.title+"
"+action.url+"
"+keys+"
Select
")[0] } } actions.length && new VirtualizedList.default($("#omni-extension #omni-list")[0], {