JSFiddle - React, Tailwind, and code Playground
HTML
<textarea rows="10" cols="45" id="text">Аноны, скоро на украине будут убивать и сажать в тюрьму.</textarea><br/>
<input type="checkbox" id="silo">Дiбiвiт' сiла?</textarea><br/>
<button onclick="maketext();">Укрiїнiфiцiрiвiть</button>
JavaScript
maketext = function()
{
// Нiчiнiєм зiмєнiт' тєкст
text = $("#text").val();
// Зiмєнiєм глiснiє
text = text.replace(/([уыаояиюУЫАОЯИЮ])/g, replacei);
// Дiблi
text = text.replace(/(ii)/g, 'i');
text = text.replace(/(II)/g, 'I');
// В лiбiм слiчiє мєнiєм i
text = text.replace(/(и)/g, 'i');
text = text.replace(/(И)/g, 'I');
// В лiбiм слiчiє мєнiєм i
text = text.replace(/(ы)/g, 'i');
text = text.replace(/(Ы)/g, 'I');
// В лiбiм слiчiє мєнiєм 'о
text = text.replace(/(ё)/g, 'ьо');
text = text.replace(/(Ё)/g, 'О');
// Зiмєнiєм В в В
text = text.replace(/(\sэто\s)/g, ' цэ ');
text = text.replace(/(\sЭто\s)/g, ' Цэ ');
// Мєнiєм Є i Е
text = text.replace(/(е)/g, 'є');
text = text.replace(/(Е)/g, 'Є');
text = text.replace(/(э)/g, 'е');
text = text.replace(/(Э)/g, 'Е');
// Зiмєнiєм В в В
text = text.replace(/(\sна\s)/g, ' в ');
text = text.replace(/(\sНа\s)/g, ' В ');
// Зiмєнiєм як в як
text = text.replace(/(\sкiк\s)/g, ' як ');
text = text.replace(/(\sКiк\s)/g, ' Як ');
// Зiмєнiєм з в з
text = text.replace(/(\siз\s)/g, ' з ');
text = text.replace(/(\sIз\s)/g, ' З ');
// Мiгкiй знiк
text = text.replace(/(ь)/g, '\'');
text = text.replace(/(Ь)/g, '\'');
hvili = "СЛIВА УКРIНЄ!";
if ($("#silo").get(0).checked) hvili = "[b]СЛIВА УКРIНЄ![/b]";
// Вiсхвiлiєм
$("#text").val(text + " \r\n" + hvili);
}
replacei = function(str, p1, offset, s)
{
i = 'i';
// Єслi бiква бiл'шiя
if(p1.search(/[УЕЫАОЯИЮ]/) != -1) i = 'I';
var coll = ",.?!:; ";
// Єслi бiква в нiчiлє iлi кiнцє слiва, то нє мєнiєм єё
if((offset == s.length-1) || (offset == 0)) i = p1;
if((offset < s.length-1) && s[offset+1].toString().search(/[,\.\?!:;\s]/) != -1) i = p1;
if((offset > 0) && (s[offset-1].toString().search(/[,\.\?!:;\s]/) != -1)) i =...