Accented letters workaround for WhatsApp on Firefox Linux

11/27/2023, 6:47:56 AM

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Accented letters workaround for WhatsApp on Firefox Linux
// @namespace   Violentmonkey Scripts
// @match       https://web.whatsapp.com/
// @grant       none
// @version     1.0
// @author      André Kugland
// @license     MIT
// @description 11/27/2023, 6:47:56 AM
// ==/UserScript==

// https://forum.manjaro.org/t/whatsapp-web-deleting-letter-that-starts-with-accent/119772

// This script was created through trial and error. I don’t know why it works, but it does
// work, at least for me in my particular configuration.
(() => {
  const eatevent = (e) => {
    e.preventDefault();
    e.stopPropagation();
    return false;
  };
  for (const evtype of ["compositionstart", "compositionend"]) {
    document.addEventListener(evtype, (e) => {
      eatevent(e);
      if (evtype == "compositionstart") {
        document.addEventListener("input", eatevent, true);
      }
      if (evtype == "compositionend") {
        document.removeEventListener("input", eatevent, true);
      }
    }, true);
  }
})();