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], {