From e7bd55a0b2fed3e4833db91958a9228c28f097ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Thu, 28 Dec 2023 21:40:08 +0000 Subject: [PATCH] send automatically --- src/main.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 1d25869..fec57b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -const emote_regex = /bttv:([^\s]+)/g; +const emote_regex = /bttv:([^\s]+)/gi; type Emote = { code: string; @@ -74,6 +74,11 @@ async function process_text(text: string): Promise { const cb_form = document.querySelector("#mgc_cb_evo_form"); if (!(cb_form instanceof HTMLFormElement)) return; + const cb_send = document.querySelector( + "#mgc_cb_evo_form > input[type=image]:nth-child(2)", + ); + if (!(cb_send instanceof HTMLInputElement)) return; + const bttv_btn = (() => { const btn = document.createElement("a"); btn.style.setProperty("cursor", "pointer"); @@ -81,24 +86,24 @@ async function process_text(text: string): Promise { const img = document.createElement("img"); img.setAttribute("src", chrome.runtime.getURL("img/sb_button.png")); + img.setAttribute("alt", "bttv emotes ersetzen und absenden"); + img.setAttribute("title", "bttv:* emotes ersetzen und absenden"); img.style.setProperty("vertical-align", "middle"); - btn.addEventListener("click", async (event) => { + btn.addEventListener("click", async () => { const cb_input = document.querySelector("#mgc_cb_evo_input"); if (!(cb_input instanceof HTMLInputElement)) return; cb_input.value = await process_text(cb_input.value); cb_input.focus(); + cb_send.click(); }); btn.appendChild(img); return btn; })(); - cb_form.insertBefore( - bttv_btn, - document.querySelector("#mgc_cb_evo_form > input[type=image]:nth-child(2)"), - ); + cb_form.insertBefore(bttv_btn, cb_send); console.log("done."); })();