bizofack

Untitled

Nov 19th, 2020 (edited)
730
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const element = document.getElementsByClassName('im-chat-input--text')[0];
  2.  
  3. element.onkeyup = () => {
  4.     if (element.getValue().indexOf('-') !== -1) {
  5.         element.setValue(element.getValue().replace(/-/g, '—'))
  6.  
  7.         const range = document.createRange();
  8.         range.selectNodeContents(element);
  9.         range.collapse(false);
  10.         const sel = window.getSelection();
  11.         sel.removeAllRanges();
  12.         sel.addRange(range);
  13.     }
  14. }
RAW Paste Data