If you’re using the JavaScript expression engine, you can improve things a lot by using array.includes():
par = parent.text.sourceText;
src = par.charAt(par.length-1);
lib = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
libNum = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "/", ":", ";", "(", ")", "$", "&", "@", '"', '“', '”', ".", ",", "?", "!", "'", "’"];
libSym = ["[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"];
if (src == " ") {
1;
}else if (lib.includes(src)){
2;
}else if (lib.includes(src.toLowerCase())){
3;
}else if (libNum.includes(src)){
4;
}else if (libSym.includes(src)){
5;
}else{ // just in case
6;
}