JSFiddle - React, Tailwind, and code Playground

by scurrilus

HTML

<div class="article__body">
<div class="p_7  obfuscated">=vm?=mj?26 Qsp{fou Njfunjoefsvoh ijfmu ebt Bnuthfsjdiu Cfsmjo.Tdi÷ofcfsh cfj fjofs [jnnfsufnqfsbuvs wpo 26 Hsbe gýs bohfnfttfo )B{; 3 D 565096*/=0mj?=mj?31 Qsp{fou Njfunjoefsvoh hftuboe ebt Bnuthfsjdiu Pmefocvsh cfj fjofs Ufnqfsbuvs wpo 29 Hsbe jn Ljoefs. voe Tdimbg{jnnfs fjofn Njfufs {v )B{; 2: D 66:088 WJJ*/ 36 Qsp{fou Njfunjoefsvoh tbi ebt Mboehfsjdiu Nýodifo J bmt hfsfdiugfsujhu bo- xfjm ejf Xpiovoh xfhfo fjoft Ifj{vohtefgfluft bvg 26 Hsbe Dfmtjvt bclýimuf )B{; 31 T 484:095*/=0mj?=mj?41 Qsp{fou Njfunjoefsvoh xjfefsvn gboe ebt Bnuthfsjdiu H÷smju{ jo Pseovoh- xfjm ejf [jnnfs ovs svoe 27.29 Hsbe Dfmtjvt xbsn xvsefo )B{;2 D 24310:7*/=0mj?=0vm?=vm?=mj?=tuspoh?Njfusfdiu;=0tuspoh?
            <a href="//localhost:3000/leben/mietrecht-was-im-hausflur-stehen-darf-und-was-nicht-id227469089.html" title="Mietrecht: Was im Hausflur stehen darf und was nicht">Was im Hausflur stehen darf und was nicht</a>
            =0mj?=mj?=tuspoh?Njfuopnbefo;=0tuspoh?
            <a href="//localhost:3000/leben/mietnomaden-wie-koennen-vermieter-gegen-sie-vorgehen-id227463995.html" title="Mietnomaden: Wie können Vermieter gegen sie vorgehen?">Wie können Vermieter gegen sie vorgehen</a>

            =0mj?=mj?=tuspoh?Njfuwfsusbh;=0tuspoh?<a href="//localhost:3000/leben/mietvertrag-das-sind-die-fuenf-haeufigsten-irrtuemer-id227446411.html" title="Mietvertrag: Das sind die fünf häufigsten Irrtümer ">Das sind die fünf häufigsten Irrtümer</a> =0mj?=0vm?</div>
</div>

JavaScript

function DeobfuscateText(rootNode, opts) {
    this.rootNode = rootNode;
    this.init();
}

DeobfuscateText.prototype.init = function () {
    jQuery('.obfuscated').each((index, elem) => {
        this.replaceTextContent(elem);
        jQuery(elem).removeClass('obfuscated').addClass('deobfuscated');
    });
};

DeobfuscateText.prototype.replaceTextContent = function (elem) {
    jQuery(elem).contents()
        .filter(function() {
            return this.nodeType === 3 && !jQuery(this.parentElement).hasClass('deobfuscated');
        })
        .replaceWith(function() {
            const obfuscatedText = this.data;
            let deobfuscatedText = '';

            for (let i = 0; i < obfuscatedText.length; i++) {
                const charValue = obfuscatedText.charCodeAt(i);
                if (charValue === 177) {
                    deobfuscatedText += '&';
                } else if (charValue === 178) {
                    deobfuscatedText += '!';
                } else if (charValue === 180) {
                    deobfuscatedText += ';';
                } else if (charValue === 181) {
                    deobfuscatedText += '=';
                } else if (charValue === 32) {
                    deobfuscatedText += ' ';
                } else if (charValue > 33) {
                    deobfuscatedText += String.fromCharCode(charValue - 1);
                }
            }
            return deobfuscatedText;
        });
};

jQuery.fn.deobfuscateText = function (opts) {
    return this.each(function () {
        new DeobfuscateText(this, opts);
    });
};
function DeobfuscateText(rootNode, opts) {
    this.rootNode = rootNode;
    this.init();
}

DeobfuscateText.prototype.init = function () {
    jQuery('.obfuscated').each((index, elem) => {
        this.replaceTextContent(elem);
        jQuery(elem).removeClass('obfuscated').addClass('deobfuscated');
    });
};

DeobfuscateText.prototype.replaceTextContent = function (elem) {
    jQuery(elem).contents()
     ...