Disable WhatsApp automatic emoji conversion
The script works by patching the webpack chunks instead of manipulating the DOM.
The script works by patching the webpack chunks instead of manipulating the DOM.
// ==UserScript== | |
// @name Disable WhatsApp automatic emoji conversion | |
// @namespace Violentmonkey Scripts | |
// @match https://web.whatsapp.com/* | |
// @grant none | |
// @version 1.0 | |
// @author shark0der | |
// @description 11/11/2022, 00:53:53 AM | |
// ==/UserScript== | |
self.webpackChunkwhatsapp_web_client = self.webpackChunkwhatsapp_web_client || []; | |
(() => { | |
// webpack array | |
const wp = self.webpackChunkwhatsapp_web_client; | |
// callbacks | |
const push = wp.push.bind(wp); | |
let callback = push; | |
// tainted symbol | |
const isTainted = Symbol('tainted'); | |
const patchChunk = chunk => { | |
const [[chunkId], modules, ...whatev] = chunk; | |
const patchedModules = Object.keys(modules).reduce((acc, id) => { | |
const f = modules[id]; | |
if (!f.toString().includes('TEXT_TO_EMOJI_HASH=')) { | |
return { ...acc, [id]: f }; | |
} | |
console.log(`Patching chunkId=${chunkId} moduleId=${id}`); | |
const p = function(e, t, n) { | |
f(e, t, n); | |
Object.keys(t.TEXT_TO_EMOJI_HASH).forEach(k => delete t.TEXT_TO_EMOJI_HASH[k]); | |
}; | |
return { ...acc, [id]: p }; | |
}, {}); | |
return [[chunkId], patchedModules, ...whatev]; | |
}; | |
const hijackedPush = (function(...items) { | |
const [chunk, ...rest] = items; | |
if (chunk[isTainted]) { | |
delete chunk[isTainted]; | |
return push(chunk, ...rest); | |
} | |
const patchedChunk = patchChunk(chunk); | |
Object.defineProperty( | |
patchedChunk, | |
isTainted, | |
{ enumerable: false, value: true, configurable: true }, | |
); | |
return callback(patchedChunk, ...rest); | |
}).bind(wp); | |
Object.defineProperty(wp, 'push', { | |
set: _callback => (callback = _callback), | |
get: () => hijackedPush, | |
}); | |
})(); |
Thanks, works great for me! 👍