change in behavior of Transform & Replace Selection With Java Script

After updating to 5.0.90+ I have this strange behavior on chrome and some other places

when pressing double shift I run javascript to change the last word to greek letters or vice versa.

the difference of the behavior between example and chrome is shown in attached videos

The code is

async (clipboardContentString) => {
    const alphabetEN = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const alphabetGR = "αβψδεφγηιξκλμνοπ;ρστθωςχυζΑΒΨΔΕΦΓΗΙΞΚΛΜΝΟΠ;ΡΣΤΘΩΧΥΖ";

    // Determine if the first character is in the English alphabet
    const firstIsEnglish = alphabetEN.indexOf(clipboardContentString[0]) !== -1;

    let newMessage = "";

    if (firstIsEnglish) {
        // Switch layout to Greek
        await trigger_named_async_without_response({
            trigger_name: 'changeInputGR',
            wait_for_reply: false
        });

        // Convert only English letters to Greek
        for (const char of clipboardContentString) {
            const idx = alphabetEN.indexOf(char);
            if (idx !== -1) {
                // If char is English, map it to the Greek equivalent
                newMessage += alphabetGR[idx];
            } else {
                // Keep anything else (already Greek or punctuation) as is
                newMessage += char;
            }
        }
    } else {
        // Switch layout to English
        await trigger_named_async_without_response({
            trigger_name: 'changeInputEN',
            wait_for_reply: false
        });

        // Convert only Greek letters to English
        for (const char of clipboardContentString) {
            const idx = alphabetGR.indexOf(char);
            if (idx !== -1) {
                // If char is Greek, map it to the English equivalent
                newMessage += alphabetEN[idx];
            } else {
                // Keep anything else (already English or punctuation) as is
                newMessage += char;
            }
        }
    }

    return newMessage;
};



it adds a new line or something

thanks for reporting, I'll check!

your script eems to work fine here, is this happening everywhere in chrome? Or in a specific website?

Which version of macOS are you on?

It happens on MS Teams Chrome specifically that I have found out and some other places I cant recall, I will update when it occurs again.

macOS 15.2 (24C101)


I added a delay here between and problems seem to be fixed.

1 Like

weird, this wasn’t necessary before?

Before it failed in some places, but after 5.0.90+ in more places.
With the delay it doesn't seem to fail on places that failed before.