Revision 61e84f81-3beb-4081-922e-0b2893b25d30 - Code Golf Stack Exchange
# [JavaScript (Node.js)], 131 bytes
<!-- language-all: lang-javascript -->
s=>s.replace(/[a-z]/gi,c=>(s+g(i=B(c)[0]-1)?"":"ei")+(h=j=>g(i)^g(j=-~j%26)?h(j):B([j+1|i&96]))(i&31),B=Buffer,g=i=>s=1065233>>i&1)
[Try it online!][TIO-l8amd0h4]
[JavaScript (Node.js)]: https://nodejs.org
[TIO-l8amd0h4]: https://tio.run/##Xc3BCoIwGADge08Rg@T/UatpCQn/Ak@9QHQQA5lzbYwmrjpE9OrmufN3@Gz7aoMczfBI775TU09TIBHWoxpcKxVs6jZ9NxttEkkCQqzBUAUS622TcjwyVjJlGMZwI0tiVrxqsJR@7Sor8HgDi2UFtY35x0SHokEEE@Uck4qqZ9@rMdFk5pD4tthneS6EiThO0t@Dd2rtvIYe2Ek555cXP7qOIS7@9PzmWb6bYfoB "JavaScript (Node.js) – Try It Online"
### Commented
s => // s = input string
s.replace( // replace in s
/[a-z]/gi, c => // each letter c (case insensitive)
( //
s + // if the previous letter was a vowel
// (or this is the first iteration)
g( // or the current letter
i = // whose ASCII code - 1 is
B(c)[0] - 1 // loaded in i
) ? // is a vowel:
"" // append nothing
: // else:
"ei" // append "ei"
) + ( //
h = j => // h is a recursive function
g(i) ^ // if the type of the current letter
g( // is not equal to the type of
j = -~j % 26 // the next letter in the alphabet (wrapping)
) ? // then:
h(j) // do a recursive call
: // else:
B([ // output the letter
j + 1 | // whose ASCII code is j + 1
i & 96 // with bits #5 and #6 taken from i
]) //
)(i & 31), // initial call to h with i mod 32
B = Buffer, // define B for Buffer
g = i => // g is a helper function taking an integer
s = 1065233 // representing an ASCII code minus 1
>> i & 1 // and returning 0 for consonant / 1 for vowel
) //