Last active
June 23, 2021 15:49
-
-
Save eyy/7d37f1a0a9debf0286efaa3aa4651c3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let r = 'αβσδεφγ῾ικλμνοπρστυξυζηω'.split('').reduce((o,curr,i) => {o['abcdefghiklmnoprstuxyzēō'[i]] = curr;return o}, {}) | |
function gr(s) { return s.replace('th','θ').replace('ch','χ').replace(/./gui, a=>r[a]||a).replace(/σ /g, 'ς ') } | |
// replace selected | |
s=window.getSelection() | |
t=s.toString() | |
p=s.focusNode.parentNode;p.innerHTML=p.innerHTML.replace(t, gr(t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment