From 87246f41bed7c3e651f88611ce86e827f16fdec0 Mon Sep 17 00:00:00 2001 From: zhangtianli2006 Date: Thu, 26 Aug 2021 20:51:03 +0800 Subject: [PATCH] [feature] md lichess extension Signed-off-by: zhangtianli2006 --- public/script.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/public/script.js b/public/script.js index b3f23c8..d8aa1e9 100644 --- a/public/script.js +++ b/public/script.js @@ -23,6 +23,25 @@ function format_time(time) { return `${time.getMonth() + 1}-${time.getDate()} ${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`; } +function render_chess(msg) { + if (!msg.toUpperCase().includes("!{LC}")) { + return msg; + } + + url = msg.substring(msg.indexOf("(") + 1, msg.indexOf(")")); + if (url.length == 0) { + return msg; + } + + if (url.toUpperCase() == "TV") { + return ''; + } + if (url.toUpperCase() == "TRAINING" || url.toUpperCase() == "PUZZLE") { + return ``; + } + return ``; +} + function write_message(data) { const message = data.msg; @@ -44,6 +63,8 @@ function write_message(data) { } rendered_message = DOMPurify.sanitize(rendered_message); + rendered_message = render_chess(rendered_message); + $('#message').append(`