send automatically
This commit is contained in:
		
							parent
							
								
									eb97f4b5f0
								
							
						
					
					
						commit
						e7bd55a0b2
					
				
					 1 changed files with 11 additions and 6 deletions
				
			
		
							
								
								
									
										17
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								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<string> {
 | 
			
		|||
  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<string> {
 | 
			
		|||
 | 
			
		||||
    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.");
 | 
			
		||||
})();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue